tanstack-db

Create reactive client-side data storage with normalized collections and live queries.

3|Updated May 11, 2026
One-click install
npx skills add https://github.com/JeromyJSmith/lattice-platform --skill tanstack-db-jeromyjsmith
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-db
Source: https://github.com/JeromyJSmith/lattice-platform/tree/main/.agents/skills/skills/tanstack-db
Command: npx skills add https://github.com/JeromyJSmith/lattice-platform --skill tanstack-db-jeromyjsmith

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TanStack DB helps you avoid manual state management and brittle cache invalidation by providing a reactive, normalized client-side data layer that stays in sync with your server-driven data.

Core Features & Use Cases

  • Collections with sync handlers: Create normalized collections tied to your API, then implement server synchronization for inserts, updates, and deletes.
  • Live queries: Subscribe to SQL-like queries that automatically recompute results when underlying collection data changes.
  • Optimistic mutations: Instantly update the UI with automatic rollback when server writes fail, so user interactions feel fast and consistent.

Quick Start

Create a collection with queryCollectionOptions wired to your API, then use useLiveQuery to define a live query that filters and renders the results.

Frequently Asked Questions about tanstack-db

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

FAQPage Schema
How do I build live queries for normalized client-side data collections?

Live queries automatically recompute SQL-like query results when underlying normalized collection data changes. You create collections tied to your API, then use live query operators to subscribe to filtered, sorted, or joined subsets for reactive UI updates.

How do optimistic mutations work in a reactive client store?

Optimistic mutations instantly update the UI while synchronizing with the server, and automatically roll back if the server write fails. This ensures user interactions feel fast and consistent without manual state recovery logic.

What is the best way to avoid manual cache invalidation in React applications?

A reactive client-side data layer stays in sync with server-driven data to avoid manual cache invalidation. Normalized collections with sync handlers manage inserts, updates, and deletes, keeping local state consistent automatically.

Can I sync local-first collections with server data for large datasets?

Yes, normalized collections support on-demand loading for large datasets. Sync handlers wire collections to your API, enabling local-first interactivity over server data for filtered lists and sorted subsets.

Do I need TanStack Query to use TanStack DB for reactive queries?

Yes, building live queries requires @tanstack/react-db and @tanstack/query-db-collection. These dependencies define collection sync modes and provide operators that map reactive queries to network requests.

Why should I use a normalized client-side database instead of manual state management?

A normalized client-side database prevents brittle state management by providing a reactive data layer. It handles incremental live query recomputation and cross-collection joins, eliminating the need to manually track and update dependent UI states.