Skip to main content
1

Install

Add the adapter and its peer dependencies to your project.
2

Create ConvexQueryClient

Initialize the Convex client, the ConvexQueryClient adapter, and the TanStack QueryClient together. Do this once at the module level, outside any component.
The queryKeyHashFn must be set globally — it cannot be set per-query, so the client can correctly identify and update Convex query cache entries.
3

Wrap your app

Place ConvexProvider and QueryClientProvider around your application. Both providers are required: ConvexProvider enables Convex hooks like useConvexMutation, while QueryClientProvider makes the TanStack cache available to useQuery.
4

Make your first reactive query

Use convexQuery() as the options argument to useQuery. Pass your generated api object and any query arguments.
The query subscribes via WebSocket and updates automatically whenever the server data changes. No polling needed.

Next steps

Reactive queries

Learn how to use convexQuery with conditional queries, useSuspenseQuery, and custom options like placeholderData.

Mutations & actions

Use useConvexMutation and useConvexAction with TanStack Query’s useMutation hook.

Authentication

Integrate Convex Auth, Clerk, or another auth provider with the query adapter.

API reference

Full reference for ConvexQueryClient, convexQuery, convexAction, and all re-exported hooks.