ImageResponse
A Next.js class from next/og that turns JSX and a subset of CSS into a PNG image response.
In more detail
It uses Satori to lay out the JSX as SVG and Resvg to convert that to PNG. Only flexbox layout and a subset of CSS work, and it runs in both the Node.js and Edge runtimes.
Example
return new ImageResponse(<div style={{ display: 'flex', fontSize: 64 }}>{title}</div>, { width: 1200, height: 630 });Related terms
- Satori — An open-source Vercel library that converts HTML and CSS written as JSX into an SVG image.
- Resvg — An open-source library that renders SVG images into bitmap images such as PNG.
- opengraph-image.tsx — A special file in a route folder that generates or provides the route's Open Graph image, with Next.js adding the meta tags automatically.
- PNG — Portable Network Graphics: a lossless image format that supports transparency.
Taught in
- Metadata API: Dynamic OpenGraph & Head Management — Next.js 15 & Modern App Router Architecture