Brewser Docs
Multiplayer

Multiplayer

Real-time rooms, shared state and presence for Brewser apps

Brewser apps can talk to each other in real time. The platform runs a small WebSocket service at wss://ws.brewser.io that groups clients into rooms, relays messages between them, tracks who is connected, and keeps a small piece of shared state for the room.

That is enough to build multiplayer games, co-op experiences, chat, shared whiteboards, live dashboards and second-screen controllers, without running a server of your own.

How it fits together

Every connection belongs to an app and a room. Clients in the same app and room see each other; clients in different rooms are isolated.

App → Room → Clients

Messages travel on three channels:

ChannelWhat it carries
systemConnection handshake, presence (join/leave), member lists, errors
appYour own events: player_move, chat_message, game_start, whatever you define
stateA small shared JSON object with revision numbers and optional single-owner authority

Start here

  • WebSockets Quick Start: the full guide, from your first connection to shared state, presence, reconnect handling and the service limits.

Things to know first

It's standard WebSocket, not a Brewser API. There is no brewser.* global involved, so the same code runs in Chrome. This keeps to the platform's compatibility promise.

  • Room state is in-memory. Rooms live at most 12 hours, empty rooms are reclaimed, and a server restart clears everything. For anything that must persist, use Saves & Leaderboards.
  • Declare the host when you publish. A published app that connects must list wss://ws.brewser.io in its manifest's allowed_origins, alongside the network capability. The security scanner checks this.
  • Test on hardware. Emulators generally have no working internet, so real-time features can't be validated there. See Emulators.

On this page