How to Add Favicons to Your Nuxt 3 Project: Complete Implementation Guide
Favicons are essential for professional web applications—they appear in browser tabs, bookmarks, and mobile home screens, reinforcing your brand identity. While adding a basic favicon to Nuxt 3 is straightforward, implementing a comprehensive favicon system that works across all devices and scenarios requires more planning.
This guide covers everything from basic implementation to advanced features like dynamic favicon switching and PWA optimization. Whether you're building a simple website or a complex application, you'll find the right approach for your Nuxt 3 project.
Quick Start: Basic Favicon Setup
For those who want to get started immediately, here's the minimal setup:
- Add
favicon.icoto yourpublic/directory - Add one line to
nuxt.config.ts:export default defineNuxtConfig({ app: { head: { link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }] } } })
That's it! Your favicon will now appear in browser tabs. For production applications, continue reading for comprehensive multi-device support.
Step 1: Prepare Professional Favicon Assets
Modern web applications need multiple favicon formats and sizes to provide optimal experience across all devices and platforms.
Essential Favicon Sizes (Priority Order)
| Size | Format | Purpose | Priority |
|---|---|---|---|
| favicon.ico | ICO | Browser tabs, bookmarks | 🔥 Critical |
| 32x32 | PNG | High-res browser tabs | 🔥 Critical |
| 180x180 | PNG | iOS home screen | ⭐ Important |
| 192x192 | PNG | Android home screen | ⭐ Important |
| 512x512 | PNG | PWA app icons | ⭐ Important |
| 16x16 | PNG | Small browser displays | ✅ Nice to have |
Quick Favicon Generation
Recommended Tools:
- RealFaviconGenerator - Most comprehensive
- Favicon.io - Simple and fast
- Favicon.im - For testing existing favicons
Input Requirements: Upload a square image (minimum 260x260px, ideally 512x512px) in PNG format.
Step 2: Organize Files in the Public Directory
In Nuxt 3, static assets are placed in the public directory. Here's the recommended file structure:
your-nuxt3-project/
├── public/
│ ├── favicon.ico
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ ├── apple-touch-icon.png
│ ├── android-chrome-192x192.png
│ ├── android-chrome-512x512.png
│ └── site.webmanifest
├── nuxt.config.ts
└── ...
Step 3: Configure Nuxt.config.ts
Nuxt 3 uses the app.head configuration to manage HTML head elements, including favicons.
export default defineNuxtConfig({
app: {
head: {
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
}
}
})
Step 4: Complete Multi-Device Configuration
For comprehensive device support, use this advanced configuration:
export default defineNuxtConfig({
app: {
head: {
link: [
// Basic favicon
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
// Standard sizes
{ rel: 'icon', type: 'image/png', sizes: '16x16', href: '/favicon-16x16.png' },
{ rel: 'icon', type: 'image/png', sizes: '32x32', href: '/favicon-32x32.png' },
// Apple devices
{ rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon.png' },
// Android devices
{ rel: 'icon', type: 'image/png', sizes: '192x192', href: '/android-chrome-192x192.png' },
{ rel: 'icon', type: 'image/png', sizes: '512x512', href: '/android-chrome-512x512.png' },
// Web App Manifest
{ rel: 'manifest', href: '/site.webmanifest' }
],
meta: [
// Theme colors for mobile browsers
{ name: 'theme-color', content: '#000000' },
{ name: 'msapplication-TileColor', content: '#000000' }
]
}
}
})
Step 5: Web App Manifest Configuration
Create a site.webmanifest file in your public directory for PWA support:
{
"name": "Your App Name",
"short_name": "AppName",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#000000",
"background_color": "#ffffff",
"display": "standalone"
}
Advanced: Dynamic Favicons with useHead
Nuxt 3's useHead composable allows you to dynamically change favicons based on application state—perfect for theme switching, notifications, or user preferences.
<template>
<div>
<button @click="toggleTheme">Toggle Theme</button>
</div>
</template>
<script setup>
const isDark = ref(false)
const toggleTheme = () => {
isDark.value = !isDark.value
updateFavicon()
}
const updateFavicon = () => {
useHead({
link: [
{
rel: 'icon',
type: 'image/png',
href: isDark.value ? '/favicon-dark.png' : '/favicon-light.png'
}
]
})
}
// Set initial favicon
onMounted(() => {
updateFavicon()
})
</script>
Step 7: Nuxt Module for Automated Favicon Management
For advanced projects, consider using a Nuxt module like @nuxtjs/pwa that handles favicons automatically:
npm install @nuxtjs/pwa
export default defineNuxtConfig({
modules: ['@nuxtjs/pwa'],
pwa: {
icon: {
source: 'static/icon.png', // Your source icon
fileName: 'icon.png'
},
manifest: {
name: 'My Nuxt App',
short_name: 'NuxtApp',
theme_color: '#000000'
}
}
})
Step 8: Server-Side Favicon Optimization
For better performance, consider optimizing favicon delivery in your nuxt.config.ts:
export default defineNuxtConfig({
nitro: {
routeRules: {
'/favicon.ico': {
headers: {
'Cache-Control': 'public, max-age=31536000, immutable'
}
},
'/**/*.png': {
headers: {
'Cache-Control': 'public, max-age=31536000, immutable'
}
}
}
}
})
Step 9: Verification and Testing
Development Testing
- Run your Nuxt 3 project:
npm run dev - Check if the favicon appears in browser tabs
- Test on different devices and browsers
Online Validation Tools
- Favicon.im - Check if favicon loads correctly
- RealFaviconGenerator Checker - Comprehensive favicon testing
- Google PageSpeed Insights - Verify favicon doesn't impact performance
Manual Testing Checklist
- [ ] Desktop browser tabs show favicon
- [ ] Mobile browsers display favicon
- [ ] iOS "Add to Home Screen" shows correct icon
- [ ] Android "Add to Home Screen" shows correct icon
- [ ] Bookmarks display favicon
- [ ] Dark/light mode variations work (if implemented)
Troubleshooting Common Issues
Favicon Not Updating After Changes
Symptoms: Old favicon persists despite updating files
Solutions:
-
Force cache refresh with versioning:
export default defineNuxtConfig({ app: { head: { link: [ { rel: 'icon', href: `/favicon.ico?v=${new Date().getFullYear()}${new Date().getMonth()}` } ] } } }) -
Clear browser cache or test in incognito mode
-
Hard refresh with
Ctrl+F5(Windows) orCmd+Shift+R(Mac)
Favicon Missing in Production
Common Causes:
- Build process not copying public files
- CDN/hosting provider configuration issues
- Incorrect file paths
Debug Steps:
-
Verify build output:
npm run build npm run preview -
Check if files exist in
.output/public/after build -
Test with absolute URLs temporarily:
{ rel: 'icon', href: 'https://yourdomain.com/favicon.ico' }
Mobile Devices Show Wrong Icons
Problem: Pixelated or incorrect icons on mobile devices
Solution: Ensure proper mobile-specific icons exist:
export default defineNuxtConfig({
app: {
head: {
link: [
{ rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon.png' },
{ rel: 'icon', type: 'image/png', sizes: '192x192', href: '/android-chrome-192x192.png' }
]
}
}
})
Console 404 Errors for Missing Icons
Problem: Browser requests favicon files that don't exist
Prevention: Only reference files you've actually created:
// ❌ Don't do this if files don't exist
{ rel: 'icon', sizes: '16x16', href: '/favicon-16x16.png' }
// ✅ Only include existing files
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
Advanced: Automated Favicon Generation
For larger projects, automate favicon generation with a custom script:
// scripts/generate-favicons.js
import sharp from 'sharp'
import fs from 'fs'
const sizes = [16, 32, 180, 192, 512]
const inputFile = 'assets/logo.png'
sizes.forEach(size => {
sharp(inputFile)
.resize(size, size)
.png()
.toFile(`public/favicon-${size}x${size}.png`)
.then(() => console.log(`Generated ${size}x${size} favicon`))
})
Run with: node scripts/generate-favicons.js
Performance Considerations
File Size Optimization
- Keep favicon.ico under 1KB when possible
- Use PNG format for larger sizes (better compression)
- Consider SVG for simple logos (smallest file size)
Loading Performance
export default defineNuxtConfig({
app: {
head: {
link: [
// Preload critical favicon
{ rel: 'preload', href: '/favicon-32x32.png', as: 'image' },
{ rel: 'icon', type: 'image/png', sizes: '32x32', href: '/favicon-32x32.png' }
]
}
}
})
Bonus: Quick Logo Generation
If you need to create a favicon from scratch:
- Logo.surf - AI-powered logo generator
- Favicon.io - Generate from text or emoji
- Canva - Design custom icons
Summary and Best Practices
Implementing favicons in Nuxt 3 applications requires balancing simplicity with comprehensive device support. Here's what you should prioritize:
Implementation Priority
- Start with basics -
favicon.ico+ basic PNG sizes - Add mobile support - iOS and Android home screen icons
- Optimize for PWAs - 192x192 and 512x512 PNG icons
- Consider advanced features - Dynamic switching, notifications
Production Checklist
Before deploying your Nuxt 3 application:
- [ ] All favicon files exist in
public/directory - [ ]
nuxt.config.tsreferences only existing files - [ ] Test favicon display in multiple browsers
- [ ] Verify mobile "Add to Home Screen" functionality
- [ ] Check PWA icon display (if applicable)
- [ ] Test dynamic favicon switching (if implemented)
- [ ] Validate with Favicon.im or similar tools
Performance Tips
- Keep files small - ICO files under 1KB, PNGs under 10KB
- Use appropriate formats - ICO for basic support, PNG for quality
- Enable caching - Configure proper HTTP cache headers
- Preload critical icons - For instant theme switching
Going Further
Consider these advanced optimizations for production applications:
- Implement adaptive favicons for light/dark themes
- Add notification badges using canvas manipulation
- Create animated favicons for special events
- Optimize for Core Web Vitals with proper caching strategies
By following this guide, your Nuxt 3 application will have a professional favicon system that works seamlessly across all devices and use cases.
Use favicon.im to quickly check if your favicon is configured correctly. Our free tool ensures your website's favicon displays properly across all browsers and devices.
Free Public Service
Favicon.im is a completely free public service trusted by developers worldwide.