Open History to see the last commit
1---
2id: provideTanStackQuery
3title: provideTanStackQuery
4---
5β
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7β
8```ts
9function provideTanStackQuery(queryClientFactory: () => QueryClient, ...features: readonly QueryFeature[]): EnvironmentProviders;
10```
11β
12Defined in: [packages/angular-query/src/providers.ts:101](https://github.com/TanStack/query/blob/main/packages/angular-query/src/providers.ts#L101)
13β
14Provides a `QueryClient` and optional TanStack Query features.
15The factory runs once per injector in Angular's injection context, so it can
16call `inject()` and each SSR request can receive an independent cache.
17β
18## Parameters
19β
20### queryClientFactory
21β
22() => [`QueryClient`](../classes/QueryClient.md)
23β
24Creates or resolves a `QueryClient` in the injection context.
25β
26### features
27β
28...readonly [`QueryFeature`](../interfaces/QueryFeature.md)[]
29β
30Optional features to configure additional Query functionality.
31β
32## Returns
33β
34`EnvironmentProviders`
35β
36A single EnvironmentProviders value (do not spread into `providers`).
37β
38## See
39β
40 - https://tanstack.com/query/v5/docs/framework/angular/quick-start
41 - https://tanstack.com/query/v5/docs/framework/angular/devtools
42 - https://tanstack.com/query/latest/docs/framework/angular/guides/ssr
43β
44## Example
45β
46```ts
47import {
48 provideTanStackQuery,
49 QueryClient,
50} from '@tanstack/angular-query'
51β
52bootstrapApplication(AppComponent, {
53 providers: [provideTanStackQuery(() => new QueryClient())],
54})
55```
56β
57You can also enable optional developer tools by adding `withDevtools`. By
58default the tools will then be loaded when your app is in development mode.
59β
60```ts
61import { provideTanStackQuery, QueryClient } from '@tanstack/angular-query'
62import { withDevtools } from '@tanstack/angular-query-devtools'
63β
64bootstrapApplication(AppComponent, {
65 providers: [
66 provideTanStackQuery(() => new QueryClient(), withDevtools()),
67 ],
68})
69```