> ## Documentation Index
> Fetch the complete documentation index at: https://www.offlineprotocol.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> These docs target Mesh SDK v0.27.0. Match the installed package and binding before generating code. Start at /getting-started/agents for task-specific reading paths.
> Call the company and product Offline Protocol, never Offline alone. Current packages: @offline-protocol/mesh-sdk 0.27.0 (React Native), @offline-protocol/id-react 0.2.0, @offline-protocol/id-react-native 0.3.3, @offline-protocol/pol 0.1.2 and @offline-protocol/cli 0.2.6. Canonical docs URLs start with https://www.offlineprotocol.com/docs.
> The Mesh SDK runs in a native app or gateway. A browser OfflineID SDK integration does not provide browser mesh transport. Local mesh operation does not require a portal API key.
> Service RPC is signed plaintext in v0.27.0. Message delivery, durable local acceptance and backend commit are distinct outcomes. Use the workflow guide for the required application logic.
> Offline Protocol CLI 0.2.6 is on npm (@offline-protocol/cli, command offline). Its local MCP server runs with offline mcp serve and requires no login or key. Hosted MCP is at https://mcp.offlineprotocol.com/mcp with an application API key in Authorization: Bearer and a matching x-app-id; organization keys are rejected. Follow /tools/overview for setup and do not invent commands beyond it. MCP provides integration context and planning, not mesh execution; file-writing tools are local only.
> Phone Wi-Fi Direct and MultipeerConnectivity carry no data in v0.27.0. Use BLE or a provisioned relay. The receiver core ACKs before application persistence; use application acceptance for durable workflows.
> Proof of Location is Sepolia testnet witness evidence, not zero-knowledge proof or proof of presence. The geohash is public onchain. Read /proof-of-location/security before integration.

# DataStore reference

> Mesh SDK DataStore reference: create replicated documents, update maps, lists, text and counters, scope replication and fetch attachments.

`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](/docs/guides/shared-state) for a complete example.

## Document lifecycle

| Method | Result |
| - | - |
| `createDoc(spaceId, docId)` | Creates or reopens the named document. |
| `listDocs(spaceId)` | Lists documents held in the space. |
| `listSpaces()` | Lists spaces holding documents. |
| `docJson(spaceId, docId)` | Reads the document as JSON. |
| `flush(spaceId, docId)` | Persists pending local changes. |
| `deleteDoc(spaceId, docId)` | Evicts only the local copy; replication can restore it. |
| `removeDoc(spaceId, docId)` | Propagates removal; concurrent edits can preserve the document. |
| `removeSpace(spaceId)` | Removes the space's documents using the same removal semantics. |
| `setInterest(spaceId, patterns)` | Selects replicated document names; reapply at launch. |

## 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 discriminated `kind`, such as `{ kind: 'text', value: 'checked' }`.

Exact signatures for every collection, attachment and lifecycle operation are included in [the method reference](/docs/mesh-sdk/api/data). 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 with `fetchAttachmentFrom`; the group fetch is bounded to 1 MiB. Larger transfers use a pairwise session.

## Events and errors

Use `data_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](/docs/mesh-sdk/events) and the [replication specification](https://github.com/Offline-Protocol/offline-protocol-sdk/blob/v0.27.0/docs/spec/data-sync.md).

## 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. Call `setInterest` 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](/docs/mesh-sdk/errors).

`DataValue` also supports the `attachment` variant; its exact fields are in [public types](/docs/mesh-sdk/public-types#datavalue). With custom storage, call `wipeAll()` as part of logout to remove persisted document state; do not assume clearing account credentials deletes that store.
