
"Before: Developers installed node-fetch to use the familiar browser fetch() API in Node.js. Now: Starting in Node.js 18, fetch() is a global function, identical to the browser implementation. const res = await fetch('https://api.github.com/repos/nodejs/node'); const data = await res.json(); console.log(data.full_name); // "nodejs/node" When added: Introduced in Node.js v17.5.0 (experimental) Stabilized: Became stable (no longer experimental) in Node.js v18.0.0 When to still use node-fetch: Only if you need older Node.js compatibility (pre-18)."
"Before: The ws package was the go-to for WebSocket clients and servers. Now: Node.js includes a global WebSocket class for client-side connections: const ws = new WebSocket('wss://echo.websocket.org'); ws.onopen = () => ws.send('Hello!'); ws.onmessage = (event) => console.log('Received:', event.data); When added: Experimental global WebSocket client support added in Node.js v21.0.0 Stabilized: As of current available sources, still experimental (no stable version declared yet) When to still use ws: For server-side WebSocket implementations, ws or libraries built on top of it remain the standard."
Node.js now includes many capabilities that previously required third-party npm packages, reducing dependency bloat and improving security and maintainability. The global fetch() API is available natively starting in Node.js 18, matching the browser implementation and replacing the need for node-fetch unless older Node versions must be supported. An experimental global WebSocket client class was added in Node.js v21 to allow client-side WebSocket connections, while server-side implementations still commonly rely on ws-based libraries. The platform evolution consolidates common utilities into the runtime. N|Solid provides tooling to track security risks from third-party packages in Node.js.
Read at nodesource.com
Unable to calculate read time
Collection
[
|
...
]