useFavicon
Custom hook that sets the document favicon.
Installation
npx sse-tool add use-favicon
npm install sse-hooks
Usage
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",
});
import { useFavicon } from "sse-hooks";
// 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
| Name | Type | Description |
|---|---|---|
| href | string | The URL of the favicon to set. |
| options | UseFaviconOptions | Configuration options. |
Changelog
81fa5 — feat: add useAutoSave and useCallbackRef hooks with comprehensive documentation