const url = "https://example.com:4999/webtransport";
async function connect() {
// WebTransport itself may be unavailable, so check before reading the static property
if (typeof WebTransport === "undefined") {
console.log("WebTransport is not supported in this browser.");
return;
}
// Without reliable-only support, the session needs HTTP/3,
// so it fails on networks that block UDP
if (!WebTransport.supportsReliableOnly) {
console.log("This browser can't fall back to a reliable-only session.");
}
const transport = new WebTransport(url);
try {
await transport.ready;
console.log("Connected");
} catch (error) {
console.error("Connection failed:", error);
}
}
connect();WebTransport: supportsReliableOnly static property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.