On this page

navigator

History
Stability: 1.1Active development. Disable this API with the --no-experimental-global-navigator CLI flag.

A partial implementation of window.navigator.

P
History
Type:number

The navigator.hardwareConcurrency read-only property returns the number of logical processors available to the current Node.js instance.

P
History
Type:string

The navigator.language read-only property returns a string representing the preferred language of the Node.js instance. The language will be determined by the ICU library used by Node.js at runtime based on the default language of the operating system.

The value is representing the language version as defined in RFC 5646.

The fallback value on builds without ICU is 'en-US'.

P
History
Type:string[]

The navigator.languages read-only property returns an array of strings representing the preferred languages of the Node.js instance. By default navigator.languages contains only the value of navigator.language, which will be determined by the ICU library used by Node.js at runtime based on the default language of the operating system.

The fallback value on builds without ICU is ['en-US'].

P
History
Stability: 1Experimental

The navigator.locks read-only property returns a LockManager instance that can be used to coordinate access to resources that may be shared across multiple threads within the same process. This global implementation matches the semantics of the browser LockManager API.

// Request an exclusive lock
await navigator.locks.request('my_resource', async (lock) => {
  // The lock has been acquired.
  console.log(`Lock acquired: ${lock.name}`);
  // Lock is automatically released when the function returns
});

// Request a shared lock
await navigator.locks.request('shared_resource', { mode: 'shared' }, async (lock) => {
  // Multiple shared locks can be held simultaneously
  console.log(`Shared lock acquired: ${lock.name}`);
});
// Request an exclusive lock
navigator.locks.request('my_resource', async (lock) => {
  // The lock has been acquired.
  console.log(`Lock acquired: ${lock.name}`);
  // Lock is automatically released when the function returns
}).then(() => {
  console.log('Lock released');
});

// Request a shared lock
navigator.locks.request('shared_resource', { mode: 'shared' }, async (lock) => {
  // Multiple shared locks can be held simultaneously
  console.log(`Shared lock acquired: ${lock.name}`);
}).then(() => {
  console.log('Shared lock released');
});

See worker_threads.locks for detailed API documentation.

P
History
Type:string

The navigator.platform read-only property returns a string identifying the platform on which the Node.js instance is running.

P
History
Type:string

The navigator.userAgent read-only property returns user agent consisting of the runtime name and major version number.