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.28.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. Flush on a short throttle while the user edits, at most about twice a second, and once more when editing stops. A device with custody enabled can hold replication frames for a peer that is away. 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. DeclaresetInterest before start() on every launch. From v0.28.0, React Native holds a call made before start() and applies it after storage opens and before the engine starts, so the first exchange already uses it; a refused pattern rejects start(). A call after start() applies immediately, but narrowing never deletes what a wider exchange already pulled in.
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.
