react-favicon is a React component that enables dynamic control over a web application's favicon. It allows developers to easily update the favicon image using a URL or a base64 encoded string, integrate animated sequences from a list of URLs, toggle these animations on and off, and display alert bubbles with customizable text and background colors directly on the favicon. Additionally, it supports custom icon overlays through a render function and offers a mechanism to preserve existing favicon links on the page, which can be beneficial for specific browser behaviors like desktop Safari. The package is currently at version 2.0.7 and appears to have an active release cadence, with recent updates ensuring compatibility with React 19 and addressing various internal component optimizations. Its key differentiator lies in providing a declarative, React-idiomatic way to manage complex favicon behaviors, moving beyond simple static <link> tags, making it suitable for applications requiring dynamic visual feedback in the browser tab.
npm install react-faviconVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic `Favicon` usage with a static URL and an animated sequence, updating the browser tab's icon dynamically. Includes basic error handling for root element.
Review your bundler configuration for ESM/CJS compatibility. If issues arise, report bugs to the maintainers, as API breakage was not intended.
Always explicitly pass all required props to the `Favicon` component, or define default values within your consuming component, rather than relying solely on the library's `defaultProps`.
Pass `keepIconLink={() => true}` to the `Favicon` component if you wish to prevent it from removing other favicon `<link>` tags in the document head.Ensure the `url` prop is always provided and is of type `string` or `string[]`.
Use ESM `import Favicon from 'react-favicon';` in your JavaScript/TypeScript files.
Ensure you pass the `url` prop: `<Favicon url="https://example.com/favicon.ico" />` or `<Favicon url={['url1', 'url2']} />`.Ensure all props are explicitly passed or correctly default to prevent `undefined` values, especially for props like `alertCount`, `alertFillColor`, etc.