Loading...
const wt = new WebTransport('https://example.com/game');
const writer = wt.datagrams.writable.getWriter();if ('WebTransport' in window) {
const wt = new WebTransport('https://example.com/game');
await wt.ready;
const writer = wt.datagrams.writable.getWriter();
} else {
connectWebSocket('wss://example.com/game');
}Feature detection adds a WebSocket fallback, and await wt.ready waits until the session is established.
WebTransport support and falls back to WebSocket.transport.ready and handles transport.closed errors.Small messages sent without delivery or order guarantees. They suit frequently updated state like player positions, where old data is useless.
Yes. The server must support HTTP/3 and WebTransport sessions; a regular WebSocket server cannot accept these connections.
Not for peer-to-peer media. WebTransport connects a client to a server, while WebRTC connects devices directly and handles audio and video.