@tanstack/expo-db-sqlite-persistence
v0.1.5
Published
Expo SQLite persisted collection adapter for TanStack DB
Readme
@tanstack/expo-db-sqlite-persistence
Thin SQLite persistence for Expo apps using the official expo-sqlite adapter.
Public API
createExpoSQLitePersistence(...)persistedCollectionOptions(...)(re-exported from core)- Advanced driver entrypoint:
@tanstack/expo-db-sqlite-persistence/expo-sqlite-driver
Quick start
import * as SQLite from 'expo-sqlite'
import { createCollection } from '@tanstack/db'
import {
createExpoSQLitePersistence,
persistedCollectionOptions,
} from '@tanstack/expo-db-sqlite-persistence'
type Todo = {
id: string
title: string
completed: boolean
}
const database = await SQLite.openDatabaseAsync(`tanstack-db.sqlite`)
// One shared persistence instance for the whole database.
const persistence = createExpoSQLitePersistence({
database,
})
export const todosCollection = createCollection(
persistedCollectionOptions<Todo, string>({
id: `todos`,
getKey: (todo) => todo.id,
persistence,
schemaVersion: 1, // Per-collection schema version
}),
)Notes
- This package targets the official
expo-sqliteasync database API. - Requires
expo-sqlite^55.0.10(documented as a peer dependency). createExpoSQLitePersistenceis shared across collections.- Mode defaults (
sync-presentvssync-absent) are inferred from whether asyncconfig is present inpersistedCollectionOptions. - The React Native
op-sqlitewrapper remains available in@tanstack/react-native-db-sqlite-persistence. - Expo web is not part of the emulator-backed E2E path in this package. Use the browser SQLite package for browser-focused persistence coverage.
E2E
pnpm --filter @tanstack/expo-db-sqlite-persistence test:e2eruns the shared Node-backed conformance suite.pnpm --filter @tanstack/expo-db-sqlite-persistence test:e2e:expo:iosruns the real Expo iOS Simulator path.pnpm --filter @tanstack/expo-db-sqlite-persistence test:e2e:expo:androidruns the real Expo Android Emulator path.
