You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TanStack DB is a reactive client-side data store that provides normalized collections, sub-millisecond live queries via differential dataflow (d2ts), and instant optimistic mutations with automatic rollback. It supports multiple data sources (REST APIs via TanStack Query, sync engines like ElectricSQL/PowerSync/RxDB/TrailBase, and local storage) through a unified collection API with framework adapters for React, Vue, Svelte, Solid, and Angular.
Domains
Domain
Description
Skills
Collection Setup & Schema
Creating and configuring typed collections from any data source, with schema validation and adapter-specific sync patterns
collection-setup
Live Query Construction
Building SQL-like reactive queries with expressions, joins, aggregations, and incremental view maintenance
live-queries
Framework Integration
Binding live queries to UI framework components using hooks, dependency tracking, Suspense, and pagination
framework-integration
Mutations & Optimistic State
Writing data with instant optimistic feedback, transaction lifecycles, and automatic rollback
mutations-optimistic
Meta-Framework Integration
Client-side preloading of collections in route loaders for TanStack Start, Next.js, Remix, etc.
meta-framework
Custom Adapter Authoring
Building custom collection adapters that implement the SyncConfig contract
custom-adapter
Offline Transactions
Offline-first transaction queueing with persistence, retry, and multi-tab coordination
Always prefer query operators over JS — Live queries are incrementally maintained via D2 differential dataflow. A .where(eq(...)) only recomputes the delta on data changes, while .filter() in JS re-runs from scratch. This applies even for trivial transformations.
The update API is Immer-style — collection.update(id, (draft) => { draft.title = "new" }) not collection.update(id, { ...item, title: "new" }). This is the single most common mutation API mistake AI agents make.
Agents hallucinate mutation APIs — The mutation surface has nuance (handler signatures, ambient transaction context, createOptimisticAction vs createTransaction). Agents generate plausible-looking but wrong code.
Collection type selection matters — Don't default to bare createCollection or localOnlyCollectionOptions. Each backend has a dedicated adapter that handles sync, handlers, and utilities correctly.
localOnly is a valid prototyping strategy — localOnlyCollectionOptions → real backend adapter is a clean upgrade path.
Offline is hard — only when needed — Don't steer users toward offline unless they need it. PowerSync/RxDB handle their own local persistence, which is different from offline transaction queuing.
SSR is not supported yet — Collections are client-side only. Routes using collections must set ssr: false. Preloading happens in client-side route loaders, not on the server.
Transactions stack — Concurrent transactions build optimistic state on top of each other. Use TanStack Pacer for sequential execution when ordering matters.
Tensions
Tension
Skills
Agent implication
Simplicity vs. correctness in sync
collection-setup ↔ custom-adapter
Agents use localOnly or eager mode for everything; production needs adapter-specific patterns
Optimistic speed vs. data consistency
mutations-optimistic ↔ collection-setup
Agents apply optimistic updates without considering rollback UX or awaiting refetch
Query expressiveness vs. IVM constraints
live-queries ↔ framework-integration
Agents write SQL-style queries that violate IVM constraints (equality joins only, orderBy for limit, etc.)
Offline complexity vs. app simplicity
offline ↔ mutations-optimistic
Agents add offline-transactions to apps that only need basic optimistic mutations
Cross-References
From
To
Reason
framework-integration
meta-framework
Hooks render data; loaders preload it. Both needed for production routing.
meta-framework
framework-integration
Preloaded collections consumed by hooks; hook API informs what to preload.
collection-setup
mutations-optimistic
Mutation handlers configured at setup time, execute during mutations.
mutations-optimistic
collection-setup
Handler signatures depend on adapter (Electric txid, Query refetch).