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

@ogxjs/next

v0.1.1

Published

Next.js adapter for OGX - High-performance OG image generation

Downloads

182

Readme

@ogxjs/next

Next.js integration for OGX - Generate OG images in App Router

Utilities for generating Open Graph images in Next.js App Router.

Installation

npm install @ogxjs/next @ogxjs/core

Next.js Configuration

Add this to your next.config.mjs:

/** @type {import('next').NextConfig} */
const config = {
  serverExternalPackages: ["@resvg/resvg-js", "@ogxjs/core"],
};

export default config;

Important: The serverExternalPackages setting prevents Next.js from bundling native dependencies, which is required for @resvg/resvg-js.

Usage

Create a route handler that returns an OG image:

// app/api/og/route.tsx
import { ogxResponse } from "@ogxjs/next";

export async function GET() {
  return ogxResponse({
    preset: "minimal",
    title: "Hello from Next.js!",
    subtitle: "Dynamic OG images",
  });
}

The ogxResponse helper automatically:

  • Sets correct Content-Type: image/png
  • Returns a Next.js Response object
  • Handles errors gracefully

Dynamic OG Images

Use route parameters for dynamic content:

// app/api/og/[slug]/route.tsx
import { ogxResponse } from "@ogxjs/next";

export async function GET(
  request: Request,
  { params }: { params: { slug: string } }
) {
  return ogxResponse({
    preset: "blog",
    title: params.slug.replace(/-/g, " "),
    description: "Read more about this topic",
  });
}

Custom Builder

Use the builder API for custom layouts:

import { ogxResponse } from "@ogxjs/next";
import { stack, div, span } from "@ogxjs/core";

export async function GET() {
  const element = stack("w-full h-full bg-blue-500 p-20", [
    div("text-white text-6xl font-bold", "Custom Layout"),
  ]);

  return ogxResponse({ element });
}

Metadata

Link your OG image in page metadata:

// app/page.tsx
export const metadata = {
  openGraph: {
    images: ['/api/og'],
  },
};

Performance Tips

Static Generation

For better performance, disable revalidation and use static params:

// app/api/og/[slug]/route.tsx
export const revalidate = false; // Disable ISR

export function generateStaticParams() {
  return [
    { slug: 'hello' },
    { slug: 'world' },
  ];
}

Caching

OGX includes built-in caching. Images with the same config will be cached:

return ogxResponse({
  preset: "blog",
  title: "My Post",
  cache: true, // Enable caching (default)
});

License

MIT