WebTransport: createUnidirectionalStream() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Note: This feature is available in Web Workers.

The createUnidirectionalStream() method of the WebTransport interface asynchronously opens a unidirectional stream.

The method returns a Promise that resolves to a WritableStream object, which can be used to reliably write data to the server.

"Reliable" means that transmission and order of data are guaranteed. This provides slower delivery (albeit faster than with WebSockets) than datagrams, but is needed in situations where reliability and ordering are important, like chat applications.

The relative order in which queued bytes are emptied from created streams can be specified using the sendOrder option. If set, queued bytes in streams with a higher send order are guaranteed to be sent before queued bytes for streams with a lower send order. If the order number is not set then the order in which bytes are sent is implementation dependent. Note however that even though bytes from higher send-order streams are sent first, they may not arrive first.

Syntax

js
createUnidirectionalStream()
createUnidirectionalStream(options)

Parameters

options Optional

An object that may have the following properties:

sendOrder Optional

An integer value specifying the send priority of this stream relative to other streams for which the value has been set. Queued bytes are sent first for streams that have a higher value. If not set, the send order depends on the implementation.

Return value

A Promise that resolves to a WebTransportSendStream object (this is a WritableStream).

Exceptions

InvalidStateError DOMException

Thrown if createUnidirectionalStream() is invoked while the WebTransport is closed or failed.

Examples

Use the createUnidirectionalStream() method to get a reference to a WritableStream. From this you can get a writer to allow data to be written to the stream and sent to the server.

Use the close() method of the resulting WritableStreamDefaultWriter to close the associated HTTP/3 connection. The browser tries to send all pending data before actually closing the associated connection.

js
async function writeData() {
  const stream = await transport.createUnidirectionalStream({
    sendOrder: "596996858",
  });
  const writer = stream.getWriter();
  const data1 = new Uint8Array([65, 66, 67]);
  const data2 = new Uint8Array([68, 69, 70]);
  writer.write(data1);
  writer.write(data2);

  try {
    await writer.close();
    console.log("All data has been sent.");
  } catch (error) {
    console.error(`An error occurred: ${error}`);
  }
}

You can also use WritableStreamDefaultWriter.abort() to abruptly terminate the stream. When using abort(), the browser may discard any pending data that hasn't yet been sent.

js
// …

const stream = await transport.createUnidirectionalStream();
const writer = stream.getWriter();

// …

writer.write(data1);
writer.write(data2);
await writer.abort();
// Not all the data may have been written.

Specifications

Specification
WebTransport
# dom-webtransport-createunidirectionalstream

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
Deno
createUnidirectionalStream
Chrome – Full support
Chrome 97 (Release date: 2022-01-04)
footnote Full support
Edge – Full support
Edge 97 (Release date: 2022-01-06)
footnote Full support
Firefox – Partial support
Firefox 114 (Release date: 2023-06-06)
footnote Partial support
footnote Returns a WritableStream instead of a WebTransportSendStream.
Opera – Full support
Opera 83 (Release date: 2022-01-19)
footnote Full support
Safari – Full support
Safari 26.4 (Release date: 2026-03-24)
footnote Full support
Chrome Android – Full support
Chrome Android 97 (Release date: 2022-01-04)
footnote Full support
Firefox for Android – Partial support
Firefox for Android 114 (Release date: 2023-06-06)
footnote Partial support
footnote Returns a WritableStream instead of a WebTransportSendStream.
Opera Android – Full support
Opera Android 68 (Release date: 2022-03-30)
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 18 (Release date: 2022-08-08)
footnote Full support
WebView Android – Full support
WebView Android 97 (Release date: 2022-01-04)
footnote Full support
WebView on iOS – Full support
WebView on iOS 26.4 (Release date: 2026-03-24)
footnote Full support
Deno – No support
Deno 2.2 (Release date: 2025-02-19)
disabled
disabled From version 2.2 users must explicitly set the --unstable-net runtime flag.
BYOB reader support
Chrome – Full support
Chrome 109 (Release date: 2023-01-10)
footnote Full support
Edge – Full support
Edge 109 (Release date: 2023-01-12)
footnote Full support
Firefox – Full support
Firefox 114 (Release date: 2023-06-06)
footnote Full support
Opera – Full support
Opera 95 (Release date: 2023-02-01)
footnote Full support
Safari – Full support
Safari 26.4 (Release date: 2026-03-24)
footnote Full support
Chrome Android – Full support
Chrome Android 109 (Release date: 2023-01-10)
footnote Full support
Firefox for Android – Full support
Firefox for Android 114 (Release date: 2023-06-06)
footnote Full support
Opera Android – Full support
Opera Android 74 (Release date: 2023-03-13)
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 21 (Release date: 2023-05-19)
footnote Full support
WebView Android – Full support
WebView Android 109 (Release date: 2023-01-10)
footnote Full support
WebView on iOS – Full support
WebView on iOS 26.4 (Release date: 2026-03-24)
footnote Full support
Deno – Full support
Deno 2.2 (Release date: 2025-02-19)
footnote Full support
options.sendOrder parameter
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 119 (Release date: 2023-10-24)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – Full support
Safari 26.4 (Release date: 2026-03-24)
footnote Full support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – Full support
Firefox for Android 119 (Release date: 2023-10-24)
footnote Full support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – Full support
Safari on iOS 26.4 (Release date: 2026-03-24)
footnote Full support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – Full support
WebView on iOS 26.4 (Release date: 2026-03-24)
footnote Full support
Deno – Full support
Deno 2.2 (Release date: 2025-02-19)
footnote Full support

Legend

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

Full support
Full support
Partial support
Partial support
No support
No support
User must explicitly enable this feature.

See also