navigator.wakeLock returns a WakeLock object from the Screen Wake Lock API. Learn how to request a screen lock, release it, handle failures, re-acquire after tab switches, five examples, and try-it labs.
01
Kind
Read-only property
02
Returns
WakeLock
03
Baseline
Newly available
04
Context
Secure (HTTPS)
05
Key method
request("screen")
06
Handle
WakeLockSentinel
Fundamentals
Introduction
Phones and laptops often dim or lock the screen to save battery. That is great most of the time — but terrible while you follow a recipe, read a map, present slides, or scan a QR code.
navigator.wakeLock is the entry point to the Screen Wake Lock API. While a screen wake lock is active, the browser tries to prevent dimming, turning the screen off, or showing a screensaver.
💡
Visible documents only
MDN: only visible (active) documents can acquire the screen wake lock. If the user switches tabs or minimizes the window, the lock is often released automatically.
Concept
Understanding the wakeLock Property
Think of navigator.wakeLock as a gate to one main action: request("screen"). That Promise resolves to a WakeLockSentinel you keep around so you can release the lock later.
WakeLock — object returned by the property.
request("screen") — ask for a screen wake lock (default type is also screen).
WakeLockSentinel — handle for the granted lock; call release().
release event — fires when the lock ends (manual or system).
Secure context — HTTPS / localhost required.
Permissions Policy — may be gated by screen-wake-lock.
Foundation
📝 Syntax
General form of the property:
JavaScript
navigator.wakeLock
Value
A WakeLock object used to request screen wake locks.
Common patterns
JavaScript
// Feature-detect:
if ("wakeLock" in navigator) {
// Supported
}
// Request (MDN-style):
let sentinel = null;
try {
sentinel = await navigator.wakeLock.request("screen");
console.log("Wake Lock is active!");
} catch (err) {
console.log(err.name + ", " + err.message);
}
// Release later:
if (sentinel) {
await sentinel.release();
sentinel = null;
}
Cheat Sheet
⚡ Quick Reference
Goal
Code
Get WakeLock
navigator.wakeLock
Feature detect
"wakeLock" in navigator
Request screen lock
await navigator.wakeLock.request("screen")
Release lock
await sentinel.release()
Listen for end
sentinel.addEventListener("release", …)
Secure context?
window.isSecureContext
Page visible?
document.visibilityState === "visible"
Snapshot
🔍 At a Glance
Four facts to remember about navigator.wakeLock.
Returns
WakeLock
Screen lock API
Status
Baseline
Newly available
Context
HTTPS
Secure required
Type
"screen"
Keep display on
Compare
📋 Default Screen Timeout vs Screen Wake Lock
Default device behavior
With Screen Wake Lock
After idle time
Screen dims / locks
Browser tries to keep screen on
Battery
Saved by timeout
Uses more power — use only when needed
Tab hidden
N/A
Lock usually released; re-request when visible
User control
System settings
Your UI should offer an Off control
Hands-On
Examples Gallery
Examples follow MDN Screen Wake Lock patterns. Prefer Try It Yourself on HTTPS with the tab visible — requests fail when the document is hidden or the battery policy blocks them.
📚 Getting Started
Detect the API and request a screen wake lock.
Example 1 — Feature Detection
MDN-style support check before enabling a Keep Awake button.
navigator.wakeLock is Baseline Newly available for the Screen Wake Lock API. It requires a secure context. Always feature-detect, request only while the page is visible, and handle refusal (battery / policy) gracefully.
✓ Baseline · Newly available
Navigator.wakeLock
WakeLock entry point — request a screen lock, hold a WakeLockSentinel, release when done.
ModernNewly available
Google ChromeScreen Wake Lock · Desktop & Mobile
Full support
Microsoft EdgeScreen Wake Lock · Chromium
Full support
OperaScreen Wake Lock · Modern versions
Full support
Apple SafariScreen Wake Lock · check version / platform
Full support
Mozilla FirefoxScreen Wake Lock · check version
Full support
Internet ExplorerNo wakeLock support
Unavailable
wakeLockStrong
Bottom line: Detect wakeLock, call request("screen") from a visible tab on HTTPS, listen for release, and re-acquire on visibilitychange when Keep Awake stays on.
Wrap Up
Conclusion
navigator.wakeLock is the Baseline entry point for keeping the screen awake when usability needs it. Request a screen lock on a visible HTTPS page, hold the sentinel, release when done, and re-acquire after visibility changes.
Baseline screen lock — request, hold sentinel, release, re-acquire when visible.
5
Core concepts
📄01
Returns
WakeLock
Value
⚡02
Request
request("screen")
API
🔒03
Context
secure HTTPS
Required
👁04
Visible
document must show
Rule
🎯05
Handle
WakeLockSentinel
Release
❓ Frequently Asked Questions
A WakeLock object for the Screen Wake Lock API. Call wakeLock.request("screen") to get a WakeLockSentinel that helps keep the screen from dimming or locking while your visible page needs to stay on.
No. MDN marks it Baseline Newly available. It is not Deprecated, Experimental, or Non-standard. It does require a secure context (HTTPS / localhost).
Yes. MDN lists it as a secure-context feature (HTTPS or localhost) in supporting browsers.
Common reasons: the document is hidden / not fully active, Permissions Policy blocks screen-wake-lock, low battery / power save, or the platform cannot grant the lock. Wrap request() in try/catch.
The object returned when a lock is granted. Use release() to free it manually, listen for the release event, and check the released property. After release, request a new lock if you still need one.
No. Use wake lock only when it helps usability (recipes, maps, presentations, ebooks). Show UI status and let the user turn it off.
Did you know?
A screen wake lock is different from preventing a laptop from sleeping entirely. It targets the display (dim / lock / screensaver) for visible pages — not a guarantee that background CPU work or downloads will keep running forever.