# Tanstack Db

> Comprehensive React-focused guide for TanStack DB and community integrations (Dexie.js, PGLite). Use when writing or debugging code that uses @tanstack/react-db for live queries, optimistic mutations, or local-first synchronization.

- **Type:** Skill
- **Install:** `agentstack add skill-fellipeutaka-leon-tanstack-db`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [fellipeutaka](https://agentstack.voostack.com/s/fellipeutaka)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [fellipeutaka](https://github.com/fellipeutaka)
- **Source:** https://github.com/fellipeutaka/leon/tree/main/skills/tanstack-db

## Install

```sh
agentstack add skill-fellipeutaka-leon-tanstack-db
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# 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

1. **Schemas Validate Client State**: Schemas are StandardSchema-compatible (Zod, Valibot, etc.). They validate client mutations, not server data. `TInput` must be a superset of `TOutput` for updates to work correctly.
2. **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.
3. **Conditional Queries**: To disable a query, return `undefined` or `null` from the callback.
4. **Router Preloading**: Preload data in your route loader (`await collection.preload()`), then consume it with `useLiveQuery` in the component.

## Advanced Topics

For deep dives into specific areas, consult the following references:

- **Collections & Schemas**: See [references/core-concepts.md](references/core-concepts.md) for collection types, sync modes (eager, on-demand, progressive), and schema constraints.
- **Queries & Hooks**: See [references/live-queries.md](references/live-queries.md) for the fluent SQL-like API, expression functions, `useLiveSuspenseQuery`, and query composition patterns.
- **Mutations & Transactions**: See [references/mutations.md](references/mutations.md) for optimistic updates, mutation merging, temporary ID handling, and direct `QueryCollection` writes.
- **Error Handling**: See [references/error-handling.md](references/error-handling.md) for specific error types (e.g., `DuplicateKeyError`, `SchemaValidationError`) and transaction states.
- **Community Integrations**: See [references/community-integrations.md](references/community-integrations.md) for Dexie.js (IndexedDB) and PGLite (WASM PostgreSQL + Drizzle ORM) adapters.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [fellipeutaka](https://github.com/fellipeutaka)
- **Source:** [fellipeutaka/leon](https://github.com/fellipeutaka/leon)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-fellipeutaka-leon-tanstack-db
- Seller: https://agentstack.voostack.com/s/fellipeutaka
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
