Loading...
Loading...
Guides creation of OpenGraph and Twitter share images using next/og ImageResponse. Covers layout patterns, custom fonts, avatars, title case, and Satori rules. Use when building OG images, Twitter cards, or social previews.
npx skill4agent add richtabor/agent-skills og-imagesnext/ogapp/opengraph-image.tsxruntimealtsizecontentTypeImageapp/api/og/route.tsxslugtitlegenerateMetadata()export const runtime = "edge"| File | Purpose | Dimensions |
|---|---|---|
| Facebook, LinkedIn, iMessage | 1200x630 |
| Twitter/X cards | 1200x600 |
| Dynamic API route | 1200x630 |
app/about/opengraph-image.tsx/aboutflexDirection: "column"justifyContent: "space-between"#888textWrap: "balance"maxWidthletterSpacing: "-0.02em"48pxjustifyContent: "flex-end"fetcharrayBuffersrcborderRadius: "50%"Map.ttfpublic/fonts/new URL("../../../public/fonts/YourFont.ttf", import.meta.url)ArrayBufferImageResponsefontsweightgenerateMetadata()export function generateMetadata({ params }) {
return {
openGraph: {
images: [`/api/og?slug=${params.slug}`],
},
};
}/api/og?title=Aboutnext/ogdisplay: "flex"rgb()hsl()gap| Issue | Solution |
|---|---|
| Text not rendering | Add |
| Layout broken | Ensure all containers have |
| Colors wrong | Use hex colors, not CSS variables |
| Font not loading | Check the relative path from route file to |
| Image not showing | Convert to base64 data URI, don't use relative paths |
http://localhost:3000/api/og?title=Hello+Worldf