WebTransport
medium 30 minWebTransport gives a browser and a server one encrypted HTTP/3 session that carries many independent reliable streams and also datagrams that may be lost.
Video lesson · Chapter 1 of 5
Enter a live match over HTTP/3
Theory
Read or listen first. About 2 min.
What it is
WebTransport is a browser API and a protocol for two-way communication between a client and a server. It runs over HTTP/3, and HTTP/3 runs over QUIC, a transport built on UDP with encryption included.
One session offers three kinds of channel. A bidirectional stream carries bytes both ways. A unidirectional stream carries bytes one way. Both are reliable and ordered. A datagram is one small packet that is sent once: it may be lost, and it may arrive out of order.
Why it exists
A WebSocket is one ordered pipe over TCP. If a packet is lost, everything behind it waits for the resend, even a message that has nothing to do with the lost one. For a player's position sent 60 times a second, the resent position is already out of date.
Applications that needed lossy delivery in a browser used WebRTC data channels, which bring a peer-to-peer connection setup that a plain client and server do not need. WebTransport offers the same two choices, reliable or latest, to an ordinary HTTPS server.
A short history
May 2021
QUIC is published as RFC 9000: encrypted, multiplexed streams over UDP, with connections identified by an ID instead of by addresses alone.
January 2022
Chrome 97 ships the WebTransport API in a stable release.
March 2022
RFC 9221 adds unreliable DATAGRAM frames to QUIC.
June 2022
HTTP/3 is published as RFC 9114. Two months later RFC 9297 defines HTTP datagrams and the capsule protocol that WebTransport builds on.
June 2023
Firefox 114 adds WebTransport.
March 2026
Safari 26.4 adds it, and MDN marks the API as Baseline: newly available in the latest versions of all major browsers.
Words to know
- Session
- One WebTransport connection to one URL. It lives as long as the HTTP/3 CONNECT stream that opened it.
- Stream
- A reliable, ordered sequence of bytes inside the session. Streams do not wait for one another.
- Datagram
- One small packet, sent once, not resent, not ordered, and too small to be split.
- Head-of-line blocking
- Data that has arrived waits because something sent earlier has not.
- Extended CONNECT
- The HTTP request that turns one HTTP/3 stream into a WebTransport session.
- Draining
- The server asks the client to finish its work and reconnect elsewhere.
- Connection ID
- The label QUIC uses to recognise a connection after the client's address changes.
How it works
Step through the idea, or press Play.
Open one session. QUIC handshake, then an extended CONNECT to an HTTPS URL
Understand it
Start here
The ferry landing
Picture a lake with a village on one shore and a fair on the other. The village has several jetties, and there are flat stones for skipping across the water.
One landing, many ways across, and each load takes the one that suits it.
The layers
What it is built on
One session, two kinds of delivery
From the wire up
| Layer | What it gives you |
|---|---|
| UDP | Packets between two addresses, with no promises |
| QUIC | TLS 1.3 encryption, streams, datagrams, loss recovery, congestion control, connection IDs |
| HTTP/3 | URLs, headers, status codes, and the CONNECT request |
| WebTransport | A session with streams and datagrams, and the browser's security rules |
| Your protocol | Message boundaries, types, acknowledgements, reconnect |
The specification of the wire format is still an IETF draft: version 17, dated 2 November 2026, is in working group last call. The browser API is a W3C document. Server libraries implement particular drafts, so check that your library and your browsers meet on one.
Connecting
How a session opens
Handshake and first data
Round trips before the session is ready
Channels
Streams and datagrams
Bidirectional stream
Reliable and ordered, both ways. Either side may open it. Chat, requests and replies, game events.
Unidirectional stream
Reliable and ordered, one way. Server news and leaderboards, client uploads and telemetry batches.
Datagram
Sent once. May be lost, late or out of order. Positions, cursors, live sensor values.
Stream per message
Streams are cheap to open. One stream per message makes each message independent, and a late one can be cancelled.
What each channel promises
| Stream | Datagram | |
|---|---|---|
| Delivery | Resent until it arrives, or the stream is reset | Once, may be lost |
| Order | Inside the stream only | None |
| Size | Any number of bytes | One packet, read maxDatagramSize |
| Boundaries | None: a byte stream | Kept: one write, one datagram |
| Flow control | Per stream and per session | None, but queues drop |
| Congestion control | Yes | Yes, shared with streams |
Loss
Why independence matters
One lost packet, three designs
How many updates get stuck behind one loss
With 2% independent loss, 60 datagrams a second lose about a second. Two losses in a row happen for about of pairs. Real loss comes in bursts, so measure yours, and send the last few inputs in each datagram if a short gap must not be noticed.
Choosing
Which channel for which data?
Pick a channel
Use it when
- Multiplayer games that mix events and positions
- Low-latency video or audio to and from your own servers
- Live collaboration with edits and cursors
- You need reliable and lossy channels together
- Clients move between networks
- Updates come 60 or more times a second
Avoid it when
- A simple chat: WebSocket is simpler
- You must support browsers from before March 2026 without a fallback
- Your servers or load balancers cannot speak HTTP/3
- Data only flows from server to client: Server-Sent Events
- Client networks block UDP
- Calls between browsers: WebRTC
Against the alternatives
| Strength | Cost | Best for | |
|---|---|---|---|
| WebTransport | Streams and datagrams to a server | HTTP/3 servers, your own framing, a fallback | Games, live media, dense updates |
| WebSocket | Simple messages, available everywhere | One ordered pipe over TCP | Chat, notifications, dashboards |
| Server-Sent Events | Plain HTTP, reconnects by itself | One way, text | Feeds, progress |
| WebRTC | Peer to peer, media codecs, echo cancelling | ICE, STUN and TURN setup | Video calls, file sharing between peers |
| gRPC-Web | Typed calls from generated code | A proxy, no client streaming in browsers | Structured APIs |
The API
Using it in a browser
const transport = new WebTransport("https://game.example.com:443/match", { requireUnreliable: true, // refuse a fallback to HTTP/2 congestionControl: "low-latency", // a hint, the browser may ignore it});await transport.ready; // rejects if the session is refused// Must arrive: one stream, with our own framingconst stream = await transport.createBidirectionalStream();const events = stream.writable.getWriter();await events.write(frame({ type: "join", player: "p-123" }));// Only the newest mattersconst out = transport.datagrams.createWritable ? transport.datagrams.createWritable() : transport.datagrams.writable; // older Chrome and Firefoxconst positions = out.getWriter();positions.write(encodePosition(seq++, x, y)).catch(() => {});// Streams the server opensfor await (const s of transport.incomingUnidirectionalStreams) readNews(s);maxDatagramSize before writing.datagrams.writable is deprecated and Safari never had it; createWritable() is the current form (Chrome 159, Firefox 155, Safari 26.4). Iterating a stream with for await is also newer than the API itself, so read with getReader() if you support older versions.
A session's life
- 1
Create
new WebTransport(url)with an HTTPS URL that names the port.options.protocolsoffers application protocol names, and the server picks one. - 2
Ready
transport.readyresolves when the server accepts. Streams opened by the server show up inincomingBidirectionalStreamsandincomingUnidirectionalStreams. - 3
Draining
transport.drainingresolves when the server asks you to leave. Open a new session, move over, then close the old one. - 4
Closed
transport.closedresolves after a clean close and rejects after a failure. Either way all streams of the session are gone.
Networks
Moving, blocking and falling back
QUIC recognises a connection by its connection ID, so a connection can go on when a phone moves from Wi-Fi to mobile data and gets a new address. The client probes the new path and the server checks that it answers before sending much. This works only if every box in front of the server also routes by connection ID. Treat it as a bonus: your client must still be able to reconnect and resume.
Connect with a fallback
Running it
Servers, limits and operations
Two session servers behind one address
What to decide before launch
| Topic | Decide | Why |
|---|---|---|
| Load balancing | UDP, by connection ID if you can | An address change must not land on a server that does not know the session |
| Deploys | Send drain, wait, then close | Sessions are long; a hard restart drops everyone at once |
| Reconnects | Backoff with jitter | Thousands of clients returning together is a thundering herd |
| State | Resume token and last sequence number | All streams die with the session |
| Limits | Streams per session, bytes per second, sessions per user | An open session is cheap for the sender and not for you |
| Security | Check Origin, authenticate, validate every datagram | The browser sends Origin; the server must check it |
| Monitoring | Share of fallback, handshake failures, datagram loss, round trip | They tell you which networks block UDP |
Certificates are the normal HTTPS ones. For test servers and short-lived machines, serverCertificateHashes accepts a certificate by its hash if it is valid for less than two weeks and uses an ECDSA key. For credentials, prefer a short-lived token in the first message or in the headers option where supported; a token in the URL ends up in logs.
Costs: no licence is involved, the protocol and the common libraries are open. You pay in CPU (QUIC encryption runs in your process), in memory per open session, and in the work of a second transport for the fallback.
Trade-offs
Pros and cons
Pros
- Multiple streams in one connection
- Datagrams for data that expires
- No blocking between streams when a packet is lost
- Connection migration where the path supports it
- Short setup: encryption is part of the first round trip
- Always encrypted: TLS 1.3 is part of QUIC
Cons
- New in Safari: only since 26.4
- Server needs HTTP/3 and so does every proxy in the path
- More to write: framing, sequence numbers, reconnect
- UDP may be blocked by firewalls
- No practical fallback built in
- Young ecosystem: the wire format is still a draft
Summary
The whole topic in one minute.
WebTransport is for data with different needs on one connection: messages that must arrive go on streams, and updates that are replaced by the next one go in datagrams. A loss on one stream never delays another.
It needs an HTTP/3 server, a path that lets UDP through, and your own framing, reconnect and fallback. If one ordered pipe is enough, a WebSocket is simpler and reaches more places.
- One HTTP/3 session: many independent reliable streams, plus datagrams that may be lost.
- Streams for what must arrive, datagrams for what the next one replaces.
- Streams are bytes: add message lengths. Datagrams are small and unordered: add sequence numbers.
- About 2 round trips to ready, against about 3 for a WebSocket.
- Plan for blocked UDP, drains, reconnects and checks of Origin.