ServerTransportBun WebSockets

Bun WebSockets

⚠️

Bun support in version 0.17 is broken at the moment. We need to upgrade bun-serve-express to support Express v5 only moving forward.

Bun support on Colyseus is still experimental. Please report any issues you may find.

Installation

Terminal
bun add @colyseus/bun-websockets
app.config.ts
import { defineServer } from "colyseus";
import { BunWebSockets } from "@colyseus/bun-websockets"
 
const server = defineServer({
  // ...
  transport: new BunWebSockets({
    /* Bun.serve options */
  }),
 
  //
  // BunWebSockets comes with Express compatibility layer.
  //
  express: (app) => {
    // register routes
    app.get("/hello", (req, res) => {
      res.json({ hello: "world!" });
    });
  },
  // ...
});