usePermission
Reactive Permissions API. The Permissions API provides the tools to allow developers to implement a better user experience as far as permissions are concerned.
Demo
{}
Usage
import { usePermission } from '@vueuse/core'
const microphoneAccess = usePermission('microphone')
import { usePermission } from '@vueuse/core'
const microphoneAccess = usePermission('microphone')
Type Declarations
Show Type Declarations
declare type DescriptorNamePolyfill =
| "clipboard-read"
| "clipboard-write"
| "camera"
| "microphone"
| "speaker"
export declare type GeneralPermissionDescriptor =
| PermissionDescriptor
| {
name: DescriptorNamePolyfill
}
export interface UsePermissionOptions<Controls extends boolean>
extends ConfigurableNavigator {
/**
* Expose more controls
*
* @default false
*/
controls?: Controls
}
export declare type UsePermissionReturn = Readonly<
Ref<PermissionState | undefined>
>
export interface UsePermissionReturnWithControls {
state: UsePermissionReturn
isSupported: boolean
query: () => Promise<PermissionStatus | undefined>
}
/**
* Reactive Permissions API.
*
* @see https://vueuse.org/usePermission
*/
export declare function usePermission(
permissionDesc:
| GeneralPermissionDescriptor
| GeneralPermissionDescriptor["name"],
options?: UsePermissionOptions<false>
): UsePermissionReturn
export declare function usePermission(
permissionDesc:
| GeneralPermissionDescriptor
| GeneralPermissionDescriptor["name"],
options: UsePermissionOptions<true>
): UsePermissionReturnWithControls
declare type DescriptorNamePolyfill =
| "clipboard-read"
| "clipboard-write"
| "camera"
| "microphone"
| "speaker"
export declare type GeneralPermissionDescriptor =
| PermissionDescriptor
| {
name: DescriptorNamePolyfill
}
export interface UsePermissionOptions<Controls extends boolean>
extends ConfigurableNavigator {
/**
* Expose more controls
*
* @default false
*/
controls?: Controls
}
export declare type UsePermissionReturn = Readonly<
Ref<PermissionState | undefined>
>
export interface UsePermissionReturnWithControls {
state: UsePermissionReturn
isSupported: boolean
query: () => Promise<PermissionStatus | undefined>
}
/**
* Reactive Permissions API.
*
* @see https://vueuse.org/usePermission
*/
export declare function usePermission(
permissionDesc:
| GeneralPermissionDescriptor
| GeneralPermissionDescriptor["name"],
options?: UsePermissionOptions<false>
): UsePermissionReturn
export declare function usePermission(
permissionDesc:
| GeneralPermissionDescriptor
| GeneralPermissionDescriptor["name"],
options: UsePermissionOptions<true>
): UsePermissionReturnWithControls
Source
Contributors
Anthony Fu
Antério Vieira
Alex Kozack
Nurettin Kaya