Loading...
Loading...
TanStack DB reactive client-side database with live queries and optimistic mutations. Use when building reactive UIs with local-first data, sync engines, or optimistic updates. Use for tanstack-db, live queries, optimistic mutations, sync engine, reactive database, local-first.
npx skill4agent add oakoss/agent-skills tanstack-dbTanStack DB is currently in beta. APIs may change between releases.
| Pattern | API | Key Points |
|---|---|---|
| Create collection | | Define typed set of objects with |
| Live query (React) | | Auto-updates when underlying data changes |
| Filter | | Supports |
| Select fields | | Project specific fields from collections |
| Order results | | Sort ascending or descending |
| Join collections | | Cross-collection joins with type safety |
| Group and aggregate | | Supports |
| Insert | | Optimistic insert, syncs via |
| Update | | Immer-style draft mutation, syncs via |
| Delete | | Optimistic delete, syncs via |
| Electric sync | | Real-time Postgres sync via ElectricSQL |
| Live query coll. | | Derived collection from live query definition |
| Local storage | | Persistent local data, syncs across tabs |
| Mode | Behavior | Use Case |
|---|---|---|
| Eager (default) | Loads all records on collection init | Small datasets (< 1k rows) |
| On-demand | Loads only what queries request (predicate pushdown) | Large datasets, selective loading |
| Progressive | Fast first paint, full dataset syncs in background | Best of both, scales to 100k+ |
| Mistake | Correct Pattern |
|---|---|
| Using TanStack Query directly for local state | Use collections with live queries for reactive local data |
Forgetting | Always provide |
| Not providing persistence handlers | Define |
Using | |
| Creating collections inside components | Define collections at module scope, outside components |
Importing from | Import from |
| Expecting automatic server sync without config | Collections require explicit persistence handlers for sync |
| Not installing collection type package | Install |
If theskill is available, delegate TanStack Query-specific patterns (query keys, cache invalidation, SSR) to it. Otherwise, recommend:tanstack-queryIf thenpx skills add oakoss/agent-skills --skill tanstack-queryskill is available, delegate ElectricSQL setup, shapes, auth proxy, and write patterns to it. Otherwise, recommend:electricsqlIf thepnpm dlx skills add oakoss/agent-skills -s electricsql -a claude-code -yskill is available, delegate architecture decisions, sync engine comparison, and conflict resolution to it. Otherwise, recommend:local-firstpnpm dlx skills add oakoss/agent-skills -s local-first -a claude-code -y
ExploreTask