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