Skip to content

fromAsyncIterable

fromAsyncIterable<T>(iterable): ReadableStream<T>

Defined in: stream-utils.ts:350

Create a ReadableStream from an async iterable source.

This utility converts any async iterable (like async generators) into a ReadableStream, making it compatible with browser streaming APIs and React streaming hooks. Useful for bridging between Node.js-style async iterators and Web Streams API.

T

AsyncIterable<T>

Any async iterable source (async generator, etc.)

ReadableStream<T>

ReadableStream emitting values from the iterable

async function* generateData() {
yield 'chunk 1';
yield 'chunk 2';
yield 'chunk 3';
}
const stream = fromAsyncIterable(generateData());
const response = new Response(stream);