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.
console.log(navigator.userAgent); // 'Node.js/24' console.log(navigator.hardwareConcurrency); // number of logical CPUs
Try it
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.
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
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
hardwareConcurrencyreport more CPUs than you may actually use. For worker pools, treat it as an upper bound and configure explicitly in production. userAgenthas only the major version. For the full version useprocess.version; for dependency versions useprocess.versions.platformis browser-style, so its spelling differs fromprocess.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 fornavigator: other runtimes (browsers, Deno, Bun, Cloudflare Workers) have anavigatortoo. - Values come from the process.
languageandlanguagesdepend 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.