Node.js 21.0 Released

The release of Node.js 21.0 took place, which is a platform for performing network applications in JavaScript. Support for the Node.js 21.0 branch will be carried out within 6 months. In the coming days, the stabilization of the Node.js 20 branch will be completed, which will receive LTS status and will be maintained until April 2026. The support for the LTS vehicle Node.js 18.0 will last until September 2025, and the LTS vehicle before last 16.0 until April 2024.

The main features of the Node.js 21.0 release include the following:

  • The declaration of the stable API fetch, designed to download resources over the network and simplify writing universal JavaScript code suitable for working on the server and client side. The implementation is based on the code from http/1.1 of the client undici and is as close as possible to the similar API provided in browsers. The API includes the FETCH() method and the objects headers, Request, and Response, representing http-settings, request, and response. The code example for using this API would be COST res = await fetch(‘https://nodejs.org/api/documentation.json’); if (res.ok) { const data = await res.json(); console.log(data); }
  • The stabilization of support for the API webstreams, which provides access to the data obtained on the network. The API allows adding handlers that work with data as information on the network arrives without waiting for the entire file to be downloaded. Node.js provides objects such as ReadableStream, TransformStream, WritableStream, TextEncoderStream, TextDecoderStream, CompressionStream, and DecompressionStream.
  • The addition of the experimental implementation of the client WebSocket, compatible with browsers. To enable WebSocket support, the flag “–experimental-features” is provided.
  • The experimental use of the default implementation of the ESM JavaScript modules (ECMASCRIPT MODULES, used in modules for browsers) instead of CommonJS (specific for Node.js). The change does not affect the modules whose format is clearly defined through the “Type” field in Package.json, set through the flag “–input-type” or is obvious due to the file extension (.mjs for ESM, .cjs for CommonJS). However, modules that are clearly not defined as CommonJS (for example, having the extension “.js”), when
/Reports, release notes, official announcements.