@collab-kit/client package is a browser SDK. It connects to your server over WebSocket and provides modules for users, rooms, presence, stores, comments, broadcasts, file storage, and CRDT collaboration.
Installation
@collab-kit/utils is a peer dependency that provides shared types and the defineStores() utility. Install it alongside the client.Initialization
Constructor Options
Base HTTP(S) URL of your CollabKit server. The SDK automatically derives the WebSocket URL from this.
JWT token returned when creating a user via
POST /users. Contains the accountId, userId, and roomId.(Optional) You must pre-define store schemas with
defineStores(). during initialization. Each client instance has access to the stores that are passed to it during initialization.User Lifecycle
Joining a CollabKit room is a two step process.Step 1: connect()
After
connect() resolves:
- The socket is open and authenticated
- User and room data is available via
client.usersandclient.currentRoom - You can listen for user events, but the current user is still
offline
Step 2: join()
online in the room and notifies other participants. After
join() resolves:
- User now has access to all features: Stores, Brodcasts, Presence and more.
- User is now online and visible to other members connected to the room.
Step 3: disconnect()
Modules
The client provides access to collaboration features through modules:| Module | Property | Description |
|---|---|---|
| Users | client.users | Track all users in the room |
| Room | client.room | Room operations and connection lifecycle |
| Presence | client.presence | Ephemeral state (cursors, selections) |
| Broadcasts | client.notifications | Custom event broadcasting |
| Stores | client.stores | Schema-driven KV stores |
| Comments | client.comments | Threaded comments |
| Storage | client.storage | File upload and management |
Next Steps
Client SDK Reference
Full API reference for all SDK modules.
Guides & Examples
Build a cursor tracking experience and more.