web-transport-ws

Crates.ioweb-transport-ws
lib.rsweb-transport-ws
version0.2.3
created_at2025-09-03 19:18:37.848607+00
updated_at2026-01-24 00:09:36.501884+00
descriptionWebTransport polyfill using WebSockets
homepage
repositoryhttps://github.com/moq-dev/web-transport
max_upload_size
id1823071
size123,196
Luke Curley (kixelated)

documentation

README

WebTransport Polyfill

A WebTransport polyfill that uses WebSocket as the underlying transport, with implementations in both Rust and TypeScript/JavaScript.

Wire Protocol

Both implementations use the same QUIC-like frame encoding over WebSocket:

  • Variable-length integer encoding (VarInt)
  • Stream multiplexing with bidirectional and unidirectional streams
  • Frame types: STREAM, RESET_STREAM, STOP_SENDING, etc.

This is a simplified version of QMux, which might be used in the future.

JavaScript/TypeScript Usage

Check if WebTransport is available, otherwise install the polyfill:

import { install } from "@moq/web-transport-ws"

// Install the polyfill if needed.
install();

// Now WebTransport is available even in Safari
const transport = new WebTransport("https://example.com/path")

URLs are automatically rewritten with the WebSocket protocol:

  • https://example.com/pathwss://example.com/path

Building

Rust

cargo build

TypeScript/JavaScript

npm install
npm run build

Usage

cargo run --example server
bun examples/client.ts
deno -A --sloppy-imports examples/client.ts

Bundle TypeScript source to single JavaScript file

bun build --target=node --outfile=examples/client.js examples/client.ts 
node examples/client.js

License

MIT OR Apache-2.0

Commit count: 208

cargo fmt