npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

web-page-snapshot

v1.0.1

Published

A React component to render web page snapshot previews from URLs

Readme

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}
/>

Custom Link Target

<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

| Prop | Type | Default | Description | |------|------|---------|-------------| | url | string | required | The URL of the web page to capture | | width | number \| string | 400 | Width of the snapshot container | | height | number \| string | 300 | Height of the snapshot container | | alt | string | - | Alternative text for the snapshot image | | clickable | boolean | true | Whether to open the URL when clicking | | target | '_blank' \| '_self' \| '_parent' \| '_top' | '_blank' | Target for the link | | className | string | - | Additional CSS class names | | style | React.CSSProperties | - | Inline styles for the container | | onLoad | () => void | - | Callback when snapshot loads | | onError | (error: Error) => void | - | Callback when snapshot fails | | placeholder | React.ReactNode | - | Custom loading placeholder | | showFavicon | boolean | true | Show website favicon | | showTitle | boolean | true | Show website title | | showDescription | boolean | false | Show website description | | screenshotService | 'microlink' \| 'urlbox' \| 'custom' | 'microlink' | Screenshot service to use | | customScreenshotUrl | string | - | Custom screenshot URL template | | apiKey | string | - | 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