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 usingdefineStores() 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: Allrequiredfields (withoutdefault) 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, orboolean).