useFavicon

Dynamically update the favicon with useFavicon.

Install:

npm i @uidotdev/usehooks

Description:

The useFavicon hook is a useful for dynamically update the favicon (shortcut icon) of a web page. By using this hook, you can easily change the favicon by providing a new URL as a parameter. It creates a new link element with the specified URL, sets its type and relationship attributes appropriately, and appends it to the <head> section of the document.

Parameters

NameTypeDescription
urlstringThe URL of the favicon to be set for the document.

Demo:

Example:

More Hooks:

Sort: