Widely available Supported across all major browsers. Safe to use in production.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
69
79
96
15.4
69
15.4

The mode read-only property of the Lock interface returns the access mode passed to LockManager.request() when the lock was requested. The mode is either "exclusive" (the default) or "shared".

69
79
96
15.4
69
15.4

The name read-only property of the Lock interface returns the name passed to LockManager.request selected when the lock was requested.

69
79
96
15.4
69
15.4

The LockManager interface of the Web Locks API provides methods for requesting a new Lock object and querying for an existing Lock object. To get an instance of LockManager, call navigator.locks.

69
79
96
15.4
69
15.4

The query() method of the LockManager interface returns a Promise that resolves with an object containing information about held and pending locks.

69
79
96
15.4
69
15.4

The request() method of the LockManager interface requests a Lock object with parameters specifying its name and characteristics. The requested Lock is passed to a callback, while the function itself returns a Promise that resolves (or rejects) with the result of the callback after the lock is released, or rejects if the request is aborted.

69
79
96
15.4
69
15.4

The locks read-only property of the Navigator interface returns a LockManager object which provides methods for requesting a new Lock object and querying for an existing Lock object.

69
79
96
15.4
69
15.4

The locks read-only property of the WorkerNavigator interface returns a LockManager object which provides methods for requesting a new Lock object and querying for an existing Lock object.

69
79
96
15.4
69
15.4
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)

Syntax

JAVASCRIPT
navigator.locks.request("net_db_sync", showLockProperties);
navigator.locks.request("another_lock", { mode: "shared" }, showLockProperties);

function showLockProperties(lock) {
  console.log(`The lock name is: ${lock.name}`);
  console.log(`The lock mode is: ${lock.mode}`);
}

Use cases

  • Using Locks

    The Lock interface of the Web Locks API provides the name and mode of a lock.

Cautions

  • May not be supported in older browsers.

Implementation notes

  • Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.