offline

Persist TanStack DB mutations offline with an outbox and automatic retries.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Offline transaction support for TanStack DB provides durable, offline-capable mutations by persisting an outbox and coordinating execution across tabs or devices. It ensures data integrity during disconnects and automatic recovery when connectivity returns.

Core Features & Use Cases

  • Persistent outbox using IndexedDB/localStorage
  • Leader election to avoid duplicate processing across tabs
  • Retry with exponential backoff and idempotency keys for at-least-once delivery
  • Online fallback when storage is unavailable; React Native support via a separate entry point
  • Integration with db-core and mutations-optimistic to wrap vanilla mutations with offline persistence
  • Out-of-band replay to apply pending mutations on startup or reconnect
  • Optional storage adapters and configurable detectors for connectivity changes

Quick Start

Initialize the Offline Executor and wait for initialization before creating transactions.

Frequently Asked Questions about offline

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

FAQPage Schema
How do I handle offline mutations and sync them when connectivity returns?

Leader election coordinates offline transaction processing across multiple open browser tabs, designating a single leader tab to execute the persistent outbox and preventing duplicate mutations during disconnects.

What is the best way to ensure durable transaction delivery during network disconnects?

Durable transaction delivery during disconnects uses a persistent outbox for offline storage, retry mechanisms with exponential backoff, and idempotency keys to guarantee at-least-once execution when connectivity returns.

Does TanStack DB offline transaction support work with React Native?

Yes, offline transaction support works with React Native via a separate entry point, providing the same persistent outbox, leader election, and automatic retry capabilities for mobile environments with intermittent connectivity.

How do I initialize offline persistence before creating TanStack DB transactions?

You initialize the Offline Executor and wait for its initialization process to complete before creating transactions, ensuring the persistent outbox and storage adapters are fully prepared to capture mutations.

What happens to offline mutations if IndexedDB or localStorage is unavailable?

When storage is unavailable, the offline executor falls back to an online mode, bypassing persistent outbox storage and processing mutations directly while skipping offline durability guarantees.