🚀. Socket Launch Week Day 2:Introducing Manifest Alerts.Learn more
Sign In

web-page-snapshot

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web-page-snapshot

A React component to render web page snapshot previews from URLs

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
2
-60%
Maintainers
1
Weekly downloads
 
Created
Source

web-page-snapshot

A React component to render web page snapshot previews from URLs. Works with React and Next.js applications.

npm version

Installation

npm install web-page-snapshot

or

yarn add web-page-snapshot

Usage

Basic Usage

import { WebPageSnapshot } from 'web-page-snapshot';

function App() {
  return (
    <WebPageSnapshot url="https://github.com" />
  );
}

With Custom Dimensions

<WebPageSnapshot 
  url="https://github.com" 
  width={500} 
  height={350}
/>

Show Metadata (Title, Description, Favicon)

<WebPageSnapshot 
  url="https://github.com" 
  showTitle={true}
  showDescription={true}
  showFavicon={true}
/>

Non-Clickable Snapshot

<WebPageSnapshot 
  url="https://github.com" 
  clickable={false}
/>
<WebPageSnapshot 
  url="https://github.com" 
  target="_self"
/>

With Custom Styling

<WebPageSnapshot 
  url="https://github.com" 
  className="my-custom-class"
  style={{ borderRadius: '16px' }}
/>

With Event Handlers

<WebPageSnapshot 
  url="https://github.com" 
  onLoad={() => console.log('Snapshot loaded!')}
  onError={(error) => console.error('Failed to load:', error)}
/>

Custom Placeholder

<WebPageSnapshot 
  url="https://github.com" 
  placeholder={<div>Loading preview...</div>}
/>

Using Different Screenshot Services

// Using Microlink (default)
<WebPageSnapshot 
  url="https://github.com" 
  screenshotService="microlink"
/>

// Using URLBox with API key
<WebPageSnapshot 
  url="https://github.com" 
  screenshotService="urlbox"
  apiKey="your-api-key"
/>

// Using custom screenshot service
<WebPageSnapshot 
  url="https://github.com" 
  screenshotService="custom"
  customScreenshotUrl="https://your-service.com/screenshot?url={url}"
/>

Props

PropTypeDefaultDescription
urlstringrequiredThe URL of the web page to capture
widthnumber | string400Width of the snapshot container
heightnumber | string300Height of the snapshot container
altstring-Alternative text for the snapshot image
clickablebooleantrueWhether to open the URL when clicking
target'_blank' | '_self' | '_parent' | '_top''_blank'Target for the link
classNamestring-Additional CSS class names
styleReact.CSSProperties-Inline styles for the container
onLoad() => void-Callback when snapshot loads
onError(error: Error) => void-Callback when snapshot fails
placeholderReact.ReactNode-Custom loading placeholder
showFaviconbooleantrueShow website favicon
showTitlebooleantrueShow website title
showDescriptionbooleanfalseShow website description
screenshotService'microlink' | 'urlbox' | 'custom''microlink'Screenshot service to use
customScreenshotUrlstring-Custom screenshot URL template
apiKeystring-API key for screenshot service

Screenshot Services

This component uses external screenshot services to capture web page previews:

  • Microlink (default): Free tier available, good for most use cases
  • URLBox: Requires API key, offers more customization
  • Custom: Use any screenshot service by providing a URL template

Next.js Usage

The component works seamlessly with Next.js. For server-side rendering, make sure to dynamically import the component:

import dynamic from 'next/dynamic';

const WebPageSnapshot = dynamic(
  () => import('web-page-snapshot').then((mod) => mod.WebPageSnapshot),
  { ssr: false }
);

function Page() {
  return <WebPageSnapshot url="https://github.com" />;
}

Styling

The component comes with default styles that can be customized using CSS. You can also override styles using the className and style props.

CSS Classes

  • .web-page-snapshot - Main container
  • .web-page-snapshot__link - Link wrapper (when clickable)
  • .web-page-snapshot__image-container - Image container
  • .web-page-snapshot__image - Snapshot image
  • .web-page-snapshot__loading - Loading state container
  • .web-page-snapshot__spinner - Default loading spinner
  • .web-page-snapshot__error - Error state container
  • .web-page-snapshot__info - Metadata info section
  • .web-page-snapshot__favicon - Favicon image
  • .web-page-snapshot__title - Page title
  • .web-page-snapshot__description - Page description
  • .web-page-snapshot__url - URL display

License

MIT

Keywords

react

FAQs

Package last updated on 29 Nov 2025

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