What's new in the Node.js v18.x release?
Rahul Sharma
Posted on April 21, 2022
Node.js 18 is released recently, There are some interesting features added in Node.js 18.
Node.js 18 will be the 'Current' release for the next 6 months and then promoted to Long-term Support (LTS) in October 2022. Once promoted to long-term support the release will be designated the codename 'Hydrogen'. Node.js 18 will be supported until April 2025.
Release Note: here
Features of Node.js 18.x:
fetch (experimental)
It's been a long-waited feature of Node.js 18. It is a new fetch API that is based on the WHATWG Fetch standard.
fetch is already supported by almost all modern browsers.
const get = async (url) => {
const res = await fetch(url);
if (res.ok) {
const data = await res.json();
console.log(data);
}
};
It's possible to disable the API by supplying the --no-experimental-fetch command-line flag.
Web Streams API (experimental)
Node.js 18 introduces the Web Streams API. It'll be globally available now.
- ReadableStream
- ReadableStreamDefaultReader
- ReadableStreamBYOBReader
- ReadableStreamBYOBRequest
- ReadableByteStreamController
- ReadableStreamDefaultController
- TransformStream
- TransformStreamDefaultController
- WritableStream
- WritableStreamDefaultWriter
- WritableStreamDefaultController
- ByteLengthQueuingStrategy
- CountQueuingStrategy
- TextEncoderStream
- TextDecoderStream
- CompressionStream
- DecompressionStream.
Test runner module (experimental)
This is a new test runner module that does not completely replace other test runners like jest or mocha. but does offer a quick and easy way to run a test suite without any additional dependencies.
import test from "node:test";
test("Number:Test", async (t) => {
await t.test("Check numbers are equal", () => {
assert.strictEqual(1, 1);
});
});
V8 engine update
The V8 engine is updated to version 10.1, which is part of Chromium 101.
https://nodejs.org/en/blog/announcements/v18-release-announce/#v8-10-1
Must Read If you haven't
Javascript console Methods: A Cheat Sheet for Developers
How to cancel Javascript API request with AbortController
How to solve Express.js REST API routing problem with typescript decorators?
Javascript short reusable functions trick and tips
More content at Dev.to.
Catch me on YouTube, Github, Twitter, LinkedIn, Medium, Stackblitz, Hashnode, HackerNoon, and Blogspot.
Posted on April 21, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.