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

useQueryClient.md

34 lines802 Bytes

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.