jotai-tanstack-query

A Jotai integration library that exposes TanStack Query as composable atoms.

Library
npm
v0.11.0
287stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
40/100Fair
Development Activity4
Maintenance20
Community56
Maturity52
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
68/100Good
Architecture70
Code Quality72
Innovation60
Learning Curve68

jotai-tanstack-query bridges Jotai’s atomic state model with TanStack Query’s data-fetching engine, exposing query and mutation state as regular Jotai atoms (atomWithQuery, atomWithMutation, atomWithInfiniteQuery, and their suspense variants) so query results can be composed with the rest of an app’s atom graph using useAtom/useAtomValue instead of a separate useQuery hook API. It supports Jotai v2 and TanStack Query v5, and can be adopted incrementally alongside existing useQuery calls as long as both share the same QueryClient instance.

What You Get

  • atomWithQuery and atomWithSuspenseQuery atoms that mirror TanStack Query’s useQuery/useSuspenseQuery behavior
  • atomWithMutation and atomWithMutationState for mutation state as atoms
  • atomWithInfiniteQuery / atomWithSuspenseInfiniteQuery for paginated, load-more data
  • atomWithQueries for running and optionally combining multiple parallel queries, plus a ready-made QueryClientAtomProvider

Common Use Cases

  • Deriving other atoms directly from server data by composing atomWithQuery results with plain Jotai atoms
  • Incrementally migrating a TanStack Query codebase to Jotai-based state without rewriting existing useQuery call sites
  • Building SSR/Next.js App Router pages that hydrate a shared QueryClient across Jotai and TanStack Query
  • Running dynamic parallel queries (e.g. one query per item in a list) via atomWithQueries with a combine function

Under The Hood

Architecture: Each atomWith* function (atomWithQuery.ts, atomWithMutation.ts, atomWithInfiniteQuery.ts, etc.) is a thin layer over a shared baseAtomWithQuery.ts, which constructs a TanStack Query QueryObserver/MutationObserver from options resolved via a getOptions(get) callback, subscribes to observer updates inside the atom’s onMount, and stores the QueryClient itself in a dedicated _queryClientAtom so all query atoms resolve the same client instance without prop drilling. Tech Stack: Written in TypeScript, built with a Rollup/Preconstruct-style multi-entry setup producing separate ESM/CJS/d.ts bundles for the root export and a react.ts subpath (for QueryClientAtomProvider), with peer dependencies on jotai v2 and @tanstack/react-query v5 and no other runtime dependencies. Code Quality: The tests directory covers each atomWith* function plus the provider component using vitest, verifying loading/success/error states and query-client sharing across atoms; the code is organized by one file per query variant, minimizing cross-file coupling and keeping each atom’s observer-subscription logic easy to audit in isolation. API Design: The API deliberately mirrors TanStack Query’s own hook signatures (same options objects, same result shape with data/isPending/isError) so existing TanStack Query knowledge transfers directly, and the library explicitly supports incremental adoption alongside plain useQuery calls sharing the same QueryClient.

Used by 5 apps in this directory

TypeScript
59%
Other

agenta

Developer Tools · Devops · AI Development

4,489

The open-source LLMOps platform unifying prompt engineering, evaluation, and observability for teams building reliable LLM applications.

View details
91
Repo Health
77
Technical
67
Dependency
Built with
TypeScript59%
Python39%
Updated today
TypeScript
72%
AGPL 3.0

APITable

Low Code Platforms · Databases

15,526

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
53
Repo Health
77
Technical
60
Dependency
Built with
TypeScript72%
Java22%
Updated 9 months ago
TypeScript
50%
Other

Dify

No Code Platforms · AI Development · Developer Tools

152,883

Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.

View details
92
Repo Health
85
Technical
71
Dependency
Built with
TypeScript50%
Python47%
Updated today
TypeScript
38%
Apache 2.0

Label Studio

AI Development · Data Engineering

28,083

Label Studio is an open-source, multi-type data labeling platform that lets teams annotate images, text, audio, video, and time series data with a configurable XML-based UI and export annotations in formats ready for any ML framework.

View details
93
Repo Health
87
Technical
68
Dependency
Built with
TypeScript38%
JavaScript27%
Python25%
Updated today
Python
69%
Apache 2.0

SurfSense

Search · AI Assistants

15,960

The open-source, unlimited NotebookLM alternative with real-time collaboration, a desktop app, and no vendor lock-in.

View details
88
Repo Health
71
Technical
66
Dependency
Built with
Python69%
TypeScript28%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search