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.
convexQuery is a query options factory that wires TanStack Query’s useQuery to a Convex query function subscription. Results are pushed from the server whenever the underlying data changes — no polling, no staleTime expiry, no manual invalidation.
Basic usage
Pass a function reference from your generatedapi object and its arguments to convexQuery, then hand the result directly to useQuery.
staleTime is set to Infinity automatically because Convex pushes fresh results proactively — the data is never stale in the traditional polling sense.
Queries with arguments
Pass an arguments object as the second parameter. The function reference and the arguments together form the query key.Conditional / skippable queries
Pass the string"skip" in place of an arguments object to disable the query conditionally.
When
"skip" is passed, enabled: false is set automatically and the query
won’t run. No subscription is created and no request is made.Suspense support
convexQuery is compatible with useSuspenseQuery. Wrap the component in a <Suspense> boundary to handle the loading state declaratively.
Actions (
convexAction) cannot be used with useSuspenseQuery because they
are not reactive and do not push updates.Controlling subscription lifetime
The Convex WebSocket subscription stays active until TanStack Query’sgcTime elapses after all observers have unmounted. Tune gcTime to balance responsiveness against bandwidth usage.
The default
gcTime in TanStack Query is 5 minutes. For most apps a value of
a few seconds is a better tradeoff — it lets fast navigation reuse a cached
result without holding the subscription open indefinitely.Extra query options
SpreadconvexQuery into an options object to add initialData, placeholderData, or any other TanStack Query option.
Using convexQueryClient.queryOptions()
ConvexQueryClient exposes a queryOptions() method that works the same way as convexQuery but embeds its own queryFn directly, so you don’t need to configure a global default queryFn.
Unlike
convexQuery, convexQueryClient.queryOptions() does NOT require the
global queryFn to be set on the QueryClient. Use it when you prefer
explicit per-query configuration over a global default.