Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History

README.md

Outline

@tanstack/react-native-db-sqlite-persistence

Thin SQLite persistence for React Native apps (including Expo runtime).

Public API

  • createReactNativeSQLitePersistence(...)
  • persistedCollectionOptions(...) (re-exported from core)

Quick start

import { open } from '@op-engineering/op-sqlite'
import { createCollection } from '@tanstack/db'
import {
  createReactNativeSQLitePersistence,
  persistedCollectionOptions,
} from '@tanstack/react-native-db-sqlite-persistence'

type Todo = {
  id: string
  title: string
  completed: boolean
}

const database = open({
  name: `tanstack-db.sqlite`,
  location: `default`,
})

// One shared persistence instance for the whole database.
const persistence = createReactNativeSQLitePersistence({
  database,
})

export const todosCollection = createCollection(
  persistedCollectionOptions<Todo, string>({
    id: `todos`,
    getKey: (todo) => todo.id,
    persistence,
    schemaVersion: 1, // Per-collection schema version
  }),
)

Notes

  • The same API is used for React Native and Expo runtimes.
  • createReactNativeSQLitePersistence is shared across collections.
  • Mode defaults (sync-present vs sync-absent) are inferred from whether a sync config is present in persistedCollectionOptions.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.