Node.js 21 heralds a new dawn for the software development community.

The latest version—released on October 17, 2023—comes with several internal improvements and enhancements, including the roll-out of a stable fetch API.

In hindsight, the central theme behind the launch of Node.js 21 is fostering a development environment that’s more simplified, structured, streamlined, extensible, and cost-effective.

Node.js 21 upends Node.js 20 as the latest stable release, pushing the latter to long-term support (LTS). Until April 2024, Node.js 21 shall remain the most updated version, transforming the as-is state of Node.js development services and facilitating the development of front-end and back-end components for modern-day applications.

The following article discusses the new features and functionalities of Node.js 21 in detail and reveals what lies in store for developers as well as users.

Node.js 21: A New Era for Node.js Development Services

Developers are in for a treat with the new streak of optimizations and improvements introduced in Node.js 21. If you lead or work in a Node.js development company, we encourage you to peruse the section below and explore what’s new in Node.js 21.

  • Stable Fetch API

The Fetch API, in its browser-compatible version, was introduced in Node.js v.17.5 through an -experimental-fetch flag. More Node.js versions continued to grace the market over the years; however, the Fetch API continued to be marked as experimental.

With the release of Node.js, the Fetch API is available as a stable addition, and a Node.js development company can finally adopt it when developing applications.

  • A Built-In WebSocket Client

Node.js continues with the tradition of using web platform APIs by introducing the –experimental-websocket flag in the latest release. This addition follows the WHATWG standards, bringing a WebSocket global into the Node.js environment.

This recent update aligns with known web platform APIs, such as Fetch and Web Streams APIs, AbortController APIs, the WHATWG URL parser, EventTarget, Web Crypto API and several others.

While it is currently not recommended for production use, you, as part of a Node.js development company, can start experimenting with it using the command below.

  • ES Modules Improvements

Node.js 21 has a –experimental-default-type flag as a new addition, enabling you to change the default behavior for input files that are not specifically declared as ES modules or CommonJS. Before, the category of such inputs were automatically treated as CommonJS.

With the –experimental-default-type flag, a Node.js web development company can fully enable ES module implementation in situations as below:

  • Providing string input via -eval or STDIN, if –input-type is unspecified.
  • Rendering files with .js extension or no extension at all.

The introduction of the –experimental-default-type flag acts as a starting point for ES module syntax support by default while allowing developers to make minimal to zero breaking changes.

  • Test Runner Improvements

Building on the stability achieved in Node.js 20, the native test runner has witnessed a marked change with the release of version 21.

Node.js 21 carves a niche by rolling-out support for glob expressions, allowing a Node.js web development company to match multiple files using custom glob patterns.

  • Web Streams API Stabilization

The Fetch API implementation relies on two elements:

  • The AbortController interface, which allows for aborting fetch requests.
  • The Web Streams API, which is compatible with web browsers.

These additions were fundamental to Node.js versions 15.0.0 and 16.5.0 respectively. While the AbortController was promoted to the stable release in version 15.4.0, it took years until version 21 for the Web Streams API to be available as a stable addition.

Notably, the older Node.js streams API has not been deprecated or removed; instead it will coexist alongside the API, allowing room for conversion between web streams and Node.js streams through the methods introduced at the time of Node.js 17 release.

However it’s worth mentioning that both of these methods are still considered experimental.

Final Thoughts

The Node.js community has a sterling reputation for continuously enhancing its potential and making it more relevant as the time tumbles by.

Gladly, it doesn’t disappoint with what it has done with the version 21 of Node.js.

The latest release rolls out a gift of better, more efficient optimizations that transforms the entire process of frontend and backend development as:

  • Easier.
  • Faster.
  • Better.

No wonder, Node.js unlocks a new innovation frontier for a Node.js development company.