--- id: provideTanStackQuery title: provideTanStackQuery --- ```ts function provideTanStackQuery(queryClientFactory: () => QueryClient, ...features: readonly QueryFeature[]): EnvironmentProviders; ``` Defined in: [packages/angular-query/src/providers.ts:126](https://github.com/TanStack/query/blob/main/packages/angular-query/src/providers.ts#L126) Sets up providers necessary to enable TanStack Query functionality for Angular applications. Provides a `QueryClient` and optional TanStack Query features. The factory runs once per injector in Angular's injection context, so it can call `inject()` and each SSR request can receive an independent cache. ## Parameters ### queryClientFactory () => [`QueryClient`](../classes/QueryClient.md) Creates or resolves a `QueryClient` in the injection context. ### features ...readonly [`QueryFeature`](../interfaces/QueryFeature.md)[] Optional features to configure additional Query functionality. ## Returns `EnvironmentProviders` A single EnvironmentProviders value (do not spread into `providers`). ## See - https://tanstack.com/query/v5/docs/framework/angular/quick-start - https://tanstack.com/query/v5/docs/framework/angular/devtools - https://tanstack.com/query/latest/docs/framework/angular/guides/ssr ## Examples ```ts import { provideTanStackQuery, QueryClient, } from '@tanstack/angular-query' bootstrapApplication(AppComponent, { providers: [provideTanStackQuery(() => new QueryClient())], }) ``` The same, in an `NgModule`-based application: ```ts import { provideTanStackQuery, QueryClient } from '@tanstack/angular-query' @NgModule({ declarations: [AppComponent], imports: [BrowserModule], providers: [provideTanStackQuery(() => new QueryClient())], bootstrap: [AppComponent], }) export class AppModule {} ``` Enabling optional developer tools by adding `withDevtools` — by default, the tools are then loaded when your app is in development mode: ```ts import { provideTanStackQuery, QueryClient } from '@tanstack/angular-query' import { withDevtools } from '@tanstack/angular-query-devtools' bootstrapApplication(AppComponent, { providers: [ provideTanStackQuery(() => new QueryClient(), withDevtools()), ], }) ``` Resolving the `QueryClient` from an `InjectionToken` — an advanced optimization that lets TanStack Query be absent from the main application bundle, useful for including it on lazy-loaded routes only while still sharing a `QueryClient`. This is a small optimization; for most applications it's preferable to provide the `QueryClient` in the main application config, as in the examples above: ```ts export const MY_QUERY_CLIENT = new InjectionToken('', { factory: () => new QueryClient(), }) // In a lazy loaded route's providers array: providers: [provideTanStackQuery(() => inject(MY_QUERY_CLIENT))] ```