Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

The favicon does not show up in a Next.js app

ErrorNo favicon in the browser tab

Short answer

In the App Router, Next.js only picks up a favicon named favicon.ico placed at the top level of the app folder. A favicon in a sub folder, a .png named favicon, or a generated favicon is ignored. Put favicon.ico in app/, or use an icon file for png and svg.

  • Applies to Next.js 15, Next.js 16
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check which icon file exists and where it is. The convention is strict about both name and location.

    find app public -iname "favicon*" -o -iname "icon*" -o -iname "apple-icon*"
  2. 2Match what you see, then jump to its fix

    1. 1The file sits in app/(group)/, app/some-route/ or src/ outside appfavicon.ico is not in the root of the app folderFix
    2. 2A file called favicon.png or favicon.svg exists and no icon link is addedThe file type does not match the conventionFix
    3. 3app/favicon.tsx or favicon.js exists and the icon is missingYou tried to generate a favicon with codeFix
    4. 4/favicon.ico does not return an image while a proxy.ts or middleware.ts file existsProxy (middleware) intercepts the icon requestFix

What does the error look like?

  • No favicon in the browser tab
  • Next.js app icon not recognised
  • GET /favicon.ico 404

Cause 1 of 4

favicon.ico is not in the root of the app folder

1Check

A favicon file is only recognised at the top level of app/. Other folders are not scanned for it.

ls app/favicon.ico

2Fix

Move the file to app/favicon.ico. If you need a different icon for one route, use an icon file in that route instead.

mv path/to/favicon.ico app/favicon.ico

3Verify

Start the dev server and request the icon, then look for the link tag in the page head.

curl -I http://localhost:3000/favicon.ico
curl -s http://localhost:3000 | grep -o '<link rel="icon"[^>]*>'

Confirmed by nextjs.org

Did this fix it?

Cause 2 of 4

The file type does not match the convention

1Check

The favicon convention accepts only .ico. Other formats work under the icon name: icon.ico, icon.jpg, icon.jpeg, icon.png or icon.svg. The apple-icon name accepts .jpg, .jpeg and .png.

ls app | grep -i -E "favicon|icon"

2Fix

Rename a png or svg to icon.png or icon.svg, or convert the image to favicon.ico.

mv app/favicon.png app/icon.png

3Verify

Reload and check that a link tag with rel icon appears in the head.

curl -s http://localhost:3000 | grep -o '<link rel="icon"[^>]*>'

Confirmed by nextjs.org

Did this fix it?

Cause 3 of 4

You tried to generate a favicon with code

1Check

Code generated icons are supported only for icon and apple-icon, not for favicon.

ls app | grep -i favicon

2Fix

Rename the generated file to icon.tsx (it must default export a function that returns an image, for example with ImageResponse), or ship a plain favicon.ico.

// app/icon.tsx
import { ImageResponse } from 'next/og'

export const size = { width: 32, height: 32 }
export const contentType = 'image/png'

export default function Icon() {
  return new ImageResponse(<div style={{ fontSize: 24 }}>A</div>, { ...size })
}

3Verify

Open /icon in the browser; it should return a png.

curl -I http://localhost:3000/icon

Confirmed by nextjs.org

Did this fix it?

Cause 4 of 4

Proxy (middleware) intercepts the icon request

1Check

Metadata files such as the icon are served by Next.js, and a proxy matcher that covers every path also covers them. The docs say to exclude metadata files in the matcher.

curl -I http://localhost:3000/favicon.ico
grep -n "matcher" proxy.ts middleware.ts

2Fix

Exclude the icon files from the matcher.

export const config = {
  matcher: ['/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)'],
}

3Verify

Request the icon again; it should answer 200 with an image type.

curl -I http://localhost:3000/favicon.ico

Confirmed by nextjs.org

Did this fix it?

How do I stop it coming back?

  • Keep icon files together at the top of app/ and name them exactly favicon, icon or apple-icon.
  • After a change, check the link tags in the page source rather than trusting the tab.
  • Use favicon.ico for the classic file and icon.svg or icon.png for everything else.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.