Open History to see the last commit
1---
2id: useQueryClient
3title: useQueryClient
4---
5β
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7β
8```ts
9function useQueryClient(queryClient?: QueryClient): QueryClient;
10```
11β
12Defined in: [packages/preact-query/src/QueryClientProvider.tsx:21](https://github.com/TanStack/query/blob/main/packages/preact-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.