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/usePermission.md
1---2category: Browser3---45# usePermission67Reactive [Permissions API](https://developer.mozilla.org/en-US/docs/Web/API/Permissions_API). The Permissions API provides the tools to allow developers to implement a better user experience as far as permissions are concerned.89## Usage1011```ts12import { usePermission } from '@vueuse/core'1314const microphoneAccess = usePermission('microphone')15```1617## Type Declarations1819```ts20type DescriptorNamePolyfill =21| "accelerometer"22| "accessibility-events"23| "ambient-light-sensor"24| "background-sync"25| "camera"26| "clipboard-read"27| "clipboard-write"28| "gyroscope"29| "magnetometer"30| "microphone"31| "notifications"32| "payment-handler"33| "persistent-storage"34| "push"35| "speaker"36| "local-fonts"37export type GeneralPermissionDescriptor =38| PermissionDescriptor39| {40name: DescriptorNamePolyfill41}42export interface UsePermissionOptions<43Controls extends boolean,44> extends ConfigurableNavigator {45/**46* Expose more controls47*48* @default false49*/50controls?: Controls51}52export type UsePermissionReturn = Readonly<53ShallowRef<PermissionState | undefined>54>55export interface UsePermissionReturnWithControls extends Supportable {56state: UsePermissionReturn57query: () => Promise<PermissionStatus | undefined>58}59/**60* Reactive Permissions API.61*62* @see https://vueuse.org/usePermission63*64* @__NO_SIDE_EFFECTS__65*/66export declare function usePermission(67permissionDesc:68| GeneralPermissionDescriptor69| GeneralPermissionDescriptor["name"],70options?: UsePermissionOptions<false>,71): UsePermissionReturn72export declare function usePermission(73permissionDesc:74| GeneralPermissionDescriptor75| GeneralPermissionDescriptor["name"],76options: UsePermissionOptions<true>,77): UsePermissionReturnWithControls78```79