| id | provideTanStackQuery |
|---|---|
| title | provideTanStackQuery |
function provideTanStackQuery(queryClient, ...features): EnvironmentProviders;Defined in: providers.ts:124
Sets up providers necessary to enable TanStack Query functionality for Angular applications.
Allows to configure a QueryClient and optional features such as developer tools. SSR dehydration and client hydration are built in (see the SSR guide); you do not need a separate hydration feature.
Environment injector only: use this with bootstrapApplication, ApplicationConfig, NgModule.providers, mergeApplicationConfig, or route-level providers. Do not use it in @Component({ providers }).
Example - standalone
import {
provideTanStackQuery,
QueryClient,
} from '@tanstack/angular-query-experimental'
bootstrapApplication(AppComponent, {
providers: [provideTanStackQuery(new QueryClient())],
})Example - NgModule-based
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 from @tanstack/angular-query-devtools (see the Angular Devtools guide).
import { provideTanStackQuery, QueryClient } from '@tanstack/angular-query-experimental'
import { withDevtools } from '@tanstack/angular-query-devtools'
bootstrapApplication(AppComponent, {
providers: [provideTanStackQuery(new QueryClient(), withDevtools())],
})Example: using an InjectionToken
export const MY_QUERY_CLIENT = new InjectionToken('', {
factory: () => new QueryClient(),
})
providers: [provideTanStackQuery(MY_QUERY_CLIENT)]A QueryClient instance, or an InjectionToken which provides a QueryClient.
QueryClient | InjectionToken<QueryClient>
...QueryFeatures[]
Optional features to configure additional Query functionality.
EnvironmentProviders
A single value to place in environment providers (do not spread).