ReadableStreamBYOBRequest: respondWithNewView() method

Baseline 2026
Newly available

Since March 2026, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Note: This feature is available in Web Workers.

The respondWithNewView() method of the ReadableStreamBYOBRequest interface specifies a new view that the consumer of the associated readable byte stream should write to instead of ReadableStreamBYOBRequest.view.

The new view must be a TypedArray or a DataView that provides a view onto the same backing memory region as ReadableStreamBYOBRequest.view. After this method is called, the view that was passed into the method will be transferred and no longer modifiable.

The method is intended for use cases where an underlying byte source needs to transfer a byobRequest.view internally before finishing its response. For example, the source may transfer the BYOB view to a separate worker thread, and wait for the worker to transfer it back once it has been filled.

Syntax

js
respondWithNewView(view)

Parameters

view

A TypedArray or a DataView that the consumer of the associated readable byte stream should write to instead of ReadableStreamBYOBRequest.view.

This must be a view onto the same backing memory region as ReadableStreamBYOBRequest.view and occupy the same or less memory. Specifically, it must be either the view's buffer or a transferred version, must have the same byteOffset, and a byteLength (number of bytes written) that is less than or equal to that of the view.

Return value

None (undefined).

Exceptions

TypeError

Thrown if the source object is not a ReadableStreamBYOBRequest, or there is no associated controller, or the associated internal array buffer is non-existent or detached. It may also be thrown if the view is zero-length when there is an active reader, or non-zero when called on a closed stream.

RangeError

Thrown if the new view does not match the backing memory region of ReadableStreamBYOBRequest.view. For example, it is not the same buffer (or a transferred version), has a different byteOffset, or is larger than the memory available to the backing view.

Examples

The view to be transferred must be of the same type as ReadableStreamBYOBRequest.view, have the same underlying buffer and byte offset, and be the same or smaller byteLength.

For example, we might define the view and respond as shown below:

js
const v = controller.byobRequest.view;
bytesRead = socket.readInto(v.buffer, v.byteOffset, v.byteLength);
byobRequest.respondWithNewView(
  byobRequest.view.subarray(v.byteOffset, bytesRead),
);

Specifications

Specification
Streams
# ref-for-rs-byob-request-respond-with-new-view①

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Bun
Deno
Node.js
respondWithNewView
Chrome – Full support
Chrome 89 (Release date: 2021-03-02)
footnote Full support
Edge – Full support
Edge 89 (Release date: 2021-03-04)
footnote Full support
Firefox – Full support
Firefox 102 (Release date: 2022-06-28)
footnote Full support
Opera – Full support
Opera 75 (Release date: 2021-03-24)
footnote Full support
Safari – Full support
Safari 26.4 (Release date: 2026-03-24)
footnote Full support
Chrome Android – Full support
Chrome Android 89 (Release date: 2021-03-02)
footnote Full support
Firefox for Android – Full support
Firefox for Android 102 (Release date: 2022-06-28)
footnote Full support
Opera Android – Full support
Opera Android 63 (Release date: 2021-04-16)
footnote Full support
Safari on iOS – Full support
Safari on iOS 26.4 (Release date: 2026-03-24)
footnote Full support
Samsung Internet – Full support
Samsung Internet 15 (Release date: 2021-08-13)
footnote Full support
WebView Android – Full support
WebView Android 89 (Release date: 2021-03-02)
footnote Full support
WebView on iOS – Full support
WebView on iOS 26.4 (Release date: 2026-03-24)
footnote Full support
Bun – Full support
Bun 1 (Release date: 2023-09-08)
footnote Full support
Deno – Full support
Deno 1.16 (Release date: 2021-11-08)
footnote Full support
Node.js – Full support
Node.js 16.5 (Release date: 2021-07-14)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also