shadcn-ahooks

useFavicon

A hook that set the favicon of the page.

Overview

A hook that set the favicon of the page.

Documentation and Examples

Installation

Open in
pnpm dlx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useFavicon.json
npx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useFavicon.json
yarn shadcn@latest add https://shadcn-ahooks.vercel.app/r/useFavicon.json
bun shadcn@latest add https://shadcn-ahooks.vercel.app/r/useFavicon.json

A hook that set the favicon of the page.

Example

Basic Usage

API

useFavicon(href: string);

Params

| Params | Description | Type | Default | | | -- | -- | - | | href | favicon URL, support svg/png/ico/gif | string | - |

FAQ

It doesn't work in Safari?

Safari cannot set the favicon dynamically.

Apple intentionally do not want the ability to script favicons. See https://bugs.webkit.org/show_bug.cgi?id=95979#c2

Related issues: #2126

On this page