Skip to main content

Streaming basics

The Response object supports streaming via the standard body property, which returns a ReadableStream<Uint8Array>. This allows you to process large responses incrementally.

Key behaviors

The body property is lazily initialized. It returns null for empty responses or a ReadableStream for non-empty responses.
Accessing response.body does not mark it as consumed. Only reading from the stream sets bodyUsed to true.
You can call response.clone() to create a duplicate response before the body is consumed.
Once consumed via json(), text(), arrayBuffer(), or stream reading, the body cannot be read again.

Processing chunks

Process data as it arrives:

Download with progress

Track download progress from the response stream itself:

Transport-level request progress

If you want progress before you start consuming response.body, use onRequestEvent. This gives you visibility into request start, headers, and native body download progress.
For more detail on event payloads and diagnostics, see /guides/request-events.

Server-Sent Events (SSE)

Parse Server-Sent Events from a stream:
  1. Fetch API response shape: fetch()
  2. Session concept for multi-step flows: /concepts/sessions