A sitemap.js, robots.js or opengraph-image.jsx in app/ becomes a route handler at a fixed URL (/sitemap.xml, /robots.txt, /opengraph-image), and the build applies the usual static-or-dynamic rule to it. On Next.js 16.4.5 (Turbopack; --webpack matched):
- Prerendered (
○): the root image,sitemap.xml,robots.txt, and an image whose plainfetchran once, at build. Repeat requests returned the same bytes withx-nextjs-cache: HIT. - Per request (
ƒ): an image readingcookies(), one with ano-storefetch, one withdynamic = 'force-dynamic', andblog/[slug]/opengraph-imagewith nogenerateStaticParams. Each request produced new bytes. A query string changes nothing: the image function receives onlyparams.
The headers surprise people. Every metadata route, static or dynamic, sent Cache-Control: public, max-age=0, must-revalidate (the loader hard-codes it), with image/png, application/xml or text/plain. A CDN may store the file but must revalidate it every time.
For images, Next.js also writes the tags into the page: og:image with ?<hash>, plus type, width, height and og:image:alt from the size, contentType and alt exports. The same image filled twitter:image, since there was no twitter-image file. The hash is the image file's content hash: editing that file changed it, but editing a component it imports, or rebuilding with new data, didn't.
Multiple outputs come from generateImageMetadata (ids small and 2 gave /gim/opengraph-image/small and /2, two sets of og:image tags) and generateSitemaps (/products/sitemap/0.xml; /products/sitemap.xml was a 404). Since 16, id arrives as a promise, and it resolved to a string even when the id was the number 2.
ImageResponse renders with Satori, which supports flexbox and a subset of CSS. The docs also cap the bundle at 500 KB and allow only ttf, otf and woff fonts (not tested here).