WakeLock
Baseline 2025Newly available
Since March 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.
TheWakeLock interface of theScreen Wake Lock API can be used to request a lock that prevents device screens from dimming or locking when an application needs to keep running.
This interface, and hence the system wake lock, is exposed through theNavigator.wakeLock property.
In this article
Instance methods
request()Returns a
Promisethat fulfills with aWakeLockSentinelobject if the screen wake lock is granted.
Examples
The following codeawaits the request for aWakeLockSentinel object, and continues if the request is granted.
TheWakeLock.request() method is wrapped in atry...catch statement to catchcases when the promise might be rejected rejected, such as due to low device power.
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}`);}Note that the screen wake lock may be revoked by the device after it has been granted.The returnedWakeLockSentinel can be used to check the status of the lock, and/or to manually cancel a held screen wake lock.
Specifications
| Specification |
|---|
| Screen Wake Lock API> # the-wakelock-interface> |