Skip to main content
Stores are schema-driven key-value stores that sync across all connected clients in real time. Define a schema, and the SDK gives you fully typed CRUD operations with automatic validation and real-time change events. Access stores via client.stores.<storeName>.
Editors can write stores. Viewers receive store updates and can read stores, but set, update, and delete are blocked for viewer sessions.

Schema Definition

Define your store schemas using defineStores() from @collab-kit/utils and pass to the client constructor:

Methods

Add Entry

set({ key, value }) Create or overwrite an entry. Required fields (without defaults) must be provided:

Get Entry

get({ key }) Fetch a single entry by key. Returns null if the key doesn’t exist:

Get All Entries

getAll() Fetch all entries in the store:

Update Entry

update({ key, value }) Partially update an existing entry. Only the provided fields are validated and merged:

Delete Entry

delete({ key }) Delete an entry by key:

Sync Store

sync() Force a full sync of the store from the server:

Events

You can listen to changes made to a store like so:
Store events fire for changes made by other clients. Your own set/update/delete calls resolve with the new value directly.

Validation

The client validates values against the schema before sending them to the server:
  • set: All required fields (without default) must be provided. Default values are applied for missing fields that have defaults.
  • update: Only provided fields are validated against their schema types.
  • Type checking: Values must match the declared type (string, number, or boolean).
If validation fails, the operation throws an error before making a network request.

Examples

Task Store