npx claudepluginhub richtabor/agent-skills --plugin rtThis skill uses the workspace's default tool permissions.
Generate dynamic OpenGraph (1200x630) and Twitter (1200x600) images using `next/og` ImageResponse.
Generate dynamic OG images for social previews in Next.js using file conventions and next/og library. Server-renders JSX cached at build time.
Generates Open Graph social media preview images by analyzing the project's design system, creating a 1200x630 screenshot-optimized page, capturing with Playwright, and configuring meta tags.
Guides implementation of Open Graph meta tags for social media previews on Facebook, LinkedIn, Slack, and Discord. Includes essential tags, best practices, Next.js App Router examples, and common pitfalls.
Share bugs, ideas, or general feedback.
Generate dynamic OpenGraph (1200x630) and Twitter (1200x600) images using next/og ImageResponse.
app/opengraph-image.tsx): Best for static pages with known titles at build time. Export runtime, alt, size, contentType, and a default Image function.app/api/og/route.tsx): Best for dynamic content (blog posts, CMS). Accept slug and/or title as query params. Reference in metadata via generateMetadata().Use export const runtime = "edge" for both approaches.
| File | Purpose | Dimensions |
|---|---|---|
opengraph-image.tsx | Facebook, LinkedIn, iMessage | 1200x630 |
twitter-image.tsx | Twitter/X cards | 1200x600 |
app/api/og/route.tsx | Dynamic API route | 1200x630 |
Place file-based routes in the relevant route directory (e.g., app/about/opengraph-image.tsx for /about).
flexDirection: "column" with justifyContent: "space-between" to separate content from branding#888)textWrap: "balance" and constrain width with maxWidthletterSpacing: "-0.02em" for tight, editorial feel at large sizes48px on all sides works well at 1200x630If the project has an avatar or logo, place it in the bottom-right corner using a flex container with justifyContent: "flex-end". Load images via fetch + arrayBuffer, convert to base64 data URI for the src. Use borderRadius: "50%" for circular avatars. Cache loaded assets in a Map to avoid refetching.
Load .ttf files from public/fonts/ using new URL("../../../public/fonts/YourFont.ttf", import.meta.url). Pass the ArrayBuffer to ImageResponse via the fonts option. Cache the font buffer after first load. Match the weight in the fonts config to the actual font file weight.
If titles come from a CMS, apply smart title case:
Reference the OG route in generateMetadata():
export function generateMetadata({ params }) {
return {
openGraph: {
images: [`/api/og?slug=${params.slug}`],
},
};
}
For static pages, pass the title directly: /api/og?title=About.
These are hard requirements of the next/og rendering engine (Satori):
display: "flex" — this is the only layout modergb(), hsl(), or CSS variablesgap on older versions — test before relying on it; fallback to margin| Issue | Solution |
|---|---|
| Text not rendering | Add display: "flex" to the text wrapper |
| Layout broken | Ensure all containers have display: "flex" |
| Colors wrong | Use hex colors, not CSS variables |
| Font not loading | Check the relative path from route file to public/fonts/ |
| Image not showing | Convert to base64 data URI, don't use relative paths |
Preview during development by visiting the route directly in the browser:
http://localhost:3000/api/og?title=Hello+World
After building, verify routes register as dynamic (f prefix) in the build output.