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
A React element (JSX) describing the image layout. Only a subset of CSS and HTML is supported.
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
Version history
| Version | Changes |
|---|---|
v14.0.0 | ImageResponse moved from next/server to next/og. |
v13.3.0 | ImageResponse importable from next/server. |
v13.0.0 | ImageResponse introduced via @vercel/og. |
