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 🙏

© 2026 – Pkg Stats / Ryan Hefner

og-shot

v0.4.0

Published

CLI to auto generate OG images for your Next.js App Router app.

Readme

og-shot

CLI to auto generate OG images for your Next.js App Router app. It screenshots your real pages, so the social cards match what people actually see. No separate templates to keep in sync.

Install

npm install -D og-shot
# pnpm add -D og-shot
# yarn add -D og-shot
# bun add -d og-shot

That's it. Chromium downloads automatically the first time you run it.

Use

Scaffold the config and a script in one step:

npx og-shot init

That adds an og-shot key and an "og": "og-shot" script to your package.json, so there's no extra config file in the root:

{
  "og-shot": {
    "baseUrl": { "production": "https://example.com", "development": "http://localhost:3000" },
    "outDir": "public/og",
    "locales": ["de", "en"],
    "resolution": { "width": 1200, "height": 630, "captureWidth": 1440, "captureHeight": 756 },
    "routes": ["/", { "slug": "about", "paths": { "de": "/about", "en": "/en/about" } }]
  }
}

Run it (init added the og script, so npm run og works):

npm run og                       # production, every route and locale
npm run og -- --env development  # screenshot localhost
npm run og -- --only about       # one route
npm run og -- --dry-run          # print the plan, capture nothing

Or call the binary directly: npx og-shot, npx og-shot --dry-run, etc. You get one PNG per route and locale in public/og.

Want autocomplete and a typed config (or a function for localePrefix)? Use og.config.ts instead of the package.json key:

import { defineConfig } from "og-shot";

export default defineConfig({
  baseUrl: { production: "https://example.com" },
  outDir: "public/og",
  routes: ["/"],
});

Routes

A route is a string or an object:

"/pricing"                                                  // slug taken from the path
{ slug: "about", path: "/about" }                           // prefixed per locale
{ slug: "about", paths: { de: "/about", nl: "/nl/over-ons", en: null } } // explicit, null skips

Use paths when the localized slugs differ. Set a locale to null to skip it, so an untranslated page never ships a wrong language card.

Read routes from the Next build manifest instead of listing them (run next build first):

autoScan: { stripSegments: ["locale"], ignore: ["/api"] }

Wiring og:image

Generating the PNGs does not change your meta tags. Set manifest and og-shot writes a map of the cards it produced:

// og.config: "manifest": "lib/og-cards.json"
{
  "about": { "de": "/og/about-de.png", "en": "/og/about-en.png" },
  "pricing": { "de": "/og/pricing-de.png" }   // a skipped locale is just absent
}

Read it in your metadata. In Next.js:

import cards from "@/lib/og-cards.json";

export async function generateMetadata({ params }) {
  const { locale } = await params;
  const image = cards["about"]?.[locale];
  return { openGraph: { images: image ? [image] : undefined } };
}

A locale that was skipped (set to null) is missing from the map, so image is undefined and you fall back to your default card.

How it works

It opens each route in headless Chromium at the capture size, waits for fonts, then downscales to the output size with sharp. Capturing wide and shrinking gives sharper text than rendering straight at 1200x630. Cookies are cleared between pages so a locale cookie cannot leak into the next URL.

License

MIT