Skip to main content

useFavicon

Hook to set and update the favicon of the webpage.

Usage

Live Editor
function App() {
	const changeFavicon = useFavicon("");

	const handleFaviconChange = () => {
		changeFavicon("https://github.githubassets.com/favicons/favicon.svg");
	};

	return (
		<div>
			<h1>Hello, world!</h1>
			<button onClick={handleFaviconChange}>Change Favicon</button>
		</div>
	);
}
Result
Loading...

API

Parameter:

initialFaviconUrl: string - The initial URL of the favicon to set.

Returns : function

A function to change the favicon of the webpage.