Open History to see the last commit
1# @tanstack/expo-db-sqlite-persistence
2
3Thin SQLite persistence for Expo apps using the official `expo-sqlite` adapter.
4
5## Public API
6
7- `createExpoSQLitePersistence(...)`
8- `persistedCollectionOptions(...)` (re-exported from core)
9- Advanced driver entrypoint:
10 `@tanstack/expo-db-sqlite-persistence/expo-sqlite-driver`
11
12## Quick start
13
14```ts
15import * as SQLite from 'expo-sqlite'
16import { createCollection } from '@tanstack/db'
17import {
18 createExpoSQLitePersistence,
19 persistedCollectionOptions,
20} from '@tanstack/expo-db-sqlite-persistence'
21
22type Todo = {
23 id: string
24 title: string
25 completed: boolean
26}
27
28const database = await SQLite.openDatabaseAsync(`tanstack-db.sqlite`)
29
30// One shared persistence instance for the whole database.
31const persistence = createExpoSQLitePersistence({
32 database,
33})
34
35export const todosCollection = createCollection(
36 persistedCollectionOptions<Todo, string>({
37 id: `todos`,
38 getKey: (todo) => todo.id,
39 persistence,
40 schemaVersion: 1, // Per-collection schema version
41 }),
42)
43```
44
45## Notes
46
47- This package targets the official `expo-sqlite` async database API.
48- Requires `expo-sqlite` `^55.0.10` (documented as a peer dependency).
49- `createExpoSQLitePersistence` is shared across collections.
50- Mode defaults (`sync-present` vs `sync-absent`) are inferred from whether a
51 `sync` config is present in `persistedCollectionOptions`.
52- The React Native `op-sqlite` wrapper remains available in
53 `@tanstack/react-native-db-sqlite-persistence`.
54- Expo web is not part of the emulator-backed E2E path in this package. Use the
55 browser SQLite package for browser-focused persistence coverage.
56
57## E2E
58
59- `pnpm --filter @tanstack/expo-db-sqlite-persistence test:e2e`
60 runs the shared Node-backed conformance suite.
61- `pnpm --filter @tanstack/expo-db-sqlite-persistence test:e2e:expo:ios`
62 runs the real Expo iOS Simulator path.
63- `pnpm --filter @tanstack/expo-db-sqlite-persistence test:e2e:expo:android`
64 runs the real Expo Android Emulator path.