Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2019.
Note: This feature is available in Web Workers.
The getReader() method of the ReadableStream interface creates a reader and locks the stream to it. While the stream is locked, no other reader can be acquired until this one is released.
An object containing the following properties:
mode OptionalA property that specifies the type of reader to create. Values can be:
A ReadableStreamDefaultReader or ReadableStreamBYOBReader object instance, depending on the mode value.
Thrown if the provided mode value is not "byob" or undefined.
TypeErrorThrown if the stream you are trying to create a reader for is already locked, or not a ReadableStream. This is also thrown if a BYOB reader is requested and the stream controller is not a ReadableByteStreamController (the stream was not constructed as an underlying source with type="bytes").
In the following simple example, a previously-created custom ReadableStream is read using a ReadableStreamDefaultReader created using getReader(). (see our Simple random stream example for the full code). Each chunk is read sequentially and output to the UI, until the stream has finished being read, at which point we return out of the recursive function and print the entire stream to another part of the UI.
| Streams # ref-for-rs-get-reader⑤ |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Dec 18, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.