Open History to see the last commit
1---
2id: useQueryClient
3title: useQueryClient
4redirect_from:
5 - framework/react/reference/useQueryClient
6---
7β
8```ts
9function useQueryClient(queryClient?: QueryClient): QueryClient;
10```
11β
12Defined in: [packages/react-query/src/QueryClientProvider.tsx:21](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryClientProvider.tsx#L21)
13β
14The `useQueryClient` hook returns the current `QueryClient` instance.
15β
16## Parameters
17β
18### queryClient?
19β
20[`QueryClient`](../classes/QueryClient.md)
21β
22Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
23be used.
24β
25## Returns
26β
27[`QueryClient`](../classes/QueryClient.md)
28β
29The current `QueryClient` instance.
30β
31## Throws
32β
33If no `queryClient` argument is passed and no `QueryClientProvider` is found in the
34component tree.