Evolu now has local auth

Evolu 8 gave every account (AppOwner) its own encrypted SQLite database whose name and key derive from the account's secret. That unlocked multi-account apps, with one catch: a database encrypted with an account's key can't also store that key, because the key has to exist before the database opens. Every app on Evolu 8 had to invent its own account bootstrap and storage, and our own examples fell back to the public testAppOwner.

createEvoluApp closes that gap. It stores accounts in a local-only encrypted device database, unlocks it with mobile secure storage, a web passkey, or instant start, and creates the first account without multi-tab races. See Local auth for the setup guide and the ADR for the full design rationale.

Update, November 18, 2026: Automatic migration from Evolu 7 has since shipped — see Evolu 8 migrates Evolu 7 data. In createEvoluApp, it carries over an Evolu 7 owner automatically under InstantStart with createFirstAppOwner: true.

Two layers of encryption

In a local-first app, no server signs users in to their data. An account is a cryptographic secret on the device (backed up as a 24-word mnemonic) that encrypts the user's database and synced relay data. Relays can still enforce access control, but they hold only ciphertext.

Encrypting user data directly with a local-auth key would tie every byte to one unlock mechanism. Instead, each AppOwner keeps its own encrypted SQLite database, and createEvoluApp adds a local-only device database (transports: []) that holds the device's AppOwner secrets (and optional device-only tables like UI preferences) without ever syncing or exporting them:

Keychain / Keystore ──────┐
                          ├─▶ DeviceSecret ─┐
Passkey ─▶ Wrapped-key DB ┘                 ├─▶ Device DB
                                            │  ├─ device tables
Instant start (public) ─────────────────────┘  └─ _evolu_appOwner
                                                        │
                                                        ▼
                                                   AppOwner DBs
                                          (one per account, each
                                           keyed by its AppOwner)

Keychain, passkeys, and instant start

Browsers don't isolate OPFS, IndexedDB, or localStorage from other programs reading profile files on disk. Evolu encrypts every database on disk, and each account's database is encrypted with its AppOwner secret stored in the device database — so at-rest protection comes down to how auth protects the device database's key: { type: "DeviceSecret", secret } or { type: "InstantStart" }.

Platformauth modePromptProtects storage at rest?
React NativeDeviceSecret (loadDeviceSecret)NoneYes
Web (sensitive data)DeviceSecret (createPasskeyAuth)Every start and tabYes
Web (non-sensitive data)InstantStartNoneNo
Electron & Node.jsInstantStart, or app-managed DeviceSecretNoneOnly with app-managed secret
  • Mobile (loadDeviceSecret): @evolu/react-native creates a 32-byte secret and keeps it in the iOS Keychain or encrypts it with an Android Keystore key, with no Expo dependency and no user prompt, so apps start silently and background sync works. Unreadable Android keys never auto-wipe — the user retries and confirms before starting over (React Native).
  • Web passkeys (createPasskeyAuth): Browsers have no promptless secure storage, so Evolu wraps DeviceSecret with a passkey's WebAuthn PRF output and keeps the wrapped blob in a small SQLite database of its own on OPFS (so the browser can't delete one without the other). First setup prompts twice to prove PRF works before generating a secret, and errors never silently replace a passkey. The catch is friction: a prompt on every start and tab, and uneven PRF support across passkey providers (Passkeys on the web).
  • Instant start (InstantStart): Uses a fixed public key so the app starts without a prompt. Synced data stays end-to-end encrypted on relays, but on disk it protects account secrets no better than localStorage. The mode is permanent per appName — upgrading an InstantStart account in place would only look like protection, because an earlier copy of its secret still decrypts its relay history.

Electron and Node.js have no secure storage in Evolu yet; Electron's safeStorage is tracked in issue #782.

A DeviceSecret protects secrets at rest from storage and backup readers. It does not stop code running inside an unlocked tab or process (XSS, malicious extensions), nor physical access to an already-unlocked phone on mobile.

One first account, without a multi-tab race

Open two tabs of a fresh web app at once: both see zero accounts and both create one. Even writing under a fixed ID races because local-only writes are upserts, so tab two overwrites tab one while tab one keeps using its own account. Solving that in app code pushes Web Lock deadlocks or split storage onto every app.

Evolu solves it inside the database worker's locked startup transaction, which commits before the worker answers any request. With createFirstAppOwner: true, Evolu creates and inserts the first AppOwner inside that creation transaction, so every tab's first read waits for it and sees the same account. It runs only when creating the device database — never whenever the table is empty — so removing every account won't resurrect one on worker restart. (On React Native and Node.js, this worker lock is in-process, while loadDeviceSecret is cross-process atomic.)

In code

import {
  AppName,
  createEvoluApp,
  createOwnerSecret,
  id,
  NonEmptyTrimmedString100,
} from "@evolu/common";
import { createEvoluDeps, createRun } from "@evolu/web";

const Schema = { todo: { id: id("Todo"), title: NonEmptyTrimmedString100 } };
const run = createRun(createEvoluDeps());

const app = await run.orThrow(
  createEvoluApp(Schema, {
    appName: AppName.orThrow("todos"),
    // Or { type: "DeviceSecret", secret } from loadDeviceSecret or createPasskeyAuth.
    auth: { type: "InstantStart" },
    createFirstAppOwner: true,
  }),
);

const [personal] = app.appOwners.get();
const current = app.current.get();
if (current) {
  const evolu = await current.evolu;
  evolu.insert("todo", { title: NonEmptyTrimmedString100.orThrow("Buy milk") });
}

// Add (or restore) a second account, then switch back in this tab.
const work = await app.add(
  createOwnerSecret(run.deps),
  NonEmptyTrimmedString100.orThrow("Work"),
);
if (work.ok) app.open(personal.id);

app.add and app.remove replace Evolu 7's restoreAppOwner and resetAppOwner: add the new account before removing the old one so a crash never leaves zero accounts. React and Vue ship EvoluAppProvider, Svelte ships evoluAppState, and apps with external accounts like Trezor Suite keep calling createEvolu directly.

Trade-offs

  • Prompt users to back up their mnemonic. Browsers can clear storage (for example, Safari clears non-Home-Screen site data after seven days of Safari use without interacting with the site; see the FAQ), and a new phone, also one restored from a device backup, doesn't get the Keychain or Keystore secret. Losing storage loses local databases (synced data returns from the mnemonic); losing only the passkey or DeviceSecret on the same device orphans the device database, but restoring a mnemonic still reopens that account's local database with its unsynced changes.
  • Private browsing varies. Safari Private Browsing and Firefox private windows refuse OPFS, so Evolu falls back to per-tab in-memory databases and skips passkeys (NotPersisted). Chrome Incognito allows OPFS for the session, creating a passkey that outlives the wiped session.
  • Startup wait. The first render waits for the device database, and with a passkey, for user confirmation on every start and tab.

Try it

Try the live instant start and passkey playgrounds, read Local auth, or browse complete apps in Examples.

Local auth shipped in @evolu/common 8.28.0, @evolu/web 3.8.0, @evolu/react 11.3.0, @evolu/react-native 16.3.0, @evolu/vue 2.2.0, and @evolu/svelte 3.1.0. If something doesn't fit your app, open an issue.