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