What’s new in Node.js core?

It can be so easy to miss when new features are added to Node.js core. Features are commonly back ported to another release line e.g. a feature is included in a 16.x release, and then also added to a 14.x release at some point in the future. It’s great that all of these new features are being made available, but keeping track of them can be really tricky.

To try and make it a little easier to stay up-to-date with what’s available, I’ve created this series of blog posts as a round up of notable new features in Node.js core.

I’m aware that "notable" is very subjective, so please drop me an email if you have a suggestion for a feature you think should be included.

This series was inspired by a thread which I’ve been posting on Twitter.

🔤 Generate v4 UUIDs without needing the uuid library

If you want to generate v4 UUIDs in Node.js e.g. d2c14405-a3dd-4fcc-b13b-bc649fe1a0bf, you no longer need to add the uuid library as a dependency. You can use crypto.randomUUID() instead.

Read more

🛑 Cancel async operations with AbortController

If you want to cancel an async operation in Node.js, such as an HTTP request, you can now use the built in AbortController and AbortSignal classes. They were originally introduced in the Web Platform APIs, which are implemented by web browsers.

Read more

📦 Make your imports clearer with the node: protocol

You can use the node: protocol to make it clear in your code when you’re importing built in Node.js modules. It makes it much easier to tell which modules are third-party dependencies.

Read more

🌟 Take advantage of promise-based APIs in Node.js

You can use util.promisify() to wrap callback-based APIs in Node.js core. But did you know that Node.js provides several promise-based APIs too? You can use them with async / await, no wrapping needed! There are two new promise-based APIs in Node.js core: timers/promises and stream/promises.

Read more