WebTransport
The WebTransport interface of the WebTransport API provides functionality to enable a user agent to connect to an HTTP/3 server, initiate reliable and unreliable transport in either or both directions, and close the connection once it is no longer needed.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 97 | 97 | 114 | 26.4 | 97 | 26.4 | |
byob_readers BYOB reader support | 109 | 109 | 114 | 26.4 | 109 | 26.4 |
| The close() method of the WebTransport interface closes an ongoing WebTransport session. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
| The closed read-only property of the WebTransport interface returns a promise that resolves when the transport is closed. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
| The congestionControl read-only property of the WebTransport interface indicates the application's preference for either high throughput or low-latency when sending data. | | | 114 | 26.4 | | 26.4 |
| The createBidirectionalStream() method of the WebTransport interface asynchronously opens and returns a bidirectional stream. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
createBidirectionalStream (options sendOrder parameter) `options.sendOrder` parameter | | | 119 | 26.4 | | 26.4 |
| The createUnidirectionalStream() method of the WebTransport interface asynchronously opens a unidirectional stream. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
createUnidirectionalStream (byob readers) BYOB reader support | 109 | 109 | 114 | 26.4 | 109 | 26.4 |
createUnidirectionalStream (options sendOrder parameter) `options.sendOrder` parameter | | | 119 | 26.4 | | 26.4 |
| The datagrams read-only property of the WebTransport interface returns a WebTransportDatagramDuplexStream instance that can be used to send and receive datagrams — unreliable data transmission. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
| The getStats() method of the WebTransport interface asynchronously returns an object containing HTTP/3 connection statistics. | | | 114 | 26.4 | | 26.4 |
| The incomingBidirectionalStreams read-only property of the WebTransport interface represents one or more bidirectional streams opened by the server. Returns a ReadableStream of WebTransportBidirectionalStream objects. Each one can be used to reliably read data from the server and write data back to it. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
| The incomingUnidirectionalStreams read-only property of the WebTransport interface represents one or more unidirectional streams opened by the server. Returns a ReadableStream of WebTransportReceiveStream objects. Each one can be used to reliably read data from the server. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
| The ready read-only property of the WebTransport interface returns a promise that resolves when the transport is ready to use. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
| The reliability read-only property of the WebTransport interface indicates whether the connection supports reliable transports only, or whether it also supports unreliable transports (such as UDP). | | | 114 | 26.4 | | 26.4 |
| The WebTransport() constructor creates a new WebTransport object instance. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
WebTransport (options allowPooling parameter) `options.allowPooling` parameter | | | 114 | 26.4 | | 26.4 |
WebTransport (options congestionControl parameter) `options.congestionControl` parameter | | | 114 | 26.4 | | 26.4 |
WebTransport (options requireUnreliable parameter) `options.requireUnreliable` parameter | | | 114 | 26.4 | | 26.4 |
WebTransport (options serverCertificateHashes parameter) `options.serverCertificateHashes` parameter | 100 | 100 | 125 | 26.4 | 100 | 26.4 |
| The WebTransportBidirectionalStream interface of the WebTransport API represents a bidirectional stream created by a server or a client that can be used for reliable transport. Provides access to a WebTransportReceiveStream for reading incoming data, and a WebTransportSendStream for writing outgoing data. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
| The readable read-only property of the WebTransportBidirectionalStream interface returns a WebTransportReceiveStream instance that can be used to reliably read incoming data. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
readable (returns WebTransportReceiveStream) Returns `WebTransportReceiveStream` (earlier spec returned `ReadableStream`) | | | 114 | 26.4 | | 26.4 |
| The writable read-only property of the WebTransportBidirectionalStream interface returns a WebTransportSendStream instance that can be used to write outgoing data. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
writable (returns WebTransportSendStream) Returns `WebTransportSendStream` (earlier spec returned `WritableStream`) | | | 114 | 26.4 | | 26.4 |
| The WebTransportDatagramDuplexStream interface of the WebTransport API represents a duplex stream that can be used for unreliable transport of datagrams between client and server. Provides access to a ReadableStream for reading incoming datagrams, a WritableStream for writing outgoing datagrams, and various settings and statistics related to the stream. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
byob_readers BYOB reader support | 109 | 109 | | 26.4 | 109 | 26.4 |
| The incomingHighWaterMark property of the WebTransportDatagramDuplexStream interface gets or sets the high water mark for incoming chunks of data — this is the maximum size, in chunks, that the incoming ReadableStream's internal queue can reach before it is considered full. See Internal queues and queuing strategies for more information. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
| The incomingMaxAge property of the WebTransportDatagramDuplexStream interface gets or sets the maximum age for incoming datagrams, in milliseconds. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
| The maxDatagramSize read-only property of the WebTransportDatagramDuplexStream interface returns the maximum allowable size of outgoing datagrams, in bytes, that can be written to WebTransportDatagramDuplexStream.writable. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
| The outgoingHighWaterMark property of the WebTransportDatagramDuplexStream interface gets or sets the high water mark for outgoing chunks of data — this is the maximum size, in chunks, that the outgoing WritableStream's internal queue can reach before it is considered full. See Internal queues and queuing strategies for more information. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
| The outgoingMaxAge property of the WebTransportDatagramDuplexStream interface gets or sets the maximum age for outgoing datagrams, in milliseconds. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
| The readable read-only property of the WebTransportDatagramDuplexStream interface returns a ReadableStream instance that can be used to unreliably read incoming datagrams from the stream. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
| The WebTransportError interface of the WebTransport API represents an error related to the API, which can arise from server errors, network connection problems, or client-initiated abort operations (for example, arising from a WritableStream.abort() call). | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
| The source read-only property of the WebTransportError interface returns an enumerated value indicating the source of the error. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
| The streamErrorCode read-only property of the WebTransportError interface returns a number in the range 0-255 indicating the application protocol error code for this error, or null if one is not available. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
| The WebTransportError() constructor creates a new WebTransportError object instance. | 97 | 97 | 114 | 26.4 | 97 | 26.4 |
| The WebTransportReceiveStream interface of the WebTransport API is a ReadableStream that can be used to read from an incoming unidirectional or bidirectional WebTransport stream. | | | 114 | 26.4 | | 26.4 |
| The getStats() method of the WebTransportReceiveStream interface asynchronously returns an object containing statistics for the current stream. | | | 114 | 26.4 | | 26.4 |
| The WebTransportSendStream interface of the WebTransport API is a specialized WritableStream that is used to send outbound data in both unidirectional or bidirectional WebTransport streams. | | | 114 | 26.4 | | 26.4 |
| The getStats() method of the WebTransportSendStream interface asynchronously returns an object containing statistics for the current stream. | | | 114 | 26.4 | | 26.4 |
getWriter | | | 114 | 26.4 | | 26.4 |
| The sendOrder property of the WebTransportSendStream interface indicates the send priority of this stream relative to other streams for which the value has been set. | | | 121 | 26.4 | | 26.4 |
- This browser only partially implements this feature
- Returns a `WritableStream` instead of a `WebTransportSendStream`.
- This browser only partially implements this feature
- Method is defined but throws a not-implemented error.
Syntax
async function initTransport(url) {
// Initialize transport connection
const transport = new WebTransport(url);
// The connection can be used once ready fulfills
await transport.ready;
return transport;
} Use cases
-
Using WebTransport
The WebTransport interface of the WebTransport API provides functionality to enable a user agent to connect to an HTTP/3 server, initiate reliable and unreliable transport in either or both directions, and close the connection once it is no longer needed.
Cautions
- May not be supported in older browsers.
Implementation notes
- Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.