SharedStoreOptions
Extends
Section titled “Extends”Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
S | Record<string, unknown> |
Properties
Section titled “Properties”accept?
Section titled “accept?”optional accept?: (meta) => boolean;Gatekeeper for incoming remote writes (patches and snapshot merges): return false to ignore them. Lets callers delimit how much is shared — e.g. accept only writes from other tabs, not from workers.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
meta | MessageMeta |
Returns
Section titled “Returns”boolean
optional kind?: PeerKind;What this client announces itself as. Defaults to ‘worker’ when there is no document, else ‘tab’.
Inherited from
Section titled “Inherited from”onInvalid?
Section titled “onInvalid?”readonly optional onInvalid?: OnInvalid;Observe validation failures instead of the default development warning.
Inherited from
Section titled “Inherited from”persist?
Section titled “persist?”optional persist?: PersistOptions;Restore this store on creation and write it back as it changes.
schema?
Section titled “schema?”readonly optional schema?: SchemaMap<S>;Validate payloads against a Standard Schema
before trusting them — any Zod, Valibot or ArkType schema, or anything else
exposing ~standard.
Without this, an inbound payload is cast, not checked: a peer running last week’s deploy sends whatever that build thought the shape was, and the receiving code reads it as whatever this build’s types say. That is the one place in this library where a type is a hope rather than a guarantee, and a rolling deploy is what turns it into a bug.
Validation runs in both directions. Inbound, a failure drops the payload — the same choice the envelope makes for a wire it cannot read. Outbound, it throws, because a value your own code just produced and cannot describe is a bug in this tab, and finding it here beats finding it in someone else’s.
Inherited from
Section titled “Inherited from”snapshotDelayMs?
Section titled “snapshotDelayMs?”optional snapshotDelayMs?: number;Longest pause before answering a late joiner’s request for state, in ms. Default 40. The actual wait is random within it, so peers do not all answer at once and the first reply cancels the rest.
transport?
Section titled “transport?”optional transport?: (name) => Transport;Transport factory, mainly for tests. Defaults to defaultTransport.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name | string |