DataStore uses the live protocol instance. Start the protocol, establish the required MLS scope and pass the peer address or group ID as spaceId. See shared state for a complete example.
Document lifecycle
Collections
Use map operations for independent keys, list operations for ordered values, text operations for collaborative text, and counter operations for accumulated increments. Values use a discriminatedkind, such as { kind: 'text', value: 'checked' }.
Exact signatures for every collection, attachment and lifecycle operation are included in the method reference. They are generated from the v0.27.0 binding.
Attachments
An attachment reference is not the attachment bytes. Fetching needs a peer that holds the content. For groups, select a member withfetchAttachmentFrom; the group fetch is bounded to 1 MiB. Larger transfers use a pairwise session.
Events and errors
Usedata_changed to refresh after a durable change and data_doc_removed to close a removed document. Handle size warnings, unsyncable documents and attachment unavailable events explicitly. DataDisabled means the data layer was disabled; DataStorageUnavailable means its storage prerequisites are not ready.
See events and the replication specification.
Capacity and recovery
Documents are capped at 1 MiB, with a warning at 768 KiB. Sync frames are bounded to 32 KiB. Each space accepts up to 1,024 peer-named documents and 32 interest patterns. CallsetInterest right after start() resolves on every launch. React Native requires the initialized DataStore.
DocTooLarge can occur after the breaching change is durable; shrink the document before adding more. DataCorrupted is not resolved by retrying the same bytes. Operations on a removed document name can return InvalidState. See error codes.
DataValue also supports the attachment variant; its exact fields are in public types. With custom storage, call wipeAll() as part of logout to remove persisted document state; do not assume clearing account credentials deletes that store.
