Skip to content

Commit 66603d7

Browse files
KyleAMathewsclaude
andauthored
Update overview w/ Query-Driven Sync and other features/arguments (#812)
* Enhance overview.md with blog post content and Query-Driven Sync Updates the overview documentation to better reflect the content and features from the two DB blog posts (0.1 and 0.5): - Add compelling "Option C" narrative explaining the architecture problem TanStack DB solves (view-specific APIs vs load-everything) - Document Query-Driven Sync feature from 0.5 release: - Three sync modes: eager, on-demand, progressive - How component queries automatically become API calls - Request optimization (collapsing, delta loading, join batching) - Add concrete performance numbers: ~0.7ms updates for 100k items on M1 Pro, demonstrating truly instantaneous optimistic updates - Expand sync engine benefits section: - Easy real-time updates without WebSocket plumbing - Automatic side-effects and cache invalidation - Efficient delta updates enabling "load everything once" pattern These changes bridge the gap between the technical reference docs and the compelling narrative from the blog posts, helping developers understand both why TanStack DB exists and how to use it effectively. * Add end-user benefit emphasis: apps stay fast regardless of data size Highlights that apps can't get sluggish due to too much data, with queries over 100k+ rows completing in under a millisecond. This makes the end-user experience benefit clear early in the documentation. * Refine introduction with clearer problem-solution framing Rewrites the introduction to: - Lead with the problems TanStack DB solves (endpoint sprawl, client performance, network on interaction path) - Emphasize the end-user benefit upfront: interactions feel instantaneous, app stays fast regardless of data volume - Present the "new way" as numbered benefits rather than "Option C" framing - More action-oriented and benefit-focused language This makes the value proposition clearer and more compelling for developers evaluating TanStack DB. * Update README.md to match new overview.md messaging Aligns README with the refined overview.md framing: - Changes "client-first" to "client" to match new terminology - Adopts problem-solution framing (avoid endpoint sprawl, optimize client performance, take network off interaction path) - Emphasizes end-user benefit: app stays fast regardless of data - More action-oriented and benefit-focused language Keeps README concise while maintaining consistency with docs. * Update packages/db/README.md with new messaging Aligns the core package README with the refined messaging: - Updates tagline to "The reactive client store for your API" - Adds "solves the problems of building fast, modern apps" - Rewrites bullet points to focus on problem-solution framing: - Avoid endpoint sprawl (vs building custom endpoints) - Blazing fast queries (app stays fast regardless of data) - Instant interactions (network off interaction path) - Fine-grained reactivity (minimize re-rendering) Makes the npm package description more benefit-oriented. --------- Co-authored-by: Claude <[email protected]>
1 parent 44b5877 commit 66603d7

File tree

3 files changed

+80
-18
lines changed

3 files changed

+80
-18
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@
3737

3838
> Tanstack DB is currently in BETA. See [the release post](https://tanstack.com/blog/tanstack-db-0.1-the-embedded-client-database-for-tanstack-query) for more details.
3939
40-
The reactive client-first store for your API.
40+
The reactive client store for your API.
4141

42-
Stop building custom endpoints for every view. TanStack DB lets you query your data however your components need it—with a blazing-fast local query engine, real-time reactivity, and instant optimistic updates:
42+
TanStack DB solves the problems of building fast, modern apps, helping you:
4343

44-
- Sub-millisecond live queries with joins & aggregates
45-
- Fine-grained reactivity to minimize re-rendering
46-
- Optimistic mutations with automatic rollback
47-
- Works with REST, sync engines, or any data source
44+
- Avoid endpoint sprawl and network waterfalls by loading data into normalized collections
45+
- Optimise client performance with sub-millisecond live queries and real-time reactivity
46+
- Take the network off the interaction path with instant optimistic writes
47+
48+
Data loading is optimized. Interactions feel instantaneous. Your backend stays simple and your app stays blazing fast. No matter how much data you load.
4849

4950
<a href="https://tanstack.com/db" style="font-weight:bold" >Read the docs →</a>
5051
<br />

docs/overview.md

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,28 @@ id: overview
77

88
Welcome to the TanStack DB documentation.
99

10-
TanStack DB is the reactive client-first store for your API. Stop building custom endpoints for every view—TanStack DB lets you query your data however your components need it, with a blazing-fast local query engine, real-time reactivity, and instant optimistic updates.
10+
TanStack DB is the reactive client store for your API. It solves the problems of building fast, modern apps, helping you:
11+
12+
- avoid endpoint sprawl and network waterfalls by loading data into normalized collections
13+
- optimise client performance with sub-millisecond live queries and real-time reactivity
14+
- take the network off the interaction path with instant optimistic writes
15+
16+
Data loading is optimized. Interactions feel instantaneous. Your backend stays simple and your app stays blazing fast. No matter how much data you load.
17+
18+
## Remove the complexity from building fast, modern apps
19+
20+
TanStack DB lets you query your data however your components need it, with a blazing-fast local query engine, real-time reactivity and instant optimistic updates.
21+
22+
Instead of choosing between the least of two evils:
23+
24+
1. **view-specific APIs** - complicating your backend and leading to network waterfalls
25+
2. **load everything and filter** - leading to slow loads and sluggish client performance
26+
27+
TanStack DB enables a new way:
28+
29+
3. **normalized collections** - keep your backend simple
30+
4. **query-driven sync** - optimizes your data loading
31+
5. **sub-millisecond live queries** - keep your app fast and responsive
1132

1233
It extends TanStack Query with collections, live queries and optimistic mutations, working seamlessly with REST APIs, sync engines, or any data source.
1334

@@ -71,11 +92,41 @@ Collections can be populated in many ways, including:
7192

7293
Once you have your data in collections, you can query across them using live queries in your components.
7394

95+
#### Sync Modes
96+
97+
Collections support three sync modes to optimize data loading:
98+
99+
- **Eager mode** (default): Loads entire collection upfront. Best for <10k rows of mostly static data like user preferences or small reference tables.
100+
- **On-demand mode**: Loads only what queries request. Best for large datasets (>50k rows), search interfaces, and catalogs where most data won't be accessed.
101+
- **Progressive mode**: Loads query subset immediately, syncs full dataset in background. Best for collaborative apps needing instant first paint AND sub-millisecond queries.
102+
103+
With on-demand mode, your component's query becomes the API call:
104+
105+
```tsx
106+
const productsCollection = createCollection(
107+
queryCollectionOptions({
108+
queryKey: ['products'],
109+
queryFn: async (ctx) => {
110+
// Query predicates passed automatically in ctx.meta
111+
const params = parseLoadSubsetOptions(ctx.meta?.loadSubsetOptions)
112+
return api.getProducts(params) // e.g., GET /api/products?category=electronics&price_lt=100
113+
},
114+
syncMode: 'on-demand', // ← Enable query-driven sync
115+
})
116+
)
117+
```
118+
119+
TanStack DB automatically collapses duplicate requests, performs delta loading when expanding queries, optimizes joins into minimal batched requests, and respects your TanStack Query cache policies. You often end up with _fewer_ network requests than custom view-specific APIs.
120+
121+
See the [Query Collection documentation](../collections/query-collection.md#queryfn-and-predicate-push-down) for full predicate mapping details.
122+
74123
### Using live queries
75124

76125
Live queries are used to query data out of collections. Live queries are reactive: when the underlying data changes in a way that would affect the query result, the result is incrementally updated and returned from the query, triggering a re-render.
77126

78-
TanStack DB live queries are implemented using [d2ts](https://github.com/electric-sql/d2ts), a Typescript implementation of differential dataflow. This allows the query results to update _incrementally_ (rather than by re-running the whole query). This makes them blazing fast, usually sub-millisecond, even for highly complex queries.
127+
TanStack DB live queries are implemented using [d2ts](https://github.com/electric-sql/d2ts), a TypeScript implementation of differential dataflow. This allows the query results to update _incrementally_ (rather than by re-running the whole query). This makes them blazing fast, usually sub-millisecond, even for highly complex queries.
128+
129+
**Performance:** Updating one row in a sorted 100,000-item collection completes in ~0.7ms on an M1 Pro MacBook—fast enough that optimistic updates feel truly instantaneous, even with complex queries and large datasets.
79130

80131
Live queries support joins across collections. This allows you to:
81132

@@ -412,6 +463,16 @@ This pattern allows you to extend an existing TanStack Query application, or any
412463
413464
One of the most powerful ways of using TanStack DB is with a sync engine, for a fully local-first experience with real-time sync. This allows you to incrementally adopt sync into an existing app, whilst still handling writes with your existing API.
414465
466+
#### Why Sync Engines?
467+
468+
While TanStack DB works great with REST APIs, sync engines provide powerful benefits:
469+
470+
- **Easy real-time updates**: No WebSocket plumbing—write to your database and changes stream automatically to all clients
471+
- **Automatic side-effects**: When a mutation triggers cascading changes across tables, all affected data syncs automatically without manual cache invalidation
472+
- **Efficient delta updates**: Only changed rows cross the wire, making it practical to load large datasets client-side
473+
474+
This pattern enables the "load everything once" approach that makes apps like Linear and Figma feel instant.
475+
415476
Here, we illustrate this pattern using [ElectricSQL](https://electric-sql.com) as the sync engine.
416477
417478
```tsx

packages/db/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# @tanstack/db
22

3-
**A reactive client store for building super fast apps on sync**
3+
**The reactive client store for your API**
44

5-
TanStack DB extends TanStack Query with collections, live queries and optimistic mutations that keep your UI reactive, consistent and blazing fast 🔥
5+
TanStack DB solves the problems of building fast, modern apps. It extends TanStack Query with collections, live queries and optimistic mutations that keep your UI reactive, consistent and blazing fast 🔥
66

77
<p>
88
<a href="https://x.com/intent/post?text=TanStack%20DB&url=https://tanstack.com/db">
@@ -21,14 +21,14 @@ TanStack DB extends TanStack Query with collections, live queries and optimistic
2121

2222
## 💥 Visit the [TanStack/db](https://github.com/TanStack/db) repo for docs and details!
2323

24-
- 🔥 **blazing fast query engine**<br />
25-
for sub-millisecond live queries &mdash; even for complex queries with joins and aggregates
26-
- 🎯 **fine-grained reactivity**<br />
27-
to minimize component re-rendering
28-
- 💪 **robust transaction primitives**<br />
29-
for easy optimistic mutations with sync and lifecycle support
30-
- 🌟 **normalized data**<br />
31-
to keep your backend simple
24+
- 🚀 **Avoid endpoint sprawl**<br />
25+
Load data into normalized collections instead of building custom endpoints for every view
26+
- 🔥 **Blazing fast queries**<br />
27+
Sub-millisecond live queries with joins & aggregates—your app stays fast no matter how much data you load
28+
- **Instant interactions**<br />
29+
Take the network off the interaction path with optimistic writes that feel instantaneous
30+
- 🎯 **Fine-grained reactivity**<br />
31+
Minimize component re-rendering with precise updates
3232

3333
---
3434

0 commit comments

Comments
 (0)