New Features Coming with Node.js 18

In the software world that is developing day by day, today I will give you information about the innovations about Node.js 18. Before moving on to our topic, let’s learn what node.js is.

What is Node.js

Node.js is an open source, server-side execution environment where we can write server-side applications with JavaScript. It can also be called a JavaScript Runtime platform.

New Features Coming with Node.js 18

Feature 1 (Native Fetch API in Node.js 18)

With v18 we can now provide native fetch functionality. This is a standardized web API standard for executing HTTP or other types of network requests. Node.js previously did not support this by default. JavaScript is used in many areas, and the addition of this construct is good news for developers.

const res = await fetch('https://api.belo.app/public/price');
if (res.ok) {
  const data = await res.json();
  console.log(data);
}

Feature 2 (–watch)

A project run using –watch will now restart the project when there is an imported file. Just like in the Nodemon build. You can also use –watch-path to specify which path to watch for.

Feature 3 (OpenSSL 3 Support)

OpenSSL is an open source implementation of the SSL and TLS protocols for securing communication. One of the most important features of OpenSSL 3.0 is the FIPS (Federal Information Processing Standards) module. FIPS is a set of US government requirements to govern the use of crypto graphics in the public sector. It now has OpenSSL support with the v18 release.

New Features Coming with Node.js 18

Feature 4 (HTTP Timeouts)

Http.server timeouts have changed:

  • headersTimeout : The timeout for parsing an http header request has been changed to 60 seconds.
  • requestTimeout : The time overtime used for http request is set to 5 minutes by default.

Feature 5 (Experimental node:test)

The node:test module is a module for creating JavaScript tests that report the results in TAP (Test Anything Protocol) format. TAP output is widely used. You can use the “import test from node:test” command to include it in the project.

import test from 'node:test';
import test from 'node:test';
import assert from 'node:assert';

test('synchronous passing test', (t) => {
  // This test passes because it does not throw an exception.
  assert.strictEqual(1, 1);
});

In this blog post, we took a look at the new features coming with node.js 18. See you in my next blog post…

Leave a Reply

Your email address will not be published. Required fields are marked *