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

provideTanStackQuery.md

69 lines1.8 KB

1---
2id: provideTanStackQuery
3title: provideTanStackQuery
4---
5​
6```ts
7function provideTanStackQuery(queryClientFactory: () => QueryClient, ...features: readonly QueryFeature[]): EnvironmentProviders;
8```
9​
10Defined in: [packages/angular-query/src/providers.ts:102](https://github.com/TanStack/query/blob/main/packages/angular-query/src/providers.ts#L102)
11​
12Provides a `QueryClient` and optional TanStack Query features.
13The factory runs once per injector in Angular's injection context, so it can
14call `inject()` and each SSR request can receive an independent cache.
15​
16**Example - standalone**
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## Example
39​
40```ts
41import {
42 provideTanStackQuery,
43 QueryClient,
44} from '@tanstack/angular-query'
45​
46bootstrapApplication(AppComponent, {
47 providers: [provideTanStackQuery(() => new QueryClient())],
48})
49```
50​
51You can also enable optional developer tools by adding `withDevtools`. By
52default the tools will then be loaded when your app is in development mode.
53​
54```ts
55import { provideTanStackQuery, QueryClient } from '@tanstack/angular-query'
56import { withDevtools } from '@tanstack/angular-query-devtools'
57​
58bootstrapApplication(AppComponent, {
59 providers: [
60 provideTanStackQuery(() => new QueryClient(), withDevtools()),
61 ],
62})
63```
64​
65## See
66​
67 - https://tanstack.com/query/v5/docs/framework/angular/quick-start
68 - https://tanstack.com/query/v5/docs/framework/angular/devtools
69 - https://tanstack.com/query/latest/docs/framework/angular/guides/ssr