Skip to content
Source
Sign inSign up
TanStack/query

Architecture

Describes commit 8363fa3Updated Made by anthropic/claude-haiku-5.5

Overview

A library for fetching, caching, synchronizing and updating server state in web apps.

What it does

  • Fetches and caches async data through queries and mutations.
  • Keeps cached data fresh with refetching, invalidation and background updates.
  • Provides framework bindings for React, Preact, Solid, Svelte, Vue, Angular and Lit.
  • Persists the cache to storage and syncs it across browser tabs.

Main parts

  • query-core: the framework-agnostic engine with QueryClient, QueryCache and observers.
  • Framework adapters: react-query, preact-query, solid-query, svelte-query, vue-query, angular-query and lit-query.
  • Devtools packages: one devtools package per framework, built on query-devtools.
  • Persistence packages: query-persist-client-core and the storage persisters built on it.
  • eslint-plugin-query and query-codemods for linting and migration.

How the parts work together

  • Each adapter re-exports query-core and adds hooks or controllers on top.
  • Adapters create observers from query-core and subscribe them to framework state.
  • Persisters save and restore the QueryClient state through query-persist-client-core.

Where to start

  • Read packages/query-core/src/index.ts for the public core API.
  • Read packages/react-query/src/index.ts to see how an adapter re-exports core.
  • Read packages/query-persist-client-core/src/index.ts for persistence.