DEV Community

Cover image for Node.js 21 is Here: Explore the Exciting New Features and Improvements! 🚀
Vitalii Sevastianov
Vitalii Sevastianov

Posted on

Node.js 21 is Here: Explore the Exciting New Features and Improvements! 🚀

It sounds like Node.js 21 is bringing a host of exciting features and updates! Here’s a breakdown of the notable changes:


1. Stable fetch/WebStreams

Description: The fetch and WebStreams modules have been marked as stable. This impacts WebStreams, FormData, Headers, Request, Response, and fetch.
Contribution: By Steven in #45684.

2. Built-in WebSocket client

Description: An experimental browser-compatible WebSocket implementation is included and can be enabled through the --experimental-websocket flag.
Contribution: By Khafra in #49830.

3. V8 11.8 Update

Description: The V8 JavaScript engine has been updated to version 11.8, introducing improved performance and new language features like Array grouping, ArrayBuffer.prototype.transfer, and WebAssembly extended-const expressions.
Contribution: By Michaël Zasso in #47251.

4. Support for globs in the Node.js test runner

Description: The test runner now supports glob expressions when specifying the --test parameter, allowing for more efficient and flexible test execution.
Contribution: By Moshe Atlow in #47653.

5. ESM: --experimental-default-type flag

Description: The new flag allows users to flip the default module system used by Node.js, offering more flexibility in handling ES modules and CommonJS.
Contribution: By Geoffrey Booth in #49869.

6. Module customization hook update

Description: The globalPreload hook has been removed, recommending the use of register and initialize instead for data and communication handling between threads.
Contribution: By Jacob Smith in #49144.

7. Add flush option to fs.writeFile function

Description: A new 'flush' option ensures data is immediately flushed to permanent storage, preventing subsequent read operations from accessing stale data.
Contribution: By Colin Ihrig in #50009.

8. Performance Enhancements

Streams: Optimizations led by Robert Nagy in #50012.
HTTP: Reduced overhead by combining write calls when uncorking the response, contributed by Robert Nagy in #50167.

9. llhttp 9.1.2 strict mode enforcement

Description: Enhanced code reliability and security with strict mode enabled by default and stricter requirements for data processing and transmission.

10. Navigator Object integration

Description: Introduction of the global navigator object for accessing hardware concurrency information.
Contribution: By Yagiz Nizipli in #47769.

11. Deprecations

Runtime deprecate punycode: By Yagiz Nizipli in #47202.
Runtime deprecate promisify-ing a function returning a Promise: By Antoine du Hamel in #49609.

Call to Action

Users and developers are encouraged to test their applications and modules with Node.js 21 and provide feedback.
Note the End-of-Life of Node.js 16 and consider upgrading to Node.js 18 or 20.

Conclusion

Node.js 21 marks a significant step forward, infusing new energy and capabilities into the ecosystem. With the integration of the updated V8 JavaScript engine, stable fetch/WebStreams, and an experimental built-in WebSocket client, developers are equipped with enhanced tools and features to build efficient and scalable applications. The improvements in performance, security, and modularity underscore the Node.js community's commitment to innovation and excellence. As we embrace these changes, the collaboration and feedback from developers worldwide will be instrumental in refining and optimizing Node.js for diverse and complex modern applications. Let’s embark on this journey together, exploring and leveraging the enriched environment that Node.js 21 promises to offer! 🚀💻✨

Top comments (0)