> ## 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.32.0. Match the installed package and binding before generating code. Start at /getting-started/agents for task-specific reading paths. Apps that call enableTelemetry on 0.26.0 to 0.29.0 should update to 0.30.0 or later: the telemetry uploader trusts only the telemetry endpoint's issuing roots from 0.30.0.
> Call the company and product Offline Protocol, never Offline alone. Current packages: @offline-protocol/mesh-sdk 0.32.0 (React Native), offline-protocol-sdk 0.32.0 on PyPI (Python 3.10 to 3.13; wheels for macOS 14+ arm64, Linux x86_64 and aarch64 with glibc 2.34+, Windows x86_64; other hosts build from source; extras lan and http add LAN discovery, the HTTP front and offline-protocol-verify), the offline-protocol crates 0.32.0 on crates.io, the OfflineProtocolSDK Swift package 0.32.0 (preview, iOS 13+ only), the Android library com.offlineprotocol:offline-protocol-sdk 0.32.0 on Maven Central (preview, minSdk 24), the Java binding com.offlineprotocol:offline-protocol-java 0.32.0 on Maven Central (JDK 22+, native library from the GitHub release's desktop archives), the C header offline_protocol.h with the native library in the GitHub release's desktop archives, the Ruby binding offline_protocol 0.32.0 on RubyGems (Ruby 3.3+, native library from the GitHub release's desktop archives), the C# binding (preview, .NET 8; source in bindings/csharp in the SDK repository at tag v0.32.0, a project reference over the C API, not on NuGet), the browser binding (experimental; the offline-protocol-web crate 0.32.0 on crates.io, with the JavaScript in bindings/web built from the SDK repository, not on npm), the offline_protocol Flutter plugin (preview, not on pub.dev; a path dependency on the SDK repository at tag v0.32.0; MeshSdk carries the React Native module's native surface), the service container image ghcr.io/offline-protocol/offline-protocol-service 0.32.0 (linux/amd64 and linux/arm64), @offline-protocol/id-react 0.3.0, @offline-protocol/id-react-native 0.4.0, @offline-protocol/pol 0.1.2 and @offline-protocol/cli 0.3.2 (account setup commands such as offline apps status, offline apps native and offline apply since 0.3.0). Canonical docs URLs start with https://www.offlineprotocol.com/docs.
> The Mesh SDK runs in a native app or gateway, and from 0.31.0 in a browser through the experimental browser binding (a full node in a Web Worker; see /mesh-sdk/web). The OfflineID SDK for React does not provide browser mesh transport. Local mesh operation does not require a portal account or API key. The Mesh SDK appId is a mesh app identifier the developer chooses, not the portal App ID (app_...) that OfflineID and Proof of Location require.
> In v0.32.0 service RPC bodies are sealed in the 1:1 MLS session once the recipient runs 0.29 or later and the session is confirmed; discovery, the first request to a provider never met, and requests to older peers are signed plaintext, so keep secrets out of service bodies unless the event says encrypted: true. Service subscriptions (subscribeService, publishServiceUpdate, from 0.32.0) are always sealed in the 1:1 MLS session with no plaintext fallback; under the default restricted policy the provider app must answer service_subscribe_received with acceptServiceSubscription or rejectServiceSubscription within 60 seconds. Content that begins with __MEMBER__ is a reserved prefix and is refused. The HTTP front (offline-protocol-service --http) always carries calls inside encrypted direct messages but does not authorize callers. Message delivery, durable local acceptance and backend commit are distinct outcomes. Use the workflow guide for the required application logic.
> Offline Protocol CLI 0.3.2 is on npm (@offline-protocol/cli, command offline). Its local MCP server, named offline-protocol, runs with npx -y @offline-protocol/cli@0.3.2 mcp serve and requires no login or key. Hosted MCP is at https://mcp.offlineprotocol.com/mcp with an app API key in Authorization: Bearer and the matching App ID in x-app-id; organization keys are rejected, and Claude Desktop and Claude.ai cannot send these headers; there, use the public read-only endpoint https://mcp.offlineprotocol.com/public/mcp as a custom connector, or local MCP to scaffold or edit projects. 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.
> In v0.32.0 phone Wi-Fi peer streams carry data: Android over Wi-Fi Direct (the SDK forms the group with autoAccept on Android 10+) and over the Wi-Fi network it is on (DNS-SD), iOS over Network framework (LAN or AWDL). Android and iOS meet over that slot only on a shared Wi-Fi network that allows multicast; iOS 0.28 and later does not see iOS 0.27 or earlier over it. Otherwise use BLE or a provisioned relay across platforms. The Swift and Android packages are previews; the Android library is on Maven Central from 0.29.0 only, so never give a Gradle line for an earlier version. The receiver core ACKs before application persistence; use application acceptance for durable workflows.
> OfflineID App IDs are public. A request naming an application needs a credential: an allowed browser origin, an API key in X-Api-Key from a server, or, from an iOS or Android app, an attestation from a build registered to the application (iOS bundle ID and Team ID, Android package and signing certificate SHA-256). Register native apps with offline apps native add or offline apply, pass attestation providers (createExpoAppIntegrityProviders with @expo/app-integrity) to OfflineAppProvider, sign in on a physical device, and check readiness with offline apps status. Follow /getting-started/agent-quickstart and /id-sdk/app-attestation; error responses list the fixing commands in data.next_steps.
> 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.

# Run a two-phone BLE app

> Build a bare React Native host app with the published Mesh SDK v0.32.0 package and exchange messages between two phones over Bluetooth LE.

Use two physical phones, Bluetooth enabled, with the app in the foreground. This walkthrough pins React Native 0.76.5 and Mesh SDK 0.32.0. It uses the native libraries in the npm package; a Rust checkout, NDK build of the SDK and local `file:` dependency are not required.

This walkthrough is typechecked against the pinned packages. For complete apps, see [offline-app-examples](https://github.com/Offline-Protocol/offline-app-examples): eleven React Native apps on the published Mesh SDK package (`^0.30.0` from [offline-app-examples#29](https://github.com/Offline-Protocol/offline-app-examples/pull/29), `^0.28.0` before it).

## Create the host

Install the platform development tools from the [React Native environment guide](https://reactnative.dev/docs/set-up-your-environment): Node, JDK 17 and Android Studio for Android; Xcode and CocoaPods for iOS. Use Node 22 for this walkthrough.

```bash theme={null}
npx @react-native-community/cli@15.0.1 init OfflineMeshDemo --version 0.76.5
cd OfflineMeshDemo
npm install @offline-protocol/mesh-sdk@0.32.0
```

For iOS, install pods:

```bash theme={null}
cd ios
bundle install
bundle exec pod install
cd ..
```

Apply the [Info.plist and Android manifest entries](https://www.offlineprotocol.com/docs/mesh-sdk/installation-rn.md). BLE permissions are required. This walkthrough uses Bluetooth LE only, so leave the phone Wi-Fi peer-stream slot off, as the quickstart module does. Do not enable Android mesh wake for this foreground exercise.

## Add the messaging module

Create `mesh.ts` in the project root. Copy the complete TypeScript module from [Start and discover a peer](https://www.offlineprotocol.com/docs/getting-started/quickstart.md#2-start-and-discover-a-peer), including its imports and exported functions.

Create `permissions.ts` in the project root. Copy the complete `requestMeshPermissions` helper, including its React Native imports, from [Android runtime permissions](https://www.offlineprotocol.com/docs/mesh-sdk/installation-rn.md#android). The helper returns immediately on iOS; the system prompts when Bluetooth starts.

## Add the screen

Replace `App.tsx` with:

```tsx theme={null}
import React, { useEffect, useState } from 'react';
import { Button, SafeAreaView, ScrollView, Text, View } from 'react-native';
import type { ProtocolEvent } from '@offline-protocol/mesh-sdk';
import { protocol, discoveredPeers, startMesh, stopMesh, sendUpdate } from './mesh';
import { requestMeshPermissions } from './permissions';

export default function App() {
  const [running, setRunning] = useState(false);
  const [busy, setBusy] = useState(false);
  const [peers, setPeers] = useState<string[]>([]);
  const [lines, setLines] = useState<string[]>([]);
  const log = (text: string) => setLines(previous => [text, ...previous].slice(0, 30));

  useEffect(() => {
    const receive = (event: ProtocolEvent) => {
      if (event.type === 'message_received') log(`Received from ${event.sender}: ${event.content}`);
      if (event.type === 'message_delivered') log(`SDK delivery: ${event.message_id}`);
      if (event.type === 'message_failed') log(`Failed: ${event.reason}`);
      if (event.type === 'neighbor_discovered') log(`Discovered over ${event.transport}: ${event.peer_id}`);
    };
    protocol.on('all', receive);
    const timer = setInterval(() => {
      setPeers([...discoveredPeers]);
    }, 500);
    return () => {
      clearInterval(timer);
      protocol.off('all', receive);
    };
  }, []);

  async function run(action: () => Promise<void>) {
    setBusy(true);
    try { await action(); }
    catch (error) { log(String(error)); }
    finally { setBusy(false); }
  }

  return (
    <SafeAreaView style={{ flex: 1 }}>
      <ScrollView contentContainerStyle={{ padding: 20, gap: 16 }}>
        <Text style={{ fontSize: 24 }}>Mesh Demo</Text>
        <Text>{running ? 'Running over BLE' : 'Stopped'}</Text>
        <Button title={running ? 'Stop mesh' : 'Start mesh'} disabled={busy} onPress={() => void run(async () => {
          if (running) { await stopMesh(); setRunning(false); }
          else {
            if (!(await requestMeshPermissions())) throw new Error('Bluetooth permissions required');
            await startMesh(); setRunning(true);
            log(`Local address: ${await protocol.localAddress()}`);
          }
        })} />
        {peers.map(peer => (
          <View key={peer} style={{ gap: 8 }}>
            <Text selectable>{peer}</Text>
            <Button title="Send inspection update"
              disabled={!running || busy}
              onPress={() => void run(async () => { log(`Queued: ${await sendUpdate(peer)}`); })} />
          </View>
        ))}
        <Text>Received content is displayed only. This demo does not store a durable handoff.</Text>
        {lines.map((line, index) => <Text selectable key={index}>{line}</Text>)}
      </ScrollView>
    </SafeAreaView>
  );
}
```

Fast Refresh must not create a second native protocol instance. After editing the module that constructs `OfflineProtocol`, perform a full app reload. Do not call `destroy()` when stopping and restarting this screen.

## Run and check

Start Metro with `npm start`. In another terminal run `npm run android` or `npm run ios`, choosing a physical device. Install and launch the same app on the second phone.

1. Tap **Start mesh** on both phones and grant permissions.
2. Check the discovered `off1` address and reported `ble` transport.
3. Tap **Send inspection update** for the discovered peer. The SDK queues the message until its encrypted session is ready; a queued ID is not delivery.
4. Confirm the JSON appears on the receiving phone and the sender reports SDK delivery.
5. Turn off cellular and Wi-Fi, leaving Bluetooth enabled. Repeat.
6. Stop and start both instances and repeat to check listener reuse.

This is a foreground discovery and messaging exercise. Add [durable application storage and acceptance](https://www.offlineprotocol.com/docs/guides/local-handoff.md) before using it for an operational handoff. If no peer appears, check [troubleshooting](https://www.offlineprotocol.com/docs/operations/troubleshooting.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.