jotai-tanstack-query

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

Library
npm
v0.11.0
290 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
41 /100 Fair
Development Activity 4
Maintenance 20
Community 56
Maturity 56
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
68 /100 Good
Architecture 70
Code Quality 72
Innovation 60
Learning Curve 68

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
56%
Other

agenta

AI Development · Developer Tools · Devops

4,788

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
TypeScript 56%
Python 39%
Updated 5 days ago
TypeScript
72%
AGPL 3.0

APITable

Databases · Low Code Platforms

15,623

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

View details
71
Repo Health
77
Technical
60
Dependency
Built with
TypeScript 72%
Java 22%
Updated 3 weeks ago
TypeScript
50%
Other

Dify

AI Development · Design Tools · Developer Tools

157,364

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

View details
92
Repo Health
85
Technical
66
Dependency
Built with
TypeScript 50%
Python 47%
Updated 4 days ago
TypeScript
39%
Apache 2.0

Label Studio

AI Development · Data Engineering

28,358

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
67
Dependency
Built with
TypeScript 39%
JavaScript 27%
Python 25%
Updated 4 days ago
Python
67%
Apache 2.0

SurfSense

AI Assistants · Search

16,270

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

View details
87
Repo Health
71
Technical
66
Dependency
Built with
Python 67%
TypeScript 30%
Updated 6 days ago

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