Skip to content

useWakeLock

Category
Export Size
727 B
Last Changed
3 years ago

Reactive Screen Wake Lock API. Provides a way to prevent devices from dimming or locking the screen when an application needs to keep running.

Demo

Is Supported: true
Is Active: false

Usage

js
import { useWakeLock } from '@vueuse/core'

const { isSupported, isActive, request, release } = useWakeLock()

If request is called, isActive will be true, and if release is called, or other tab is displayed, or the window is minimized,isActive will be false.

Type Declarations

typescript
type WakeLockType = "screen"
export interface WakeLockSentinel extends EventTarget {
  type: WakeLockType
  released: boolean
  release: () => Promise<void>
}
export type UseWakeLockOptions = ConfigurableNavigator & ConfigurableDocument
/**
 * Reactive Screen Wake Lock API.
 *
 * @see https://vueuse.org/useWakeLock
 * @param options
 */
export declare function useWakeLock(options?: UseWakeLockOptions): {
  isSupported: ComputedRef<boolean>
  isActive: Ref<boolean>
  request: (type: WakeLockType) => Promise<void>
  release: () => Promise<void>
}
export type UseWakeLockReturn = ReturnType<typeof useWakeLock>

Source

SourceDemoDocs

Contributors

Anthony Fu
Jelf
vuff
HannesOberreiter
wheat
koheing

Changelog

No recent changes

Released under the MIT License.

Build the skills AI cannot replace
Secure early access. 500 seats. Lowest entry price. 48 hours.
Join Waitlist
02
days
:
11
hours
:
25
minutes
: