myfavicon

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.pngBrowser tab, bookmarks, most desktop browsers
favicon.icoLegacy browsers and older bookmark imports
apple-icon.pngiOS home screen shortcut (needs 180×180)
manifest.webmanifestPWA name, theme colour and install icons
opengraph-image.pngSocial 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.

  • Hard-refresh with Ctrl+F5 / Cmd+Shift+R, or open the page in a private window.
  • Request /icon.png directly and confirm it returns 200 and the new image.
  • Rename the file or add a query string so the URL itself changes.
  • Purge the CDN cache, then re-deploy.
  • Check DevTools > Elements > head: exactly one rel=icon should be present.
  • Checklist before you ship

  • A square source image of at least 512×512 px.
  • app/icon.png or an explicit metadata.icons entry — not both conflicting.
  • apple-icon.png at 180×180 if mobile home-screen installs matter.
  • site.webmanifest with 192×192 and 512×512 entries for PWA installs.
  • A hard refresh after deploying, before reporting it as broken.
  • FAQ

    Do I still need favicon.ico in Next.js?

    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.

    Can I use an SVG favicon in the App Router?

    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.

    Why does my favicon show in Chrome but not on iOS?

    iOS home screen shortcuts use apple-icon.png, not the standard icon. Add a 180×180 PNG with no transparency and a solid background.

    Does the App Router support per-page favicons?

    Yes. Export metadata from a page or layout deeper in the tree to override the icons for that route segment.

    Make my favicon — free

    Related guides