Generate dynamic Open Graph images for every page in your Next.js app using ShotLayer's API. No Satori, no build-time rendering -- just one API call per page.
Store your ShotLayer API key as an environment variable. Create or edit your .env.local file in the project root:
Get a free API key instantly at shotlayer.dev -- no credit card required.
Create a dynamic API route that generates OG images on demand using ShotLayer. This route receives a blog post slug and returns a PNG image.
app/api/og/[slug]/route.tsUse Next.js generateMetadata to add the OG image to every blog post page automatically.
That's it. Deploy to Vercel as usual. OG images are generated on the first request and cached for 24 hours via the Cache-Control header. No build step, no static generation -- every new post gets a unique OG image automatically.
When a social platform (Twitter, Slack, Discord) crawls your page, it finds the /api/og/[slug] URL in the meta tags. That route calls ShotLayer, which renders and returns a PNG. Subsequent requests are served from cache.
Get a free API key and start generating images in minutes.
Get API Key Free →