Skip to main content
Important: Add OGify packages to serverExternalPackages in your next.config.js:
This prevents Next.js from bundling OGify packages, which is necessary for proper font loading and image generation.
For Next.js projects using the Pages Router, generate OG images using API Routes.

Using API Routes

1

Create the API Route

Create a file at pages/api/og.ts:
2

Use in Pages

In your pages, point the og:image meta tag to your API route.