IndexedDB Persistence for ElectricSQL + TanStack DB

Implement a custom IndexedDB adapter for persistent offline storage in ElectricSQL and TanStack DB.

Updated Dec 21, 2025
One-click install
npx skills add https://github.com/shotleybuilder/sertantai-legal --skill indexeddb-persistence-for-electricsql-tanstack-db
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: IndexedDB Persistence for ElectricSQL + TanStack DB
Source: https://github.com/shotleybuilder/sertantai-legal/tree/main/.claude/skills/indexeddb-electric-persistence
Command: npx skills add https://github.com/shotleybuilder/sertantai-legal --skill indexeddb-persistence-for-electricsql-tanstack-db

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires idb-keyval, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill enables robust offline data storage for applications using ElectricSQL and TanStack DB, overcoming limitations of default memory-only or small localStorage storage.

Core Features & Use Cases

  • Persistent Offline Storage: Leverages IndexedDB for large datasets, ensuring data survives page reloads and browser closures.
  • Delta Sync Optimization: Persists ElectricSQL's sync offset, allowing for efficient resumption of synchronization from the last known point.
  • Handles Large Datasets: Solves the "localStorage quota exceeded" error by providing a much larger storage capacity.
  • Use Case: A field service application needs to store thousands of customer records and service logs offline. This Skill ensures all data is available even without a network connection and syncs efficiently when connectivity is restored.

Quick Start

Use the IndexedDB Storage adapter to initialize a TanStack DB collection for offline use.

Frequently Asked Questions about IndexedDB Persistence for ElectricSQL + TanStack DB

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

FAQPage Schema
How do I persist ElectricSQL data offline using IndexedDB instead of localStorage?

You can persist ElectricSQL data offline by implementing a custom IndexedDB adapter. This approach solves localStorage size limits, manages large datasets, and ensures data survives page reloads by storing data and sync metadata in separate IndexedDB stores.

Why does my TanStack DB collection lose data after a browser refresh?

TanStack DB loses data after a refresh if using memory-only storage. You need persistent offline storage via an IndexedDB adapter to ensure data survives browser closures and handles large datasets effectively across sessions.

How do I resume ElectricSQL delta sync efficiently after going offline?

To resume ElectricSQL delta sync efficiently, you must persist the sync offset. This Skill stores the sync metadata in a separate IndexedDB store, allowing synchronization to resume from the last known point when connectivity is restored.

Can I use IndexedDB to avoid localStorage quota exceeded errors with TanStack DB?

Yes, you can avoid the localStorage quota exceeded error by using an IndexedDB storage adapter. IndexedDB provides a much larger storage capacity, making it suitable for handling thousands of offline records in TanStack DB collections.

Do I need idb-keyval to set up offline persistence for ElectricSQL?

Yes, this offline persistence implementation requires the idb-keyval dependency. It leverages this library to manage the custom IndexedDB adapter that stores ElectricSQL data and sync offsets separately.