TanStack Query is unopinionated about authentication. With Convex, auth is an implicit argument to all query functions — you don’t need to add an auth token to the query key. Queries are automatically retried when authentication state changes.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/get-convex/convex-react-query/llms.txt
Use this file to discover all available pages before exploring further.
How Convex auth works with queries
Convex auth uses JWTs. Some query functions will return errors (or restricted results) if called beforeconvexReactClient.setAuth() is invoked with a function that supplies the current token.
Because auth is implicit in the Convex client, the query key does not include auth tokens. When the user signs in or out, Convex automatically re-runs all active subscriptions with the new auth context.
Clerk setup
Wrap your app inClerkProvider, then ConvexProviderWithClerk to wire Clerk’s auth into the Convex client. The QueryClientProvider goes inside.
Convex Auth (password) setup
If you’re using@convex-dev/auth for password-based authentication, replace ConvexProviderWithClerk with ConvexAuthProvider.
Conditional rendering based on auth state
Use theAuthenticated, Unauthenticated, and AuthLoading components from convex/react to render different UI based on auth state. These work regardless of which auth provider you use.
See the Convex Auth docs for full setup
instructions for Clerk, Auth0, and other providers.