Interface: PlasmaClientOptions<S, TCtx, M>
Interface: PlasmaClientOptions<S, TCtx, M>
Section titled “Interface: PlasmaClientOptions<S, TCtx, M>”Defined in: client/src/sync/client.ts:116
Type Parameters
Section titled “Type Parameters”S extends Schema<Record<string, AnyTable>>
TCtx
M extends AnyMutators<S, TCtx>
Properties
Section titled “Properties”schema
Section titled “schema”
readonlyschema:S
Defined in: client/src/sync/client.ts:121
dbName
Section titled “dbName”
readonlydbName:string
Defined in: client/src/sync/client.ts:122
endpoint
Section titled “endpoint”
readonlyendpoint:string
Defined in: client/src/sync/client.ts:124
Base URL for the sync endpoints, e.g. “https://api.example.com/sync”.
schemaVersion
Section titled “schemaVersion”
readonlyschemaVersion:string
Defined in: client/src/sync/client.ts:125
clientGroupID
Section titled “clientGroupID”
readonlyclientGroupID:string
Defined in: client/src/sync/client.ts:127
Durable per-installation identifier (persist this in the app’s own settings).
mutators
Section titled “mutators”
readonlymutators:M
Defined in: client/src/sync/client.ts:132
The isomorphic mutators. Same record shape as the server side; users typically define them once and import from both.
getContext
Section titled “getContext”
readonlygetContext: () =>TCtx|Promise<TCtx>
Defined in: client/src/sync/client.ts:138
Called before every locally-executed mutation to obtain the ctx that the mutator receives. Kept as a getter (not a constant) so identity changes (e.g. user logs out) reflect without recreating the client.
Returns
Section titled “Returns”TCtx | Promise<TCtx>
pollIntervalMs?
Section titled “pollIntervalMs?”
readonlyoptionalpollIntervalMs?:number
Defined in: client/src/sync/client.ts:140
Milliseconds between poll pulls. Defaults to 5000.
authHeaders?
Section titled “authHeaders?”
readonlyoptionalauthHeaders?: () =>Record<string,string> |Promise<Record<string,string>>
Defined in: client/src/sync/client.ts:142
Optional headers to attach to every push / pull request.
Returns
Section titled “Returns”Record<string, string> | Promise<Record<string, string>>
fetcher?
Section titled “fetcher?”
readonlyoptionalfetcher?: (request) =>Promise<Response>
Defined in: client/src/sync/client.ts:144
Override the global fetch — used in tests to route to an in-process handler.
Parameters
Section titled “Parameters”request
Section titled “request”Request
Returns
Section titled “Returns”Promise<Response>
subscribe?
Section titled “subscribe?”
readonlyoptionalsubscribe?: (onPoke) => () =>void
Defined in: client/src/sync/client.ts:155
Optional realtime nudge. start() invokes this once and expects the
caller to fire onPoke() whenever the server has news. Return an
unsubscribe function so stop() can tear the transport down.
The canonical transport is a WebSocket connected to the plasma
SyncCoordinator Durable Object; use createWebSocketSubscription
from @sh1n4ps/plasma-client for the standard implementation. The polling
fallback continues to run so a dropped connection still catches up.
Parameters
Section titled “Parameters”onPoke
Section titled “onPoke”() => void
Returns
Section titled “Returns”() => void
onError?
Section titled “onError?”
readonlyoptionalonError?: (event) =>void
Defined in: client/src/sync/client.ts:162
Observability sink for the sync loop. Called with a discriminated
SyncClientError when a push / pull / rebase step fails so callers can
surface a toast or forward to Sentry. The client keeps retrying on the
next tick — this hook does not affect control flow.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
retry?
Section titled “retry?”
readonlyoptionalretry?: {maxAttempts?:number;initialDelayMs?:number;maxDelayMs?:number; }
Defined in: client/src/sync/client.ts:169
Retry policy for push / pull HTTP failures. The client retries on
network errors, 5xx, and 429 with exponential backoff + jitter.
Default: 5 attempts starting at 500 ms, doubling to a cap of 30 s.
Set maxAttempts to 1 to disable retries.
maxAttempts?
Section titled “maxAttempts?”
readonlyoptionalmaxAttempts?:number
initialDelayMs?
Section titled “initialDelayMs?”
readonlyoptionalinitialDelayMs?:number
maxDelayMs?
Section titled “maxDelayMs?”
readonlyoptionalmaxDelayMs?:number
blobUploadRetry?
Section titled “blobUploadRetry?”
readonlyoptionalblobUploadRetry?: {maxAttempts?:number;initialDelayMs?:number;maxDelayMs?:number; }
Defined in: client/src/sync/client.ts:183
Retry policy for blob PUT uploads. Independent from retry so a
caller can be aggressive about push / pull retries while giving
uploads a longer runway (large file, unstable link). Defaults:
5 attempts, initial 500ms, max 30s — same shape as retry but a
different budget. Explicit override:
blobUploadRetry: { maxAttempts: 8, initialDelayMs: 1_000 }maxAttempts?
Section titled “maxAttempts?”
readonlyoptionalmaxAttempts?:number
initialDelayMs?
Section titled “initialDelayMs?”
readonlyoptionalinitialDelayMs?:number
maxDelayMs?
Section titled “maxDelayMs?”
readonlyoptionalmaxDelayMs?:number
pullPageSize?
Section titled “pullPageSize?”
readonlyoptionalpullPageSize?:number
Defined in: client/src/sync/client.ts:194
When set, pull requests carry ?limit=N so the server returns at
most N change records per response. The client chains follow-up pulls
until the server signals hasMore: false. Use this to bound memory
on the initial hydration of a huge table.
encryption?
Section titled “encryption?”
readonlyoptionalencryption?: {dek:Uint8Array;keyId:string; }
Defined in: client/src/sync/client.ts:203
End-to-end encryption keys. When present, columns declared with
.encrypted() in the schema are automatically transparent-encrypted
on their way to the server (via a helper the caller applies inside
mutators) and transparent-decrypted on pull before landing in IDB.
The DEK must be 32+ bytes of high-entropy material. The caller
manages storage / rotation of the key.
readonlydek:Uint8Array
readonlykeyId:string
onSchemaMismatch?
Section titled “onSchemaMismatch?”
readonlyoptionalonSchemaMismatch?: (info) =>"reset"|"stay"|Promise<"reset"|"stay">
Defined in: client/src/sync/client.ts:214
Handler invoked when the server responds with 409 schema-mismatch.
Return "reset" to have plasma wipe the local base + optimistic
stores and start over on the next pull (typical for prompt-and-reload
apps); return "stay" to leave the local IDB alone and just surface
the mismatch through onError. Omitted → "stay".
Parameters
Section titled “Parameters”"push" | "pull"
Returns
Section titled “Returns”"reset" | "stay" | Promise<"reset" | "stay">
offline?
Section titled “offline?”
readonlyoptionaloffline?:boolean
Defined in: client/src/sync/client.ts:238
Offline-only mode (native / desktop apps, tests, air-gapped
environments). When true the client:
- Skips the sync loop entirely —
start()does not open a poll interval /onlinelistener / websocket subscription, andpushOnce()/pullOnce()become no-ops. - Runs mutations locally through the IndexedDB engine only. The
outbox still accumulates envelopes so
PlasmaClientOptions.offlinecan be flipped back tofalselater without losing history. - Serves
readFile(ref)from_plasma_blobs_localonly, returning{ status: "missing" }when the bytes are absent. - Fires no upload workers, no blob PUT retries, and no
SyncClientError.blob-upload-failedevents.
Ideal for React-Native / Tauri / Electron shells that build on
plasma’s reactive query DSL but never talk to a plasma sync server.
endpoint is still required (dummy value is fine — it is never
fetched); flip offline back to false at runtime by
reconstructing the client with the same dbName.