Skip to content

Favicon guide

How to change the favicon in a React app (Vite)

A new Vite + React project shows the purple Vite logo in the tab. Swapping it for your own icon takes two edits.

Updated November 11, 2026

1. Put your icons in public/

Everything in Vite's public/ folder is served from the site root as-is. Delete public/vite.svg and copy in your favicon files:

my-app/
├── public/
│   ├── favicon.ico
│   ├── favicon.svg
│   ├── apple-touch-icon.png
│   ├── android-chrome-192x192.png
│   ├── android-chrome-512x512.png
│   └── site.webmanifest
├── src/
└── index.html

2. Update index.html

In a Vite app, index.html sits at the project root (not in public/). Find this line:

<link rel="icon" type="image/svg+xml" href="/vite.svg" />

and replace it with:

<link rel="icon" href="/favicon.ico" sizes="32x32" />
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<link rel="manifest" href="/site.webmanifest" />

Use paths starting with /, not /public/. Vite serves the folder's contents at the root.

Deploying under a sub-path

If you set base in vite.config.ts (common for GitHub Pages, e.g. base: '/my-app/'), Vite rewrites absolute URLs in index.html for you during the build, so /favicon.ico becomes /my-app/favicon.ico. Keep the paths as written above.

Create React App

Older Create React App projects work the same way: the files go in public/ and the tags live in public/index.html, written with %PUBLIC_URL%, like href="%PUBLIC_URL%/favicon.ico". Also update the icon list in public/manifest.json.

Changing the favicon at runtime

To swap the icon from React code (for an unread-count badge, say), update the existing tag rather than adding new ones:

function setFavicon(href: string) {
  const link = document.querySelector<HTMLLinkElement>('link[rel="icon"][type="image/svg+xml"]');
  if (link) link.href = href;
}

Make your favicon in a minute

FavMint is a free favicon generator that runs in your browser. Design an icon from letters, symbols, or 2,100+ icons, check it at real sizes, and download the full package: favicon.ico, SVG, PNGs, the Apple touch icon, Android icons, and site.webmanifest. No signup, nothing uploaded.