WebTransport

WebTransport is a new transport protocol that allows for low-latency, bidirectional, and multiplexed communication between a client and a server. It is built on top of HTTP/3 and QUIC - which is built on top of UDP instead of TCP.

⚠️

Experimental - This WebTransport implementation hasn’t been battle tested. Please report any issues you may find - WebTransport is still an emerging technology and not widely available yet.

The underlying library is @fails-components/webtransport - a server-side implementation of HTTP3/WebTransport.

npm install --save @colyseus/h3-transport

Usage

app.config.ts
import config from "@colyseus/tools";
import { H3Transport } from "@colyseus/h3-transport"
 
export default config({
  // ...
  initializeTransport: function(options) {
    return new H3Transport({
      // more H3Transport options
      ...options,
    });
  },
 
  //
  // bind express routes
  //
  initializeExpress: (app) => {
 
    app.get("/hello", (req, res) => {
      res.json({ hello: "world!" });
    });
 
  },
  // ...
})

Available options

  • app: The Express app.
  • cert: Certificate contents (cert.pem)
  • key: Private key contents (key.pem)
  • secret: (?)
  • server: The http.Server instance to be used.
  • localProxy: (optional) Fallback every URL through the this local proxy.
Last updated on