How to add a favicon to Nuxt
A favicon in Nuxt is a handful of files in public/ and some link tags in app.head. This works the same in Nuxt 3 and Nuxt 4. The only difference: Nuxt 4 usually keeps the app in an app/ folder (app/app.vue), where Nuxt 3 has app.vue at the project root.
Published by FavForge, which is itself a Nuxt app on Netlify set up exactly this way.
The short version
- 1Put the files in public/Unzip the favicon pack into the public/ folder at your project root, so the files are served from the site root.
- 2Declare them in app.headAdd the link tags to app.head in nuxt.config.ts, so every page gets the favicon, Apple touch icon and manifest.
- 3Deploy and checkDeploy, then hard-refresh. If an old icon sticks, add ?v=2 to the hrefs to bust the browser cache.
1. What to put in public/
Files in the project-root public/ folder are served at the site root exactly as they are, with no hashing by the build (Nuxt docs). That is why favicon.ico belongs here and not in assets/, whose files get renamed. Both Nuxt 3 and Nuxt 4 use the root-level public/, even when your app lives in app/.
If you made your icon in FavForge, unzip the favicon pack into public/:
public/
├── favicon.ico
├── favicon-16x16.png
├── favicon-32x32.png
├── apple-touch-icon.png
├── android-chrome-192x192.png
├── android-chrome-512x512.png
├── maskable-icon-512x512.png
├── site.webmanifest
└── favicon.svg ← only if you downloaded the SVG separately The pack has no SVG. If you also downloaded the SVG favicon, rename it favicon.svg and add it yourself. The pack’s site.webmanifest lists the 192, 512 and maskable 512 icons but has no start_url or id: add them if you rely on it for installing your app, or let @vite-pwa/nuxt own the manifest instead. Don’t ship two competing manifests.
2. Site-wide tags with app.head
For tags that never change, the favicon included, Nuxt’s SEO and meta docs use app.head in nuxt.config.ts. It isn’t reactive, which is fine for a favicon. Declare the whole set, not just /favicon.ico:
export default defineNuxtConfig({
app: {
head: {
link: [
{ rel: 'icon', type: 'image/svg+xml', href: '/favicon.svg' }, // omit if you have no SVG
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico', sizes: '48x48' },
{ rel: 'icon', type: 'image/png', sizes: '32x32', href: '/favicon-32x32.png' },
{ rel: 'icon', type: 'image/png', sizes: '16x16', href: '/favicon-16x16.png' },
{ rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon.png' },
{ rel: 'manifest', href: '/site.webmanifest' },
],
},
},
})Drop the SVG line if you have no favicon.svg.
One catch: a literal href: '/favicon.ico' isn’t rewritten when you set app.cdnURL. If you serve public/ from a CDN, build the hrefs at runtime instead.
3. useHead, for reactive tags or a CDN
useHead takes the same link array, but runs in your app, so the hrefs can be computed, here from cdnURL or baseURL, as the Nuxt docs show:
<script setup lang="ts">
// app/app.vue in a Nuxt 4 layout, app.vue at the root in Nuxt 3
const { app } = useRuntimeConfig()
const base = (app.cdnURL || app.baseURL).replace(/\/$/, '')
useHead({
link: [
{ rel: 'icon', type: 'image/x-icon', href: `${base}/favicon.ico`, sizes: '48x48' },
{ rel: 'icon', type: 'image/png', sizes: '32x32', href: `${base}/favicon-32x32.png` },
{ rel: 'icon', type: 'image/png', sizes: '16x16', href: `${base}/favicon-16x16.png` },
{ rel: 'apple-touch-icon', sizes: '180x180', href: `${base}/apple-touch-icon.png` },
{ rel: 'manifest', href: `${base}/site.webmanifest` },
],
})
</script> Favicons are <link> tags, so useHead is the right API. useSeoMeta is for meta tags such as the description and Open Graph.
4. Cache-busting
Files in public/ keep their names, and browsers cache favicons hard, /favicon.ico especially. To force a refresh after replacing a file, add a version to the link hrefs:
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico?v=2', sizes: '48x48' },
{ rel: 'icon', type: 'image/png', sizes: '32x32', href: '/favicon-32x32.png?v=2' }, That doesn’t change the bare request for /favicon.ico that the HTML Standard lets browsers make when a page has no icon link. For PNG and SVG files you can also rename the file. Even then, a hard refresh or a little patience may be needed after a deploy: favicon updates are rarely instant.
5. @nuxt/icon is not a favicon
@nuxt/icon renders icon components inside your pages. It doesn’t create /favicon.ico or an Apple touch icon, and an <Icon> component can’t go in app.head. Your favicon still needs real image files in public/.
6. If your app is a PWA: @vite-pwa/nuxt
For an installable app, @vite-pwa/nuxt is the official Vite-based module. It is documented for Nuxt 3, and it only works with Vite. Add it, then give it a pwa block. Its minimal requirements are a name, a theme colour and 192 and 512px icons; include the maskable 512 too.
// npx nuxi@latest module add @vite-pwa/nuxt
export default defineNuxtConfig({
modules: ['@vite-pwa/nuxt'],
pwa: {
includeAssets: ['favicon.ico', 'apple-touch-icon.png'],
manifest: {
name: 'My App',
short_name: 'My App',
theme_color: '#2563eb',
icons: [
{ src: 'android-chrome-192x192.png', sizes: '192x192', type: 'image/png' },
{ src: 'android-chrome-512x512.png', sizes: '512x512', type: 'image/png' },
{ src: 'maskable-icon-512x512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' },
],
},
},
})- List
favicon.icoandapple-touch-icon.pnginincludeAssetsso the service worker serves them. - Let the module register the manifest (its
<NuxtPwaManifest />component, orregisterWebManifestInRouteRuleson Netlify) and remove the pack’ssite.webmanifestlink, so there’s only one. - The module doesn’t replace your tab favicons: keep the icon links in
app.head. - A stale service worker can keep serving an old icon after you replace it. Check this before blaming the browser cache.
Make the files
The FavForge generator makes the whole pack from any of its icons. For the details of each file, see favicon sizes, favicon.ico, the Apple touch icon and PWA and maskable icons.