Back to Mantine

Use Favicon

apps/mantine.dev/src/pages/hooks/use-favicon.mdx

9.5.1704 B
Original Source

import { UseFaviconDemos } from '@docs/demos'; import { Layout } from '@/layout'; import { MDX_DATA } from '@/mdx';

export default Layout(MDX_DATA.useFavicon);

Usage

The use-favicon hook appends a <link /> element to the head component with the given favicon in useLayoutEffect. The hook is not called during server-side rendering.

Call the hook with a favicon URL (supported formats: .ico, .png, .svg, and .gif) that should be set as the favicon. The hook is triggered every time the URL changes and the value is not an empty string (trailing whitespace is trimmed) or null.

<Demo data={UseFaviconDemos.usage} />

Definition

tsx
function useFavicon(url: string): void;