DB
Take the network off the interaction path.
DB turns API data into typed collections, runs live relational queries over them, and applies optimistic writes immediately while persistence catches up.
collection
3 records
live query
2 open
transaction
ready
persist on your cadence
useLiveQuery(openTodos)
readyThe live result changes immediately. Persistence either confirms the local state or removes it automatically when the handler fails.
A third path
Stop choosing between endpoint sprawl and loading everything.
Normalized collections keep the backend shape simple. Components can ask a fast local query engine for the exact joined, filtered, and aggregated view they need.
01
Endpoint per screen
The backend inherits every view and relationship the product invents.
02
Load everything
The browser receives broad payloads and repeatedly recomputes derived views.
03
Collections + live queries
Keep normalized records locally and ask for each view as a reactive query.
from issues
join projects on projectId
where status = open3 results 路 inferred output
Live relational queries
Describe the view. DB keeps the result current.
Queries can filter, project, join, include, order, group, and aggregate across collections. Differential dataflow updates affected results incrementally as the underlying records change.
On-demand sync
The component query can shape the request.
With on-demand sync, predicates, ordering, limits, and offsets can reach the collection loader. Translate them into API parameters and load only the subset active views require.
active query
team = platform 路 limit 20
load subset
ctx.meta.loadSubsetOptions
API request
GET /issues?team=platform&limit=20
Brownfield by design
Adopt collections without replacing the backend.
Start from the data source already in production. Components use the same live-query model whether records arrive through TanStack Query, an API, local persistence, or a sync engine.
TanStack Query
Keep the Query client and materialize fetched rows into a collection.
REST or GraphQL
Load records and persist mutations through the API you already own.
Sync engine
Use Electric, PowerSync, RxDB, TrailBase, or a custom collection creator.
same collection 路 same live query