Skip to main content
@convex-dev/react-query bridges Convex real-time subscriptions with TanStack Query, giving you live-updating data in your React app without polling or manual cache invalidation. When a Convex query result changes on the server, the update is pushed to your client instantly. Your TanStack Query cache stays fresh automatically — no queryClient.invalidateQueries() needed.

Quickstart

Install the package and wire up your first reactive query in minutes.

How it works

Learn how Convex subscriptions integrate with the TanStack Query cache.

API Reference

Full reference for ConvexQueryClient, convexQuery, and convexAction.

Guides

Deep dives into queries, mutations, authentication, and SSR.

Why use this library?

Convex pushes new query results to your client over a WebSocket whenever the underlying data changes. TanStack Query is the most popular data-fetching library for React. This adapter connects them so you can use the full TanStack Query API — useQuery, useSuspenseQuery, useMutation, devtools, and more — while getting Convex’s real-time guarantees for free.

No stale data

Results are pushed from the server; staleTime: Infinity is set automatically so TanStack Query never marks Convex data as stale.

No manual invalidation

Forget invalidateQueries(). The ConvexQueryClient updates the cache whenever the server pushes a new result.

Type-safe queries

Full TypeScript inference for function arguments and return types using Convex’s generated api object.

SSR ready

Fetch consistent query snapshots on the server with ConvexHttpClient and hydrate on the client.

Quick look

quickstart.tsx
1

Install the package

Add @convex-dev/react-query along with its peer dependencies.
2

Create ConvexQueryClient

Instantiate a ConvexQueryClient and connect it to your TanStack QueryClient.
3

Wrap your app

Provide both clients to your React tree.
4

Query with convexQuery

Use useQuery with the convexQuery options factory for live-updating data.