Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

useQueryClient.md

36 lines875 Bytes

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:21](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryClientProvider.tsx#L21)
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.