tanstack-db
Installation
SKILL.md
TanStack DB (React)
Quick Start
TanStack DB is a local-first database and reactivity layer. For React applications, it provides useLiveQuery and optimistic mutations with sub-millisecond updates powered by d2ts.
Core Guidelines
- Schemas Validate Client State: Schemas are StandardSchema-compatible (Zod, Valibot, etc.). They validate client mutations, not server data.
TInputmust be a superset ofTOutputfor updates to work correctly. - Dependency Arrays: All query hooks require dependency arrays as the last argument, identical to
useEffect. Include all external values. Omit to run on every render, or use[]for static queries. - Conditional Queries: To disable a query, return
undefinedornullfrom the callback. - Router Preloading: Preload data in your route loader (
await collection.preload()), then consume it withuseLiveQueryin the component.
Advanced Topics
For deep dives into specific areas, consult the following references: