Latest in branch 21.x
21.7.3
Released 10 Apr 2024
(2 years ago)
SoftwareNode.js
Branch21.x
Status
End of life
Initial release21.0.0
17 Oct 2023
(2 years ago)
Latest release21.7.3
10 Apr 2024
(2 years ago)
End of bug fixes01 Apr 2024
(Ended 2 years, 1 month ago)
End of security fixes01 Jun 2024
(Ended 1 year, 11 months ago)
Release noteshttps://github.com/nodejs/node/releases/tag/v21.7.3
Source codehttps://github.com/nodejs/node/tree/v21.7.3
Documentationhttps://nodejs.org/dist/latest-v21.x/docs/api/
Downloadhttps://nodejs.org/download/release/latest-v21.x/
Node.js 21.x ReleasesView full list

What Is New in Node.js 21?

CategoryChange
New FeaturesStable WebSocket client (no flag needed)
New FeaturesV8 11.8 -- includes Array grouping, Promise.withResolvers
New FeaturesBuilt-in fetch() now stable
ImprovementsTest runner: --test-reporter and --test-reporter-destination flags
Improvementsnode:fs glob() added (experimental)
Improvementsnavigator.hardwareConcurrency exposed in global scope
SecurityOpenSSL 3.1.4 bundled
DeprecatedExperimental fetch warnings removed (fetch is now stable)

Stable WebSocket Client -- No More Undici Import

Node.js 21 ships a built-in WebSocket global that works without any flags or third-party packages. It follows the WhatWG WebSocket standard and uses Undici under the hood.

const ws = new WebSocket('wss://echo.example.com');
ws.addEventListener('open', () => ws.send('hello'));
ws.addEventListener('message', (e) => console.log(e.data));

This is significant for server-to-server communication, live data feeds, and any tooling that previously needed ws or undici's WebSocket implementation as a dependency.

New JavaScript Features via V8 11.8

Array grouping (Object.groupBy and Map.groupBy) ships natively -- a long-requested feature for grouping collections by a key without a reducer. Promise.withResolvers() simplifies creating manually-resolved promises.

// Object.groupBy
const items = [{type: 'a', v: 1}, {type: 'b', v: 2}, {type: 'a', v: 3}];
const grouped = Object.groupBy(items, (i) => i.type);
// { a: [...], b: [...] }

// Promise.withResolvers
const { promise, resolve, reject } = Promise.withResolvers();
setTimeout(() => resolve('done'), 1000);

Test Runner Improvements

The built-in test runner now supports --test-reporter and --test-reporter-destination flags. You can pipe test output to spec, tap, junit, or dot formatters and redirect each to a file or stdout independently.

This makes the built-in runner a more complete replacement for Jest/Mocha in CI pipelines that require structured test output (e.g., JUnit XML for GitHub Actions or Jenkins).

Web API Globals Expanded

navigator.hardwareConcurrency is now available in the global scope, matching browser behavior. Scripts that dynamically size worker pools based on CPU count no longer need to os.cpus().length workarounds when targeting both browser and Node environments.

FAQ

Is the built-in WebSocket client compatible with the browser WebSocket API?
Yes, it implements the WhatWG WebSocket standard. Code written for browser WebSocket should work in Node.js 21 without modification.

Can I use Object.groupBy in production with Node.js 21?
Yes, it's part of the ECMAScript 2024 spec and natively available in V8 11.8. No polyfill needed.

What reporters does the built-in test runner support?
spec (human-readable), tap, dot, and junit. You can combine multiple reporters with multiple --test-reporter and --test-reporter-destination pairs.

Is Node.js 21 an LTS release?
No. Node.js 21 is a Current release. The LTS line from this generation is Node.js 22. Use 21 for feature evaluation, not long-term production deployments.

Does fetch() in Node.js 21 support streaming response bodies?
Yes. You can read response bodies as streams via response.body (a ReadableStream), and pipe them using the WHATWG Streams API.

Releases In Branch 21.x

VersionRelease datenpm version
21.7.310 Apr 2024
(2 years ago)
10.5.0
21.7.203 Apr 2024
(2 years ago)
10.5.0
21.7.108 Mar 2024
(2 years ago)
10.5.0
21.7.006 Mar 2024
(2 years ago)
10.5.0
21.6.213 Feb 2024
(2 years ago)
10.2.4
21.6.122 Jan 2024
(2 years ago)
10.2.4
21.6.014 Jan 2024
(2 years ago)
10.2.4
21.5.019 Dec 2023
(2 years ago)
10.2.4
21.4.005 Dec 2023
(2 years ago)
10.2.4
21.3.030 Nov 2023
(2 years ago)
10.2.4
21.2.014 Nov 2023
(2 years ago)
10.2.3
21.1.024 Oct 2023
(2 years ago)
10.2.0
21.0.017 Oct 2023
(2 years ago)
10.2.0