Install and configure the SDK
Add og-pilot-js and configure API key + domain in server env variables.
Generate route-specific Open Graph images in Next.js and inject them into metadata from the server.
Add og-pilot-js and configure API key + domain in server env variables.
Build a reusable helper that signs payloads and returns OG image URLs.
Call the helper in generateMetadata so each URL gets its own preview image.
Deploy and validate with Open Graph debugger tools to refresh social caches.
// lib/og-image.ts
import { configure, createImage } from "og-pilot-js"
configure((config) => {
config.apiKey = process.env.OG_PILOT_API_KEY
config.domain = process.env.OG_PILOT_DOMAIN
})
export async function buildOgImage(post: {
title: string
description: string
path: string
imageUrl?: string
}) {
return createImage(
{
template: "blog_post",
title: post.title,
description: post.description,
image_url: post.imageUrl,
path: post.path,
},
{ iat: Math.floor(Date.now() / 1000) },
)
}
// app/blog/[slug]/page.tsx
export async function generateMetadata({ params }) {
const post = await getPost(params.slug)
const ogImage = await buildOgImage({
title: post.title,
description: post.excerpt,
path: "/blog/" + post.slug,
})
return {
openGraph: { images: [ogImage] },
twitter: { card: "summary_large_image", images: [ogImage] },
}
}No. Keep JWT signing and OG Pilot calls on the server only.
Yes. Pass per-post title, description, and path values when generating the image URL.
OG Pilot turns page metadata into consistent, high-quality social previews without manual design exports.