Choose a space
A space is an existing MLS session or group. For a pairwise session, pass the other device’s address asspaceId; each device therefore uses a different address for its side of the same space. For a group, pass its group ID on every member.
Start the protocol and establish the encrypted session using the quickstart. The data layer is enabled by default in v0.27.0; it can be explicitly disabled with data.enabled.
Write and read a document
flush waits for local persistence. It does not mean a peer has received the edit. Attach a data_changed listener to your OfflineProtocol instance to refresh the UI after a durable change, and read the document again on the receiving device.
Model concurrent edits
Map values are replaced as a whole. Put fields that must merge independently in separate keys instead of one JSON string. Use one collection type per collection name.
Document and collection names are 1 to 128 bytes using letters, digits,
., _ and -. Map keys are 1 to 256 bytes.
Scope replication
setInterest(spaceId, patterns) selects document names or trailing-wildcard prefixes. ['*'] requests all documents; [] requests none. Call setInterest right after start() resolves, on every launch; interests are not persisted. React Native initializes DataStore during startup, so calling it earlier throws. A space accepts at most 32 patterns. This reduces replicated data but is not a substitute for membership authorization: use separate spaces for different access boundaries.
deleteDoc evicts this device’s copy; a peer can restore it. removeDoc propagates removal, but a concurrent edit can preserve and restore the document. Use a fresh document name for new content rather than relying on removal as a permanent tombstone.
Verify two different interruptions
- Disconnect the backend while keeping peers connected. Edit on one device and observe the other receiving the change.
- Disconnect the peer path. Edit different fields on both devices, flush, then reconnect and compare both documents.
- Edit the same map key independently and confirm the documented conflict rule.
- Restart a device and confirm its persisted state and identity survive.

