Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

WebTransport

WebTransport is a browser-first transport next to WebSocket. The SDKs speak the same FastPubSub frames on one bidirectional stream. Optional unidirectional subscribe lines exist (:U: / :D:).

Today:

  • JavaScript: real browser WebTransport (not a stub).
  • Rust: real client behind the webtransport feature.
  • Node.js: not supported unless a WebTransport global exists.

Not today:

  • Unreliable datagrams for games (planned as a GameDev idea, not the current transport).
  • Node.js production support.

JavaScript

const client = await session.webTransport(accessToken).build();

Subscribe options can select unidirectional delivery where the edge supports it. See the SDK changelog for wtDelivery.

Rust

#![allow(unused)]
fn main() {
use fastpubsub_sdk::client::{open, FastPubSub};
use fastpubsub_sdk::transport::WebTransport;

let mut session = open("globaltest");
session.resolve_edge().await?;

let mut client: FastPubSub<WebTransport> =
    session.web_transport(access_token)?.build().await?;
}

Keep the WebTransport endpoint object alive for the whole session.

Lab-only: FASTPUBSUB_WT_INSECURE=1 skips certificate checks. Do not use that in production.

Token rights

Access tokens can restrict protocols with allow_protocols (websocket, webtransport). They can also cap ingress_kb_per_sec and egress_kb_per_sec.

If you only need WebSocket, leave protocol rights unset (both allowed) or list websocket only.

When to use it

Use WebTransport in browsers when you want QUIC/HTTP3 to the edge and multiple independent streams without WebSocket head-of-line blocking. Keep WebSocket as the default for Node.js and as a fallback for networks that interfere with UDP.