WakeLock

Draft: This page is not complete.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The WakeLock interface of the Screen Wake Lock API prevents device screens from dimming or locking when an application needs to keep running.

The system wake lock is exposed through the global Navigator.wakelock property.

Methods

request

Requests a WakeLockSentinel object, which returns a Promise that resolves with a WakeLockSentinel object.

Examples

The following asynchronous function requests a WakeLockSentinel object. The WakeLock.request method is wrapped in a try...catch statement to account for if the browser refuses the request for any reason.

try {
  const wakeLock = await navigator.wakeLock.request('screen');
} catch (err) {
  // the wake lock request fails - usually system related, such being low on battery
  console.log(`${err.name}, ${err.message}`);
}

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
WakeLock
84
84
No
No
Yes
No
84
84
No
Yes
No
14.0
request
84
84
No
No
Yes
No
84
84
No
Yes
No
14.0

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WakeLock