New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-native-preview-url

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-preview-url

A React Native component to generate rich link previews by fetching metadata (title, description, images) from URLs. Easily integrate customizable and lightweight link previews into your app.

latest
Source
npmnpm
Version
0.3.0
Version published
Maintainers
1
Created
Source

React Native Preview Url

A React Native library that provides an easy way to fetch and display link previews using the useUrlPreview hook and a customizable <LinkPreview /> component. It uses our own open-source free open source API azizbecha-link-preview-api available on GitHub at https://github.com/azizbecha/link-preview-api.

You can use the API for free without an API key or host it yourself if you prefer.

Features

  • Fetches metadata (title, description, images, favicons, etc.) from URLs
  • Customizable preview component with styles and fallback support
  • Supports timeout and error handling
  • Handles URL validation and loading states

Installation

npm install react-native-preview-url
# or
yarn add react-native-preview-url

Usage

useUrlPreview Hook

import { useUrlPreview } from 'react-native-preview-url';

const { loading, data, error } = useUrlPreview('https://github.com');

<LinkPreview /> Component

import React from 'react';
import { LinkPreview } from 'react-native-preview-url';

export const Example = () => (
  <LinkPreview
    url="https://github.com"
    timeout={3000} // optional, default timeout in ms
    onSuccess={(metadata) => console.log(metadata)}
    onError={(error) => console.error(error)}
    onPress={() => console.log('Pressed preview')}
    containerStyle={{ margin: 16, borderRadius: 8, backgroundColor: '#fff' }}
    imageStyle={{ borderRadius: 8, height: 150 }}
    titleStyle={{ fontSize: 18, fontWeight: 'bold' }}
    descriptionStyle={{ fontSize: 14, color: '#555' }}
    urlStyle={{ fontSize: 12, color: 'grey' }}
    titleLines={2}
    descriptionLines={3}
    showUrl={true}
    hideImage={false}
  />
);

Props

PropTypeRequiredDefaultDescription
urlstringYes-The URL to fetch metadata for
timeoutnumberNo3000Fetch timeout in milliseconds
onSuccess(data: LinkPreviewResponse) => voidNo-Callback when data is successfully fetched
onError(error: string) => voidNo-Callback when fetching metadata fails
onPress(url: string) => voidNo-Callback when the preview component is pressed
containerStyleViewStyleNo-Style for the container view
imageStyleImageStyleNo-Style for the preview image
titleStyleTextStyleNo-Style for the title text
descriptionStyleTextStyleNo-Style for the description text
urlStyleTextStyleNo-Style for the URL text
titleLinesnumberNo2Number of lines for title text truncation
descriptionLinesnumberNo4Number of lines for description text truncation
showUrlbooleanNotrueWhether to show the URL domain below the description
hideImagebooleanNofalseWhether to hide the preview image
visiblebooleanNotrueWhether to show or hide the preview component
loaderComponentReactNodeNoActivityIndicatorCustom loading component
fallbackImageImageSourcePropTypeNoundefinedFallback image in case the website doesn't have one

Example Response Object

{
  "status": 200,
  "title": "azizbecha - Overview",
  "description": "I'm fixing bugs now, I'll write a bio later. azizbecha has 26 repositories available. Follow their code on GitHub.",
  "url": "https://github.com/azizbecha",
  "images": [
    "https://avatars.githubusercontent.com/u/63454940?v=4?s=400"
  ],
  "favicons": [
    "https://github.githubassets.com/favicons/favicon.svg"
  ],
  "mediaType": "profile",
  "contentType": "text/html",
  "siteName": "GitHub"
}

License

MIT License

Keywords

react-native

FAQs

Package last updated on 25 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts