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/useWakeLock.md
1---2category: Browser3---45# useWakeLock67Reactive [Screen Wake Lock API](https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake_Lock_API). Provides a way to prevent devices from dimming or locking the screen when an application needs to keep running.89## Usage1011```ts12import { useWakeLock } from '@vueuse/core'1314const { isSupported, isActive, forceRequest, request, release } = useWakeLock()15```1617When `request` is called, the wake lock will be requested if the document is visible. Otherwise, the request will be queued until the document becomes visible. If the request is successful, `isActive` will be **true**. Whenever the document is hidden, the `isActive` will be **false**.1819When `release` is called, the wake lock will be released. If there is a queued request, it will be canceled.2021To request a wake lock immediately, even if the document is hidden, use `forceRequest`. Note that this may throw an error if the document is hidden.2223## Type Declarations2425```ts26type WakeLockType = "screen"27export interface WakeLockSentinel extends EventTarget {28type: WakeLockType29released: boolean30release: () => Promise<void>31}32export type UseWakeLockOptions = ConfigurableNavigator & ConfigurableDocument33export interface UseWakeLockReturn extends Supportable {34sentinel: ShallowRef<WakeLockSentinel | null>35isActive: ComputedRef<boolean>36request: (type: WakeLockType) => Promise<void>37forceRequest: (type: WakeLockType) => Promise<void>38release: () => Promise<void>39}40/**41* Reactive Screen Wake Lock API.42*43* @see https://vueuse.org/useWakeLock44* @param options45*46* @__NO_SIDE_EFFECTS__47*/48export declare function useWakeLock(49options?: UseWakeLockOptions,50): UseWakeLockReturn51```52