Skip to main content
Faviqo

Favicon for Next.js

How to add a favicon in Next.js

In the App Router, Next.js reads icons from the metadata export or from special files in app/. Generate a complete kit below, drop it in public/ and paste the metadata. It works for the Pages Router too.

Generate my Next.js icon kit →Free · no upload · one ZIP

Add the favicon in Next.js

Upload files to
public/
Add code to
app/layout.tsx
  1. Unzip the package into the public/ folder.
  2. Delete app/favicon.ico if it exists — it overrides the icons below.
  3. Add the metadata and viewport exports to app/layout.tsx (merge with any you already have).

app/layout.tsx

import type { Metadata, Viewport } from "next";

export const metadata: Metadata = {
  icons: {
    icon: [
      { url: "/favicon.ico", sizes: "32x32" },
      { url: "/favicon.svg", type: "image/svg+xml" },
      { url: "/favicon-48x48.png", type: "image/png", sizes: "48x48" },
    ],
    apple: { url: "/apple-touch-icon-180x180.png", sizes: "180x180" },
  },
  manifest: "/site.webmanifest",
};

export const viewport: Viewport = {
  themeColor: "#FFFFFF",
};

The file names match what the generator produces. Your theme colour and name are filled in when you generate your own kit.

Pages Router? Paste the HTML snippet inside <Head> in pages/_document.tsx instead.

Metadata API and file conventions

The App Router gives you two ways to declare icons and they do not mix well. The first is file conventions: put favicon.ico, icon.png or icon.svg and apple-icon.png in the app/ folder and Next.js writes the tags for you at build time, adding a content hash. The second is the metadata export in layout.tsx, where you list files from public/ yourself.

Choose one. If an app/favicon.ico exists it takes precedence, and create-next-app puts one there by default, so the usual reason a new icon does not appear is that the old file is still in place. The metadata export is the better fit when you want a complete kit, since the generated names such as favicon-32x32.png and apple-touch-icon-180x180.png come from public/ and keep a stable URL.

Icons are inherited down the route tree. A layout or page that exports its own metadata.icons replaces the parent's rather than adding to it, so a nested layout with its own icons list quietly drops the rest. Set them once, in the root layout.

app/layout.tsx

export const metadata = {
  icons: {
    icon: [
      { url: "/favicon.svg", type: "image/svg+xml" },
      { url: "/favicon-32x32.png", sizes: "32x32", type: "image/png" },
    ],
    apple: "/apple-touch-icon-180x180.png",
  },
  manifest: "/site.webmanifest",
};

Files go in public/. Delete app/favicon.ico first, or it overrides this list. On the Pages Router, put the equivalent <link> tags inside <Head>.

Check it worked

  1. Run a production build and start it. The dev server caches icons and can mislead you.
  2. View the page source and confirm each icon appears once, with the path you expect.
  3. Open the icon URLs directly (for example /favicon-32x32.png). A 404 means the file is not in public/.

Why your Next.js favicon may not show

  • An app/favicon.ico (or app/icon.png) overrides the metadata icons. Delete the default one that create-next-app adds, or your new icon will not appear.
  • Files in app/ named icon.svg or apple-icon.png are wired up automatically. Don't also list them in metadata, or you get duplicate tags.
  • Metadata is merged per route segment. If a nested layout sets its own icons it replaces the root's.
  • The dev server caches icons hard. Restart it and clear the tab's cache before you decide it is broken.

Already published? Run your site through the favicon checker to see exactly what is wrong, or see every favicon size for what each file is for.

Next.js favicon FAQ

How do I add a favicon in Next.js 13+ App Router?

Either drop favicon.ico in the app/ folder, or put the files in public/ and list them in the metadata export of app/layout.tsx under icons.

Why is my Next.js favicon not showing?

Most often a leftover app/favicon.ico overrides your metadata, or the browser cached the old one. Delete the old file, restart the dev server and hard-refresh.

How do I add a favicon in the Pages Router?

Put the files in public/ and add the link tags inside <Head> in pages/_document.tsx or _app.tsx.

Skip the resizing.

Drop in one logo and get every size, the manifest and the HTML for Next.js.

Open the favicon generator →