Skip to content

TanStack DB

Reactive client store for building super-fast apps. With sub-millisecond reactivity and instant local writes.

What is TanStack DB?

TanStack DB is a reactive, client-first store that keeps your UI reactive, consistent and blazing fast 🔥

Why do we need it?

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:

  • avoid endpoint sprawl and network waterfalls
  • optimise client performance and re-rendering
  • take the network off the interaction path

Data loading is optimized. Interactions feel instantaneous. Your backend stays simple and your app stays blazing fast. No matter how much data you load.

Use cases

TanStack DB is ideal for:

  • modern apps that need fast, responsive UI
  • collaborative apps where multiple users edit shared data
  • applications combining structured data (via Postgres Sync) with real-time streams (via Durable Streams)
  • applications that combine real-time sync with API-based data fetching
  • any app that needs a reactive, queryable client-side data store

How it works

Built on a Typescript implementation of differential dataflow, TanStack DB provides three core primitives:

  1. collections a unified data layer to load data into
  2. live queries super-fast reactivity using differential dataflow
  3. optimistic mutations that tie into the sync machinery

Data flow

TanStack DB acts as the client-side data layer in the Electric ecosystem. Data flows from your backend through Electric's sync primitives into TanStack DB, which then powers your reactive UI components.

You can load and sync data into it from multiple sources, including your API, Postgres Sync and Durable Streams.

TanStack DB then provides a unified, reactive interface to the data.

Query-driven sync

When used with Postgres Sync, TanStack DB leverages progressive data loading to implement query-driven sync.

This means that you can progressively sync data into your app, in response to navigation, user input and events, just by defining live queries against your local client store.

Learn more

See the blog post on query-driven sync and the interactive guide to TanStack DB, how it works and why it might change the way you build apps:

TanStack DB 0.5 . Query-Driven SyncAn Interactive Guide to TanStack DB

Showcase

See applications built with TanStack DB in the TanStack Showcase.

More information

See the Quickstart and TanStack docs.