Skip to main content
The @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

serverUrl
string
required
Base HTTP(S) URL of your CollabKit server. The SDK automatically derives the WebSocket URL from this.
authToken
string
required
JWT token returned when creating a user via POST /users. Contains the accountId, userId, and roomId.
stores
[StoresConfig](/types/stores#storesconfig)
(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

Step 1: join()

join() is the single entry point. It opens the WebSocket (if not already open), authenticates with the server using the JWT token, sets the current user as online, loads active editors, comments, and stores, and notifies other participants when this session is an editor.
After join() resolves:
  • client.users.active is populated with active editors, excluding self
  • client.users.all remains empty until you call client.users.list(...)
  • client.currentUser and client.currentRoom are set
  • Comments and stores are hydrated
  • Editors can write collaboration state; viewers receive updates and can follow users
Join as a viewer when the user should not collaborate directly:

Step 2: disconnect()

Gracefully disconnects. Notifies other participants before closing the socket.
Call disconnect() in the beforeunload event to notify peers when the tab closes:

Modules

The client provides access to collaboration features through modules:

Next Steps

Client SDK Reference

Full API reference for all SDK modules.

Guides & Examples

Build a cursor tracking experience and more.