Open History to see the last commit
function provideTanStackQuery(queryClientFactory: () => QueryClient, ...features: readonly QueryFeature[]): EnvironmentProviders;
Defined in: packages/angular-query/src/providers.ts:101
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
Creates or resolves a QueryClient in the injection context.
features#
...readonly QueryFeature[]
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
Example#
import {
provideTanStackQuery,
QueryClient,
} from '@tanstack/angular-query'
bootstrapApplication(AppComponent, {
providers: [provideTanStackQuery(() => new QueryClient())],
})
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.
import { provideTanStackQuery, QueryClient } from '@tanstack/angular-query'
import { withDevtools } from '@tanstack/angular-query-devtools'
bootstrapApplication(AppComponent, {
providers: [
provideTanStackQuery(() => new QueryClient(), withDevtools()),
],
})