Skip to main content
Bun provides full support for the Web Streams API, including ReadableStream, WritableStream, and TransformStream.

ReadableStream

ReadableStreams represent a source of data that can be read chunk by chunk:

Creating Readable Streams

With Pull

With Cancel

Reading from Streams

Using getReader()

Using for-await-of

Using pipeTo()

WritableStream

WritableStreams represent a destination for data:

Creating Writable Streams

Writing to Streams

Using with Files

TransformStream

TransformStreams convert data as it flows through:

Creating Transform Streams

Multiple Transforms

Compression Streams

CompressionStream

DecompressionStream

Supported Formats

  • "gzip" - GZIP compression
  • "deflate" - DEFLATE compression
  • "deflate-raw" - Raw DEFLATE (no headers)

Text Encoding/Decoding Streams

TextEncoderStream

TextDecoderStream

File Streams

Reading Files

Writing Files

Piping Files

HTTP Response Streams

Streaming Response

Server-Sent Events

Streaming File Upload

Stream Utilities

Teeing Streams

Canceling Streams

Backpressure Handling

Direct Streams (Bun-specific)

Bun supports direct streams for zero-copy I/O:

Stream from Async Iterator

Error Handling

Type Signatures