ImageResponse lets you generate dynamic images using JSX and CSS. This is useful for social media images such as Open Graph images and Twitter cards.
Parameters
ReactElement
required
A React element (JSX) describing the image layout. Only a subset of CSS and HTML is supported.
ImageResponseOptions
Optional configuration:
Supported CSS
ImageResponse supports common CSS including:
- Flexbox layout (
display: flex) - Absolute positioning
- Custom fonts
- Text wrapping and centering
- Nested images
Behavior
- Uses @vercel/og, Satori, and Resvg to convert JSX/CSS into PNG.
- Maximum bundle size is 500KB (includes JSX, CSS, fonts, images, and other assets).
- Supported font formats:
ttf,otf,woff. Preferttforotffor faster parsing.
Examples
In a Route Handler
app/api/og/route.tsx
With opengraph-image.tsx
app/opengraph-image.tsx
With custom fonts
app/opengraph-image.tsx
