Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/useFavicon.md
1---2category: Browser3---45# useFavicon67Reactive favicon89## Usage1011```ts {3}12import { useFavicon } from '@vueuse/core'1314const icon = useFavicon()1516icon.value = 'dark.png' // change current icon17```1819### Passing a source ref2021You can pass a `ref` to it, changes from of the source ref will be reflected to your favicon automatically.2223```ts {7}24import { useFavicon, usePreferredDark } from '@vueuse/core'25import { computed } from 'vue'2627const isDark = usePreferredDark()28const favicon = computed(() => isDark.value ? 'dark.png' : 'light.png')2930useFavicon(favicon)31```3233When a source ref is passed, the return ref will be identical to the source ref3435```ts36import { useFavicon } from '@vueuse/core'37// ---cut---38const source = shallowRef('icon.png')39const icon = useFavicon(source)4041console.log(icon === source) // true42```4344## Type Declarations4546```ts47export interface UseFaviconOptions extends ConfigurableDocument {48baseUrl?: string49rel?: string50}51export type UseFaviconReturn =52| ComputedRef<string | null | undefined>53| Ref<string | null | undefined>54/**55* Reactive favicon.56*57* @see https://vueuse.org/useFavicon58* @param newIcon59* @param options60*/61export declare function useFavicon(62newIcon: ReadonlyRefOrGetter<string | null | undefined>,63options?: UseFaviconOptions,64): ComputedRef<string | null | undefined>65export declare function useFavicon(66newIcon?: MaybeRef<string | null | undefined>,67options?: UseFaviconOptions,68): Ref<string | null | undefined>69```70