Skip to main content
A room is the virtual container. All users, presence, stores, comments, and files are scoped to a room. The Room module provides access to the current room’s details.

Room Lifecycle

Rooms are created via the REST API and cannot be created from the client SDK. The typical flow is:
  1. Your backend creates a room via POST /rooms
  2. Your backend adds a user via POST /users, gets a JWT token
  3. The client SDK connects and joins the room using the JWT token
  4. The room tracks participants, presence, and all collaboration state Users can join as an editor or viewer:
    Roles are session-scoped. Editors are active collaborators and appear in client.users.active; viewers receive realtime updates and can follow users, but cannot write collaboration state. After connecting and joining, room information is available using:
    You can also fetch the current room’s details from the server:
    This method returns room details. Use client.users.list(...) for paginated users and client.users.active for active editors.

Connection Lifecycle

The client exposes low-level connection events via client.socket. Use these to monitor connection state, handle disconnections, and implement custom reconnection logic like so:

Lifecycle Events

Auto-Reconnection

The SDK automatically reconnects when the WebSocket connection drops unexpectedly. It uses exponential backoff with configurable parameters:
  • Reconnection starts immediately after disconnection
  • Each subsequent attempt waits longer (exponential backoff)
  • After all attempts are exhausted, the failed event fires

Pre-Reconnect Hooks (Optional)

Register a handler that runs before each reconnection attempt. Use this to refresh tokens or perform setup before reconnecting:

Connection States

The connection transitions through these states:

Examples

Offline Queue

Buffer actions while offline and replay them on reconnect: