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.
Configuration
SyncClientOptions reference for configuring the Strata Sync client.
Pass SyncClientOptions to createSyncClient.
Quick example
import { createSyncClient } from "@stratasync/client";
const client = createSyncClient({
// Required adapters
storage: storageAdapter,
transport: transportAdapter,
reactivity: reactivityAdapter,
// Optional
dbName: "my-app-sync",
userId: "user-123",
version: 1,
userVersion: 1,
groups: ["workspace-abc"],
optimistic: true,
batchMutations: true,
batchDelay: 50,
bootstrapMode: "auto",
rebaseStrategy: "server-wins",
fieldLevelConflicts: true,
});Required adapters
storage
Type: StorageAdapter
Local persistence for model rows, metadata, the outbox, partial indexes, and sync actions.
import { createIndexedDbStorage } from "@stratasync/storage-idb";
const storage = createIndexedDbStorage();The StorageAdapter interface defines methods for:
get,getAll,put,delete: basic CRUD for model rowsgetByIndex: indexed lookupsgetMeta,setMeta: sync metadata (last sync ID, schema hash, and more)getOutbox,addToOutbox,removeFromOutbox: pending transaction persistencehasPartialIndex,setPartialIndex: partial model index trackingaddSyncActions,getSyncActions,clearSyncActions: sync action logwriteBatch: batch write operationsclear,count: storage management
transport
Type: TransportAdapter
Server communication: bootstrap, delta subscriptions, batch mutations, and connection state.
import { createGraphQLTransport } from "@stratasync/transport-graphql";
const transport = createGraphQLTransport({
endpoint: "https://api.example.com/graphql",
syncEndpoint: "https://api.example.com/sync",
wsEndpoint: "wss://api.example.com/sync/ws",
auth: { getAccessToken: async () => "token" },
});The TransportAdapter interface defines:
bootstrap(options): stream initial data asAsyncGenerator<ModelRow>batchLoad(options): lazy-load models by indexmutate(batch): submit transaction batchessubscribe(options): real-time delta subscriptionfetchDeltas(after, limit?): poll for missed deltasgetConnectionState(): current connection stateonConnectionStateChange(callback): subscribe to connection changesclose(): clean up resources
reactivity
Type: ReactivityAdapter
Makes identity map entries observable for UI re-rendering.
import { createMobXReactivity } from "@stratasync/mobx";
const reactivity = createMobXReactivity();Simple options
All optional.
| Option | Type | Default | Description |
|---|---|---|---|
dbName | string | "sync-db" | Database name for storage. Each unique name creates a separate IndexedDB database. |
userId | string | - | Logged-in user ID. Used for storage isolation in multi-user scenarios. |
version | number | - | Client version for storage naming. Incrementing triggers a fresh bootstrap. |
userVersion | number | - | Per-user version for storage naming. Incrementing triggers a fresh bootstrap. |
groups | string[] | - | Sync groups for multi-tenancy. The client syncs only models belonging to the specified groups. |
optimistic | boolean | true | Apply mutations to the identity map before the server confirms them. Rolls back on rejection. |
batchMutations | boolean | false | Batch multiple mutations into a single network request. |
batchDelay | number (ms) | - | Delay before sending a mutation batch. Only applies when batchMutations is true. |
bootstrapMode | "auto" | "full" | "local" | "auto" | auto: use local storage if available and the schema matches, otherwise bootstrap from server. full: always bootstrap from server. local: never contact the server. |
schema | SchemaDefinition | ModelRegistrySnapshot | - | Explicit schema definition. If omitted, the client uses the global ModelRegistry populated by decorators. |
modelFactory | ModelFactory | ModelFactoryFactory | - | Custom factory for creating model instances from raw data. Defaults to ModelRegistry constructors with _applyUpdate. |
yjsTransport | YjsTransport | - | Yjs transport for collaborative editing. Enables client.yjs with document and presence managers. See Y-Doc. |
Conflict resolution
rebaseStrategy
Type: "server-wins" | "client-wins" | "merge": Default: "server-wins"
How the client resolves conflicts with concurrent server changes.
| Strategy | Behavior |
|---|---|
"server-wins" | Server changes take precedence. Client changes drop on conflict. |
"client-wins" | Client changes take precedence. Server changes are overridden. |
"merge" | Field-level merge. Non-conflicting fields from both sides are kept. |
fieldLevelConflicts
Type: boolean: Default: true
Detect conflicts per-field rather than per-model. When enabled, non-overlapping field changes coexist without conflict.