Client
API reference for @waits/lively-client — the low-level TypeScript client for connecting to a Lively server, managing rooms, presence, cursors, storage, and real-time events.
LivelyClient
The main entry point. Create one client per app, then join rooms through it.
Constructor:
joinRoom(roomId, options) — connects to a room and returns a Room instance:
Other methods:
Room
Returned by client.joinRoom(). Holds all real-time state for a single room — presence, cursors, storage, events, and history.
Presence
Cursors
Storage
Events
Follow Mode
Live State
Lightweight key-value state synced via last-write-wins (not CRDT). Good for ephemeral UI state like viewport position.
History (Undo / Redo)
History works with room.batch() — batched mutations are undone/redone as a single unit.
Connection
ConnectionManager
Handles WebSocket lifecycle internally. You rarely use this directly — Room wraps it. Supports auto-reconnect with exponential backoff, heartbeats, and connection timeouts.
ActivityTracker
Detects idle and active users by listening for DOM events (mousemove, keydown, pointer, visibility). Transitions through online → away → offline. Used internally by Room.
Utilities
Re-exported for convenience.
Types
Configuration:
ClientConfig— { serverUrl, reconnect?, maxRetries?, WebSocket? }JoinRoomOptions— { userId, displayName, cursorThrottleMs?, initialStorage?, inactivityTime?, offlineInactivityTime?, token? }RoomConfig— full room config (used internally)ConnectionConfig— { url, reconnect?, maxRetries?, baseDelay?, maxDelay?, heartbeatIntervalMs?, connectionTimeoutMs? }ActivityTrackerConfig— { inactivityTime?, offlineInactivityTime?, pollInterval? }
Runtime:
ConnectionStatus— "connected" | "connecting" | "reconnecting" | "disconnected"OnlineStatus— "online" | "away" | "offline"PresenceUser— { userId, displayName, onlineStatus, location?, metadata?, joinedAt }CursorData— { userId, x, y, viewportPos?, viewportScale? }