The favicon does not show up in a Next.js app
No favicon in the browser tabShort 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.
Fix it fast
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*"2Match what you see, then jump to its fix
- 1
The file sits in app/(group)/, app/some-route/ or src/ outside appfavicon.ico is not in the root of the app folderFix - 2
A file called favicon.png or favicon.svg exists and no icon link is addedThe file type does not match the conventionFix - 3
app/favicon.tsx or favicon.js exists and the icon is missingYou tried to generate a favicon with codeFix - 4
/favicon.ico does not return an image while a proxy.ts or middleware.ts file existsProxy (middleware) intercepts the icon requestFix
- 1
What does the error look like?
No favicon in the browser tabNext.js app icon not recognisedGET /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.ico2Fix
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.ico3Verify
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
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.png3Verify
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
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 favicon2Fix
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/iconConfirmed by nextjs.org
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.ts2Fix
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.icoConfirmed by nextjs.org
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
Web apps
AuthUserPoolException: Auth UserPool not configured in a Next.js app
Auth UserPool not configured
The error means an Amplify Auth call ran before Amplify.configure did.
3 causes, each with a fixWeb apps
Apollo Server rejects a request as a potential CSRF
HTTP 400 Bad Request from the GraphQL endpoint
Apollo Server's CSRF prevention is on by default.
3 causes, each with a fixWeb apps
Clerk cannot read its publishable key in a Next.js app
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY is undefined
Clerk reads NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY.
3 causes, each with a fixWeb apps
The shell cannot find create-next-app
command not found: create-next-app
create-next-app is not meant to be installed as a shell command.
2 causes, each with a fixWeb apps
ESLint fails with: Cannot find module 'next/babel'
ESLint stops on the first file with a Babel or parser error instead of listing lint results
next/babel is a Babel preset that ships inside the next package.
3 causes, each with a fixWeb apps
ESLint says an element in a list is missing its key prop
react/jsx-key
react/jsx-key fires when an element returned from map, Array.from or an array literal has no key.
3 causes, each with a fix