Open History to see the last commit
1---
2id: provideQueryClient
3title: provideQueryClient
4---
5β
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7β
8```ts
9function provideQueryClient(queryClient:
10 | QueryClient
11 | InjectionToken<QueryClient>): Provider;
12```
13β
14Defined in: [packages/angular-query-experimental/src/providers.ts:21](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L21)
15β
16Usually [provideTanStackQuery](provideTanStackQuery.md) is used once to set up TanStack Query and the
17[`QueryClient`](https://tanstack.com/query/latest/docs/reference/QueryClient) for the entire application β
18it calls `provideQueryClient` internally. Use `provideQueryClient` directly to provide a different
19`QueryClient` instance for part of the application, or for unit testing.
20β
21## Parameters
22β
23### queryClient
24β
25 \| [`QueryClient`](../classes/QueryClient.md)
26 \| `InjectionToken`\<[`QueryClient`](../classes/QueryClient.md)\>
27β
28A `QueryClient` instance, or an `InjectionToken` which provides a `QueryClient`.
29β
30## Returns
31β
32`Provider`
33β
34A provider object that can be used to provide the `QueryClient` instance.
35β
36## Example
37β
38Providing a test-only `QueryClient` in a component test, without wiring up `provideTanStackQuery`'s other
39defaults:
40```ts
41TestBed.configureTestingModule({
42 providers: [provideQueryClient(new QueryClient())],
43})
44```