Skip to main content
This guide shows you how to use CollabKit’s Stores module to build a shared task board where all changes are synced in real time across connected clients.

What You’ll Build

  • A shared task list with real-time sync
  • Type-safe store operations with schema validation
  • Live update rendering when other users make changes

Prerequisites

  • A CollabKit server running with a room and users created
  • @collab-kit/client and @collab-kit/utils installed

Step 1: Define Your Schema

Create a schema using defineStores(). This gives you full type safety and validation:

Schema Rules

  • required: true — field must be present when calling set() (unless it has a default)
  • default: value — applied automatically when the field is missing on set()
  • Fields without required: true become optional in TypeScript types

Step 2: Initialize the Client with Stores

Store writes require an editor session. Viewers can read stores and receive realtime store updates, but cannot call set, update, or delete.

Step 3: Create, Read, Update, Delete

Step 4: Listen for Real-Time Changes

Store events fire when other clients make changes:

Step 5: Build the Task Board UI

Multiple Stores

You can define multiple stores for different data types:

Syncing on Reconnect

When the client reconnects after a network interruption, call sync() to reload the latest state:

Next Steps

  • Add comments to individual tasks
  • Use presence to show which task a user is viewing
  • Set up webhooks to notify external services when tasks change