Framework
Version
Menu
Getting Started
Guides & Concepts
API Reference
ESLint
Community Resources
Examples
Plugins

useQueryClient

The useQueryClient hook returns the current QueryClient instance.

tsx
tsx
import { useQueryClient } from '@tanstack/react-query'
const queryClient = useQueryClient(queryClient?: QueryClient)
tsx
tsx
import { useQueryClient } from '@tanstack/react-query'
const queryClient = useQueryClient(queryClient?: QueryClient)

Options

  • queryClient?: QueryClient,
    • Use this to use a custom QueryClient. Otherwise, the one from the nearest context will be used.
Want to Skip the Docs?
Query.gg - The Official React Query Course
“This course is the best way to learn how to use React Query in real-world applications.”—Tanner Linsley
Check it out