useFavicon
Custom hook that sets the document favicon.
Installation
npx sse-hooks add use-favicon
yarn dlx sse-hooks add use-favicon
pnpm dlx sse-hooks add use-favicon
deno run -A npm:sse-hooks add use-favicon
bunx sse-hooks add use-favicon
Usage
example.ts
import { useFavicon } from "./{hooks file}";
// Basic usage
useFavicon("/assets/favicon-dark.ico");
// With options
useFavicon("/assets/notification-badge.ico", {
preserveFaviconOnUnmount: false, // Revert when component unmounts
type: "image/png",
});
API
Parameters
| Prop | Default | Type |
|---|---|---|
options |
|
Configuration options.
|
href | - |
The URL of the favicon to set. |
Returns
| Return Value | Default | Type |
|---|---|---|
return | - |
Hook return value |
Types Aliases
No specific type aliases defined for this component.
Changelog
81fa5 — feat: add useAutoSave and useCallbackRef hooks with comprehensive documentation