AI agents: fetch the documentation index at llms.txt. Markdown versions are available by appending .md to any page URL, including this page's markdown.
Quick start
Build a sync-enabled React app in five steps.
Build a local-first React app with real-time sync, offline support, and undo/redo.
Skip the manual setup? Scaffold a complete app:
npx skills add
mblode/stratasync
Step 1: Define your model
@ClientModel registers a class with the sync engine. @Property marks each synced field.
// models/task.tsimport { Model, ClientModel, Property } from "@stratasync/core";@ClientModel("Task", { loadStrategy: "instant" })export class Task extends Model { // Use `declare` so TypeScript skips initializer code for decorated properties @Property() declare id: string; @Property() declare title: string; @Property() declare status: string; @Property() declare completed: boolean;}
Step 2: Create the sync client
Wire up storage, transport, and reactivity.
// lib/sync-client.tsimport { createSyncClient } from "@stratasync/client";import { createMobXReactivity } from "@stratasync/mobx";import { createIndexedDbStorage } from "@stratasync/storage-idb";import { createGraphQLTransport } from "@stratasync/transport-graphql";// Import the model so it registers with ModelRegistryimport "../models/task";const storage = createIndexedDbStorage({ name: "my-app",});const transport = createGraphQLTransport({ endpoint: "/api/graphql", syncEndpoint: "/api/sync", wsEndpoint: "wss://api.example.com/sync/ws", auth: { getAccessToken: async () => "token" },});const reactivity = createMobXReactivity();export const client = createSyncClient({ storage, transport, reactivity, // Apply mutations locally before server confirmation optimistic: true, // Group rapid mutations into a single network request batchMutations: true, batchDelay: 50,});
Step 3: Wrap your app with SyncProvider
SyncProvider starts sync on mount and stops on unmount.
// app/providers.tsx"use client";import { SyncProvider } from "@stratasync/react";import { client } from "../lib/sync-client";export function Providers({ children }: { children: React.ReactNode }) { return ( <SyncProvider client={client} autoStart autoStop> {children} </SyncProvider> );}