db-core/persistence

Add SQLite-backed durable persistence to TanStack DB collections across platforms.

3.9k|254|Updated Mar 11, 2025
One-click install
npx skills add https://github.com/TanStack/db --skill db-core-persistence
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: db-core/persistence
Source: https://github.com/TanStack/db/tree/main/packages/db/skills/db-core/persistence
Command: npx skills add https://github.com/TanStack/db --skill db-core-persistence

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

SQLite-backed persistence for TanStack DB collections, enabling durable local storage and offline access. persistedCollectionOptions wraps any adapter (Electric, Query, PowerSync, or local-only) to provide a durable local store. Platform adapters: browser OPFS, React Native op-sqlite, Expo sqlite, Electron IPC, Node better-sqlite3, Capacitor, Tauri, Cloudflare Durable Objects. Multi-tab/multi-process coordination via BrowserCollectionCoordinator / ElectronCollectionCoordinator / SingleProcessCoordinator. schemaVersion for migration resets. Local-only mode for offline-first without a server.

Core Features & Use Cases

  • Cross-platform persistence adapters and a unified API.
  • Durable local storage with multi-tab coordination for offline-first apps.
  • SchemaVersioned persistence with local-only and synced configurations.

Quick Start

Create a persisted TanStack DB collection using persistedCollectionOptions with a platform persistence adapter and a coordinator to enable cross-tab durability.

Frequently Asked Questions about db-core/persistence

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add SQLite-backed persistence to TanStack DB collections?

To add SQLite-backed persistence to TanStack DB collections, wrap your adapter with persistedCollectionOptions and a platform-specific persistence adapter to enable durable local storage.

Does TanStack DB persistence work across React Native, Electron, and browser platforms?

Yes, TanStack DB persistence works cross-platform by using specific adapters like browser OPFS, React Native op-sqlite, Expo sqlite, Electron IPC, and Node better-sqlite3 for unified local storage.

How do I coordinate offline-first SQLite writes across multiple browser tabs?

To coordinate offline-first SQLite writes across multiple browser tabs, use the BrowserCollectionCoordinator within persistedCollectionOptions to manage concurrent writers and ensure data consistency.

What is the best way to handle schema migrations when using durable local storage?

The best way to handle schema migrations with durable local storage is defining a schemaVersion in persistedCollectionOptions, which triggers automatic collection resets when the schema changes.

Can I use TanStack DB for offline-first apps without a backend server?

Yes, you can use TanStack DB for offline-first apps without a server by configuring a local-only mode adapter within persistedCollectionOptions to store data entirely on the device.

Do I need a coordinator for single-process Node.js SQLite persistence?

For single-process Node.js SQLite persistence, you use the SingleProcessCoordinator within persistedCollectionOptions to manage the local-only or synced collection lifecycle without multi-tab conflicts.