Skip to Content

Client: Rooms

Rooms group connections together. Use them to organize users, broadcast messages, or track who is present in a shared context.

Joining a room

Use client.joinRoom(...) to join a room. This also supports optional presence tracking:

// Just join const { , } = await .("lobby"); if () { .("Current members:", ); }
// Join and receive presence updates const { , } = await .("lobby", () => { if (. === "join") { .("User joined:", .); } else if (. === "leave") { .("User left:", .); } });
💡

The present array always reflects current members in the room at time of join, even if you don’t subscribe to presence updates.

Leaving a room

Use client.leaveRoom(...) to exit:

await .("lobby");

If you joined with presence tracking, it will be automatically unsubscribed.

Use cases

  • Shared chat rooms
  • Multiplayer game lobbies
  • Collaborative workspaces
  • Audio/video channels

Rooms are lightweight, real-time groupings. Combine with presence for full user visibility.

Last updated on
© 2025