1 of 20
2 of 20
3 of 20
4 of 20
5 of 20
6 of 20
7 of 20
8 of 20
9 of 20
10 of 20
11 of 20
12 of 20
13 of 20
14 of 20
15 of 20
16 of 20
17 of 20
18 of 20
19 of 20
20 of 20



The Streams API’s ReadableStreamDefaultReader is a default reader used to read stream data obtained from a network, such as a fetch request.

Unlike a ReadableStreamBYOBReader, which only works with streams that have a byte source, the ReadableStreamDefaultReader can be used to read from any type of ReadableStream source.


ReadableStreamDefaultReader() Creates and returns a ReadableStreamDefaultReader object instance.

Instance properties

ReadableStreamDefaultReader.closed Returns a Promise that fulfills when the stream closes, or rejects if the stream throws an error or the reader’s lock is released. This property enables you to write code that responds to an end to the streaming process.

Instance methods

ReadableStreamDefaultReader.cancel() Returns a Promise that resolves when the stream is canceled. Calling this method signals a loss of interest in the stream by a consumer. The supplied reason argument will be given to the underlying source, which may or may not use it.

ReadableStreamDefaultReader.read() Returns a promise providing access to the next chunk in the stream’s internal queue.

ReadableStreamDefaultReader.releaseLock() Releases the reader’s lock on the stream.


In the following example, an artificial Response is created to stream HTML fragments fetched from another resource to the browser.

fetch("https://www.example.org/").then((response) => {
  const reader = response.body.getReader();
  const stream = new ReadableStream({
    start(controller) {
      // The following function handles each data chunk
      function push() {
        // "done" is a Boolean and value a "Uint8Array"
        return reader.read().then(({ done, value }) => {
          // Is there no more data to read?
          if (done) {
            // Tell the browser that we have finished sending data

          // Get the data and send it to the browser via the controller


  return new Response(stream, { headers: { "Content-Type": "text/html" } });

For more information on ReadableStreamDefaultReader visit MDN Web Docs.

Didn’t find what you were looking for? Open a support ticket.