Skip to content

Colyseus rooms

Multiplayer state is owned by a Colyseus room on the server. The template ships four (packages/editor/template/server/rooms/), registered in server/rooms.ts.

A server room owns authoritative state; clients receive it via the Callbacks API and send input up
A room owns authoritative state; clients sync via the Callbacks API.
RoomPurposeUsed by
ArenaRoomTag game with phases (lobby → countdown → playing → scoreboard), NPC bots, server-authoritative tag logicthird-person-arena, third-person-arena-game
TankRoomTank arena — server owns tank positions; clients send movement input; @colyseus/schema syncs statetanks
NotbloxRoomPhysics playground — server-authoritative player + box physicsnotblox
GameRoomA worked Schema-synced room (an orb-collecting arena) to start from

Each is a Room<State> using @colyseus/schema for the synced state. The client connects via the Callbacks API (onAdd / onChange / onRemove).

  1. Create packages/editor/template/server/rooms/{name}.ts with a Room<State> class and a @colyseus/schema state.
  2. Register it in server/rooms.ts.
  3. On the client, connect and subscribe via the StateReplication / Callbacks API; read live schema fields in onChange.
  4. Set serverRoom: '{name}' on the example’s registry entry.