How to Add a Favicon in Next.js App Router
In the App Router you do not need a plugin or a package. Drop one image into the right place and Next.js generates the link tags for you. Here is the complete setup, including the sizes that actually matter and the caching trap that makes people think their favicon is broken.
The shortest answer: one file in app/
Put a square image named icon.png (or icon.svg) directly inside your app/ directory. Next.js detects it at build time, serves it from a generated route and injects the correct <link rel="icon"> tag into every page's head. Nothing else is required.
A 512×512 PNG is a safe starting point. Next.js will use it for the browser tab and downscale as needed. If you also need an ICO for older browsers, add app/favicon.ico alongside it.
app/
layout.tsx
page.tsx
icon.png <- browser tab icon
apple-icon.png <- iOS home screen
favicon.ico <- legacy / bookmarks
Which filename does what
The App Router uses file-based metadata conventions. The name decides where the icon is used:
| File in app/ | What it controls |
|---|---|
| icon.svg / icon.png | Browser tab, bookmarks, most desktop browsers |
| favicon.ico | Legacy browsers and older bookmark imports |
| apple-icon.png | iOS home screen shortcut (needs 180×180) |
| manifest.webmanifest | PWA name, theme colour and install icons |
| opengraph-image.png | Social share preview (not a favicon) |
Using the metadata API instead
If your icons live in public/ or you need per-route icons, declare them in layout.tsx. This is also the right place when an icon is generated at build time.
// app/layout.tsx
import type { Metadata } from 'next'
export const metadata: Metadata = {
icons: {
icon: '/favicon.ico',
shortcut: '/favicon-32.png',
apple: '/apple-touch-icon.png',
},
manifest: '/site.webmanifest',
}
export default function RootLayout({ children }) {
return <html lang="en"><body>{children}</body></html>
}
Generate every size from one image
Doing this by hand means exporting 16×16, 32×32, 180×180, 192×192 and 512×512, plus a multi-size ICO. The myfavicon generator takes one square image and produces the whole set in the browser — the files are processed locally and nothing is uploaded.
See the favicon size guide for what each dimension is for, and ICO vs PNG when deciding which format to ship.
Why the icon does not update
This is almost always caching, not a broken file. Browsers hold favicons aggressively, and a CDN may serve an old copy for hours. Work through these in order:
Also check that the file really is square and at least 512×512. Fine detail disappears at 16×16 — a bold single shape or letter survives, thin text does not.
Checklist before you ship
FAQ
Not for modern browsers. icon.png or icon.svg is enough. Keep favicon.ico only if you care about legacy browsers or old bookmark imports.
Yes. Put icon.svg in app/ and Next.js will reference it. SVG is ideal for simple marks and supports dark mode through prefers-color-scheme, but Safari still relies on apple-icon.png for home screen icons.
iOS home screen shortcuts use apple-icon.png, not the standard icon. Add a 180×180 PNG with no transparency and a solid background.
Yes. Export metadata from a page or layout deeper in the tree to override the icons for that route segment.