home / skills / andrelandgraf / fullstackrecipes / og-image-generation
This skill generates dynamic social preview images for Next.js apps using file conventions and next/og, with server-side rendering and build-time caching.
npx playbooks add skill andrelandgraf/fullstackrecipes --skill og-image-generationReview the files below or copy the command above to add this skill to your agents.
---
name: og-image-generation
description: Generate dynamic social preview images using Next.js file conventions and the next/og library. Server-rendered JSX images cached at build time.
---
# OG Image Generation
Generate dynamic social preview images using Next.js file conventions and the next/og library. Server-rendered JSX images cached at build time.
```bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/og-image-generation
```
This skill generates dynamic social preview (OG) images for Next.js apps using Next.js file conventions and the next/og library. It produces server-rendered JSX images that can be cached at build time for fast, consistent social previews. The approach is production-ready and integrates with existing Next.js routes and build pipelines.
You define image JSX components that follow Next.js routing and file conventions, then use the next/og library to render those components server-side into image bytes. Images are generated on the server and can be cached at build time so the same URL returns a pre-rendered image for social cards and link previews. The skill focuses on repeatable patterns and recipes to integrate this into a full-stack app reliably.
Can images be generated at build time only?
Yes. If your image components are deterministic and use build-available assets, they can be rendered and cached at build time so the same URL returns the pre-rendered image.
Do I need client-side code to render OG images?
No. The next/og approach renders images server-side using JSX, so no client-side rendering is required for the image itself.