hardBackend

What are the Web Streams API (ReadableStream/WritableStream) in Node.js and how do they differ from node:stream?

478 views
01

Understand the problem

WHATWG streams vs the classic Node stream API.

nodejsstreamsweb-streamsinterop
02

Attempt it yourself

Sketch your approach before reading the solution — that's what interviews test.

Stuck? AI Nudge Available

Get a conceptual hint to guide your logic without spoiling the final implementation.

03

Study the solution

The solution is waiting

Give it an honest attempt first — then compare your thinking with the full walkthrough.

04

Read the code

Consuming fetch's Web ReadableStream
const res = await fetch('https://example.com/big');
// res.body is a Web ReadableStream — async-iterable:
for await (const chunk of res.body) {
  console.log('got', chunk.length, 'bytes');
}

// Bridge to node:stream if needed:
import { Readable } from 'node:stream';
const nodeStream = Readable.fromWeb(res.body);
05

Join the discussion

Discussion (0)

Sign in to join the discussion.

No responses yet. Be the first to share what you think.