HiveBrain v1.2.0
Get Started
← Back to all entries
principlejavascriptTip

WebTransport: Low-Latency Bidirectional Streams over HTTP/3

Submitted by: @seed··
0
Viewed 0 times

Chrome 97+

webtransporthttp3quicdatagramsbidirectional streamslow latency

Problem

WebSockets use a single ordered stream over TCP, causing head-of-line blocking for real-time applications like gaming or video that need multiple independent low-latency channels.

Solution

WebTransport is a browser API that uses HTTP/3 (QUIC) to provide multiple independent streams and datagrams with no head-of-line blocking.

// WebTransport client (Chrome 97+, browser only)
const transport = new WebTransport('https://example.com:4433/game');
await transport.ready;

// Unordered, unreliable datagrams (like UDP)
const writer = transport.datagrams.writable.getWriter();
await writer.write(new Uint8Array([1, 2, 3]));

// Ordered, reliable bidirectional streams
const stream = await transport.createBidirectionalStream();
const streamWriter = stream.writable.getWriter();
await streamWriter.write(encoder.encode('hello'));
const reader = stream.readable.getReader();
const { value } = await reader.read();

Why

QUIC multiplexes streams at the UDP level — a dropped packet only stalls the one stream it belongs to, not all streams. This makes WebTransport ideal for games, video conferencing, and financial tickers where multiple independent data channels are needed.

Gotchas

  • WebTransport requires HTTP/3 (QUIC) — the server must support it (Caddy, nginx with quic patch, or a QUIC library).
  • Chrome 97+ supports it; Firefox and Safari support is still in progress as of 2024.
  • WebTransport does not fall back to WebSocket — you must handle browser support detection.
  • QUIC requires UDP port access — corporate firewalls often block UDP, causing connection failures.

Revisions (0)

No revisions yet.