Skip to content
Tutorials Center
My learning

Topics

Node.js Reference ยท Web APIs in Node.js

Node.js navigator object

Reference for the navigator global in Node.js: hardwareConcurrency, language, languages, platform and userAgent, and how to use them for environment checks.

navigator is a small global object that mirrors a few properties of the browser's navigator. It was added so that code written for both environments can ask simple questions about the runtime without crashing on a missing global.

Node.js implements only a handful of properties: hardwareConcurrency, language, languages, platform and userAgent. It has no onLine, no geolocation, no clipboard, and so on. The global exists since Node.js 21; in Node 24 it is always available.

NODE
console.log(navigator.userAgent);          // 'Node.js/24'
console.log(navigator.hardwareConcurrency); // number of logical CPUs

Try it

Node.js Reading the properties

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Node.js Feature detection for shared code

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Syntax

NODE
navigator.hardwareConcurrency   // number
navigator.language              // string, a BCP 47 tag such as 'en-US'
navigator.languages             // string[]
navigator.platform              // string
navigator.userAgent             // string, 'Node.js/<major>'
Property Description
hardwareConcurrency Number of logical processors available to the process (the same count as os.availableParallelism()).
language The preferred language, taken from the process locale.
languages Array holding the preferred languages; in Node.js it contains just language.
platform A browser-style platform string. It is not the same as process.platform: for example 'Win32' on Windows. Use process.platform for reliable checks.
userAgent Always the form Node.js/ followed by the major version number, for example Node.js/24.

Errors: none. All properties are read-only getters.

Usage notes

  • The value is a hint, not a promise. Containers and cgroup limits can make hardwareConcurrency report more CPUs than you may actually use. For worker pools, treat it as an upper bound and configure explicitly in production.
  • userAgent has only the major version. For the full version use process.version; for dependency versions use process.versions.
  • platform is browser-style, so its spelling differs from process.platform ('Win32' versus 'win32'). Do not compare them, and do not use either for security decisions.
  • Detect Node.js with process.versions.node, not by testing for navigator: other runtimes (browsers, Deno, Bun, Cloudflare Workers) have a navigator too.
  • Values come from the process. language and languages depend on the environment locale and may differ between machines; avoid asserting on them in tests.
  • Feature-test each property before using it in shared code: Node.js gains Web APIs gradually, and older runtimes expose fewer of them.