JavaScript Navigator wakeLock Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

navigator.wakeLock is a read-only property that returns a WakeLock object from the Screen Wake Lock API. While a screen wake lock is active, the browser tries to prevent dimming, locking, or a screensaver (MDN).

Read the notes below before you rely on this property. Prefer feature detection when support is limited.

Syntax

Use navigator.wakeLock. Start with this line.

JavaScript
navigator.wakeLock
CallWhat it does
navigator.wakeLockPrimary signature.

Built into the browser. Read navigator.wakeLock on Navigator — no import required.

Library declarations
JavaScript
navigator.wakeLock

Parameters

ParameterDescription
request("screen")Required. Ask for a lock (default type is screen)
WakeLockSentinelRequired. Handle for release / status
Visible documentRequired. Hidden tabs cannot hold the lock

Return Value

Return ValueDescription
*The current value of navigator.wakeLock.

JavaScript Examples

Example 1 — Feature-Detect Support

Check for wakeLock and a secure context before requesting.

JavaScript
console.log(
  "wakeLock: " + ("wakeLock" in navigator ? "available" : "missing")
);
console.log("isSecureContext: " + window.isSecureContext);
console.log("visibilityState: " + document.visibilityState);
Try It Yourself

How It Works

  1. Detect the property. "wakeLock" in navigator.
  2. Secure context. HTTPS / localhost is required.
  3. Visibility. Hidden pages cannot acquire a screen lock.
  4. Next step. Only call request() when those checks look good.

Example 2 — Request a Screen Lock (MDN)

Ask for a WakeLockSentinel and catch refusal.

JavaScript
async function requestWakeLock() {
  if (!("wakeLock" in navigator)) {
    console.log("wakeLock missing");
    return null;
  }
  try {
    const sentinel = await navigator.wakeLock.request("screen");
    console.log("screen wake lock granted");
    return sentinel;
  } catch (err) {
    console.log(err.name + ", " + err.message);
    return null;
  }
}

requestWakeLock();
Try It Yourself

How It Works

  1. Guard. Exit if the API is missing.
  2. Request. request("screen") is the MDN pattern (also the default type).
  3. Success. You receive a WakeLockSentinel to keep and release later.
  4. Failure. Catch NotAllowedError and similar system refusals.

Example 3 — Release the Sentinel

Store the sentinel and free the lock when the user is done.

JavaScript
let sentinel = null;

async function startLock() {
  if (!("wakeLock" in navigator)) return;
  try {
    sentinel = await navigator.wakeLock.request("screen");
    console.log("locked");
  } catch (err) {
    console.log("request failed: " + err.name);
  }
}

async function stopLock() {
  if (!sentinel) return;
  await sentinel.release();
  sentinel = null;
  console.log("released");
}

startLock().then(stopLock);
Try It Yourself

How It Works

  1. Keep a reference. You need the sentinel to release later.
  2. Request. Same MDN call as Example 2.
  3. Release. release() ends the lock promptly.
  4. Clear state. Set the variable to null so you do not double-release.

Browser Support

navigator.wakeLock is Baseline Newly available (MDN: since March 2025). It requires a secure context. Older browsers may still lack it — feature-detect and keep a graceful fallback.

✓ Baseline · Newly available (2025)

Navigator.wakeLock

Screen Wake Lock API entry point. Request a screen lock to reduce dimming/locking while a visible page needs to stay on, then release when finished.

Modern Baseline 2025
Google Chrome Supported · modern versions
Full support
Mozilla Firefox Supported · recent releases
Full support
Apple Safari Supported · recent releases
Full support
Microsoft Edge Supported · Chromium
Full support
Opera Supported · modern versions
Full support
Internet Explorer Not available
No support
wakeLock Newly available

Bottom line: Detect navigator.wakeLock, require HTTPS and a visible document, wrap request() in try/catch, and release when the task ends.

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 (since March 2025). 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.

Next: webdriver

Continue with the next Navigator property in the JavaScript guide.

webdriver tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful