# Choosing adapters (https://docs.open-e2ee.dev/start/choosing-adapters.md)

- Status: stable
- Applies to: 15.0.0
- Platforms: All
- Prereqs: Quickstart
- Reading time: 8 min

The SDK is a protocol core with four pluggable slots. Composition is the API: what you pass here determines where keys live, who can deliver messages, and what your backend can see. Adapters are security boundaries, not convenience callbacks.

```ts
const signal = await createSignalProtocolClient({
  identity: { userId, deviceId, enablePniKeys },
  adapters: {
    storage,             // required
    relay,               // optional
    remoteObjectStore,   // optional
    protocolManager,     // advanced
  },
  protocol: { /* ... */ },
});
```

Note the shape: only those four live under `adapters`. Everything else, `logger`, `hooks`, `sealedSender`, `groups`, prekey timings, is a top-level field on the config.

## The four slots [#the-four-slots]

| Slot | Interface | Required | What it owns |
|---|---|---|---|
| `storage` | `SignalProtocolLocalStore` | **yes** | Device-local protocol state: identity keys, prekeys, sessions, ratchet state, contact trust |
| `relay` | `SignalProtocolRelayServer` | no | Public key distribution, device registry, envelope delivery |
| `remoteObjectStore` | `SignalProtocolRemoteObjectStore` | no | Brokered upload and download of encrypted attachment bytes |
| `protocolManager` | `SignalProtocolManager` | no | Advanced override, mainly for tests |

**The design requires only storage.** You can replace delivery or omit the relay. The local test path still encrypts and decrypts. You cannot omit the store because it holds ratchet state. If you lose the store, no server copy can recover it.

## Storage adapters [#storage-adapters]

```bash
npm install @open-e2ee/signal-protocol-sdk@latest expo-secure-store expo-sqlite
```

| Adapter | Subpath | Exports | Status |
|---|---|---|---|
| Expo | `/local/store/expo` | `ExpoSignalProtocolStore`, `expoStore()` | Primary. Requires a development build; SQLCipher is not available in Expo Go. In an Expo web build, an encrypted open fails with `KEY_STORAGE_ERROR`. |
| React Native (bare) | `/local/store/react-native` | `ReactNativeSignalProtocolStore`, `reactNativeStore()` | Supported. SQLCipher on op-sqlite in an SDK-owned database; requires the op-sqlite SQLCipher build and a native build. Not available in Expo Go. |
| Node and Electron | `/local/store/node` | `NodeSignalProtocolStore`, `nodeStore()` | Supported. SQLCipher on `better-sqlite3-multiple-ciphers` in an SDK-owned database; you pass the vault. In Electron, open it in the main process. |
| Web, SQLite | `/local/store/web-sqlite` | `WebSqliteSignalProtocolStore`, `webSqliteStore()` | Supported. Encrypted SQLite in the origin private file system, in an SDK-owned database; needs a CSP that allows `'wasm-unsafe-eval'`. Also the store for a Tauri 2 webview. |
| Web | `/local/store/web` | `IndexedDbSignalProtocolStore`, `indexedDbStore()` | Supported. For browsers without the origin private file system. Full store contract; its graduation gates run in real Chromium, Firefox, and WebKit on every change. Deployment requires the [browser threat model](https://docs.open-e2ee.dev/start/browser.md) review. |
| Key-value | `/local/store/key-value` | `KeyValueSignalProtocolStore`, `keyValueStore()` | Supported. Full store contract; you supply the key-value backend and verify it with the exported backend-conformance kit. |
| In-memory | `/local/store/memory` | `InMemorySignalProtocolStore`, `inMemoryStore()` | **Development only.** Everything is lost on restart. |

> **Every store carries the same contract**
>
> Each shipped store declares `implements SignalProtocolLocalStore` and carries the full contract. This includes Expo, bare React Native, Node, both web stores, key-value, and in-memory. The contract includes the Sesame device store, sender-key store, and message-record store. [Multi-device](https://docs.open-e2ee.dev/build/multi-device.md) and both [group](https://docs.open-e2ee.dev/build/groups.md) APIs therefore work on every store, including Node.

Factory call shapes differ, and this catches people porting between runtimes:

```ts
inMemoryStore()                  // synchronous
await expoStore(options?)        // async
await indexedDbStore()           // async
await webSqliteStore(options?)   // async
await reactNativeStore(options?) // async
await nodeStore(options)         // async; directory and vault are required
await keyValueStore(options)     // async
```

There is a fifth piece that is not a store: the **secret vault**, `SignalProtocolLocalSecretVault`, with `ExpoSecureStoreSignalProtocolSecretVault` at `/local/vault/expo-secure-store`, `ReactNativeKeychainSignalProtocolSecretVault` at `/local/vault/react-native-keychain`, and `ElectronSafeStorageSignalProtocolSecretVault` at `/local/vault/electron-safe-storage`. It holds small bootstrap secrets, in the OS keychain except for the web SQLite store's default IndexedDB vault: for each SQLite store, one 32-byte database key; for the key-value store, the 32-byte key that encrypts each stored value. A plain Node process has no SDK vault, so pass one over the secret store of your deployment. Platform secret managers are appropriate for tiny keys and bootstrap values, not full session databases. Do not try to put protocol state in it.

## Relay adapters [#relay-adapters]

| Adapter | Subpath | Exports | Status |
|---|---|---|---|
| OpenE2EE Signal Protocol Relay | package root | `createHostedSignalProtocolClient()` | Built to work with this SDK. Start on a Sandbox environment. See [Signal Protocol Relay](https://docs.open-e2ee.dev/signal-relay.md). |
| Custom transport | `/remote/signal-relay` | `SignalProtocolRelayServer` (type only) | You implement it and pass it to `createSignalProtocolClient()`. You operate the authenticated backend. |

The package contains no relay implementation.

Omitting `relay` gives you local-only mode: real encryption and decryption, no distribution. That is a legitimate configuration for tests and for a first integration where you want the protocol working before the backend exists.

Before you implement `SignalProtocolRelayServer`, read [reference → adapters](https://docs.open-e2ee.dev/reference/adapters.md). The relay must preserve one-time-prekey consumption during concurrent requests. It must never issue a consumed prekey as unused.

## Object store adapters [#object-store-adapters]

| Adapter | Subpath | Exports |
|---|---|---|
| Convex R2 | `/remote/object-store/convex-r2` | `ConvexR2ObjectStore`, `convexR2ObjectStore()`, `ConvexR2ObjectStoreApi` |
| S3 | `/remote/object-store/s3` | `S3ObjectStore`, `s3ObjectStore()` |

Both are **brokered**, and this is not an implementation detail. An authenticated application backend maps a request to a canonical object ID and a private provider key, and issues scoped URLs. Cloud credentials and unrestricted provider clients do not belong in the app runtime. If you choose an adapter that takes an access key in the client, you choose the wrong adapter.

These adapters apply to `createSignalProtocolClient()`. The hosted client takes no `remoteObjectStore`, because the Relay transport supplies the object store. Omit `remoteObjectStore` from `createSignalProtocolClient()` and file upload operations throw. See [encrypted attachments](https://docs.open-e2ee.dev/guides/encrypted-attachments-r2-s3.md).

## How to decide [#how-to-decide]

**Start from your runtime**, because storage is the only required slot and it is the most constrained choice:

- Shipping an Expo app → use the Expo store and secure-store vault. Plan for a development build.
- Shipping a web app → use the web SQLite store. It needs the origin private file system and a CSP with `'wasm-unsafe-eval'`. Where the origin private file system is not available, the open fails with `OPFS_UNAVAILABLE`; use the IndexedDB store there. Evaluate [the browser threat model](https://docs.open-e2ee.dev/start/browser.md) separately from the adapter.
- Shipping a bare React Native app → use the React Native store and the react-native-keychain vault. Plan for the op-sqlite SQLCipher build and a native build. See [React Native setup](https://docs.open-e2ee.dev/start/react-native.md).
- Choosing your own storage engine, for example Realm → use the key-value store, and verify your backend with the exported backend-conformance kit before you ship.
- Shipping an Electron app → use the Node store in the main process with the safeStorage vault. A Tauri 2 app uses the web SQLite store in its webview. On Linux, WebKitGTK fails the open with `OPFS_UNAVAILABLE`. See [runtime support](https://docs.open-e2ee.dev/reference/runtime-support.md#browser).
- Building a service, CLI, or test → the Node store, having read [why a server-side identity is a real participant](https://docs.open-e2ee.dev/start/node.md).

**Then decide the relay**, which is a backend question rather than a runtime one. Use the OpenE2EE Signal Protocol Relay for hosted delivery. On your own backend, Convex, Supabase, your own API, anything: implement `SignalProtocolRelayServer`. It is a bounded interface, and the SDK never asks it for anything private.

**Then decide attachments**, which most teams should defer. Get messaging working first.

> **Tradeoff — Experimental adapters are not a lesser version of the same thing**
>
> The maturity labels define support status. "Experimental" means the adapter's graduation checklist is not yet a set of continuously running CI gates. It does not mean an older build of a supported adapter. No store carries the label today, but a future adapter can ship experimental. If you ship one, record the decision and a review date. Read [upgrades](https://docs.open-e2ee.dev/operate/upgrades.md) for the version and migration policy.

> **Not covered**
>
> Writing your own adapters. The interfaces, their correctness obligations, and their security expectations are in [reference → adapters](https://docs.open-e2ee.dev/reference/adapters.md). Implementing `SignalProtocolLocalStore` in particular means taking responsibility for key material at rest, stable trust decisions, atomic linked-device state, and session record semantics.

## Next [#next]

- [Expo setup](https://docs.open-e2ee.dev/start/expo.md), [React Native setup](https://docs.open-e2ee.dev/start/react-native.md), [Browser setup](https://docs.open-e2ee.dev/start/browser.md), [Node setup](https://docs.open-e2ee.dev/start/node.md).
- [Local encrypted storage](https://docs.open-e2ee.dev/build/local-storage.md): the store and vault boundary in depth.
- [Relay and prekeys](https://docs.open-e2ee.dev/build/relay-and-prekeys.md): what a relay owes the protocol.
- [Adapter interfaces](https://docs.open-e2ee.dev/reference/adapters.md): the full contracts.
- [Package subpaths](https://docs.open-e2ee.dev/reference/package-subpaths.md): every import path.
