Static branding
A fixed brand mark is already available as an image asset.
Next.js 16+ · Directive
Use an icon file in an App Router route segment to provide an application icon. Choose a static supported image or generate the icon with JavaScript, TypeScript, or TSX.
The App Router recognizes icon as a metadata file convention. Add a supported static image such as icon.png or use icon.js, icon.ts, or icon.tsx to generate one; Next.js then serves it and updates the relevant document metadata automatically.
app/icon.(ico|jpg|jpeg|png|svg)
app/icon.(js|ts|tsx)The icon file is served as an application icon and its corresponding metadata is added automatically.
icon convention to define an application icon in an App Router route segment.// app/icon.tsx
import { ImageResponse } from 'next/og'
export default function Icon() {
return new ImageResponse(
<div style={{ fontSize: 64, background: 'white', width: '100%', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
A
</div>,
)
}Place this dynamic icon file in the app directory; Next.js uses its generated image as the application icon.
A fixed brand mark is already available as an image asset.
The icon must reflect runtime or computed content.
Different sections of an application need distinct icons.
Add a supported static file such as icon.png to an app route segment, or create icon.js, icon.ts, or icon.tsx to generate the image. The file convention causes Next.js to serve the icon and add the corresponding metadata.
Follow-up: How would you scope an icon to a route? Place the icon file in that route segment; nested segments can define their own icons.
icon convention use?The convention supports .ico, .jpg, .jpeg, .png, and .svg image files. A generated icon can use JavaScript, TypeScript, or TSX, and generated output must be an image response.
Follow-up: When should code generation be preferred? Use it when the icon needs dynamic content or rendering rather than a fixed asset.
Next.js automatically serves the file and updates the relevant head metadata, including the asset URL and image information. This avoids manually maintaining icon link tags.
Follow-up: What happens in production? File-based metadata is served with hashes for caching.
apple-iconfaviconImageResponseMetadata Files