Open History to see the last commit
1---
2id: provideTanStackQuery
3title: provideTanStackQuery
4---
5β
6# Function: provideTanStackQuery()
7β
8```ts
9function provideTanStackQuery(queryClient, ...features): Provider[]
10```
11β
12Sets up providers necessary to enable TanStack Query functionality for Angular applications.
13β
14Allows to configure a `QueryClient` and optional features such as developer tools.
15β
16**Example - standalone**
17β
18```ts
19import {
20 provideTanStackQuery,
21 QueryClient,
22} from '@tanstack/angular-query-experimental'
23β
24bootstrapApplication(AppComponent, {
25 providers: [provideTanStackQuery(new QueryClient())],
26})
27```
28β
29**Example - NgModule-based**
30β
31```ts
32import {
33 provideTanStackQuery,
34 QueryClient,
35} from '@tanstack/angular-query-experimental'
36β
37@NgModule({
38 declarations: [AppComponent],
39 imports: [BrowserModule],
40 providers: [provideTanStackQuery(new QueryClient())],
41 bootstrap: [AppComponent],
42})
43export class AppModule {}
44```
45β
46You can also enable optional developer tools by adding `withDevtools`. By
47default the tools will then be loaded when your app is in development mode.
48β
49```ts
50import {
51 provideTanStackQuery,
52 withDevtools
53 QueryClient,
54} from '@tanstack/angular-query-experimental'
55β
56bootstrapApplication(AppComponent,
57 {
58 providers: [
59 provideTanStackQuery(new QueryClient(), withDevtools())
60 ]
61 }
62)
63```
64β
65**Example: using an InjectionToken**
66β
67```ts
68export const MY_QUERY_CLIENT = new InjectionToken('', {
69 factory: () => new QueryClient(),
70})
71β
72// In a lazy loaded route or lazy loaded component's providers array:
73providers: [provideTanStackQuery(MY_QUERY_CLIENT)]
74```
75β
76## Parameters
77β
78### queryClient
79β
80A `QueryClient` instance, or an `InjectionToken` which provides a `QueryClient`.
81β
82`QueryClient` | `InjectionToken`\<`QueryClient`\>
83β
84### features
85β
86...[`QueryFeatures`](../../type-aliases/queryfeatures.md)[]
87β
88Optional features to configure additional Query functionality.
89β
90## Returns
91β
92`Provider`[]
93β
94A set of providers to set up TanStack Query.
95β
96## See
97β
98- https://tanstack.com/query/v5/docs/framework/angular/quick-start
99- withDevtools
100β
101## Defined in
102β
103[providers.ts:118](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L118)