0
Fork 0
mirror of https://github.com/TanStack/query.git synced 2026-11-18 19:33:22 +00:00
query/docs/framework/angular/reference/functions/provideTanStackQuery.md
Wonsuk Choi 6e16d3946a
docs(query-core/utils): add missing JSDoc to utility functions (#11830)
* docs(query-core/utils): add missing JSDoc to utility functions

* docs(query-core/utils): clarify that 'addToEnd' and 'addToStart' drop at most one item

* docs(framework/*/reference): regenerate reference docs
2026-10-04 02:47:14 +09:00

2.6 KiB

id title
provideTanStackQuery provideTanStackQuery
function provideTanStackQuery(queryClient: 
  | QueryClient
  | InjectionToken<QueryClient>, ...features: QueryFeatures[]): Provider[];

Defined in: packages/angular-query-experimental/src/providers.ts:96

Sets up providers necessary to enable TanStack Query functionality for Angular applications. Allows configuring a QueryClient and optional features such as developer tools.

Parameters

queryClient

A QueryClient instance, or an InjectionToken which provides a QueryClient.

QueryClient | InjectionToken<QueryClient>

features

...QueryFeatures[]

Optional features to configure additional Query functionality.

Returns

Provider[]

A set of providers to set up TanStack Query.

See

Examples

import { provideTanStackQuery, QueryClient } from '@tanstack/angular-query-experimental'

bootstrapApplication(AppComponent, {
  providers: [provideTanStackQuery(new QueryClient())],
})

The same, in an NgModule-based application:

import { provideTanStackQuery, QueryClient } from '@tanstack/angular-query-experimental'

@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:

import {
  provideTanStackQuery,
  withDevtools,
  QueryClient,
} from '@tanstack/angular-query-experimental'

bootstrapApplication(AppComponent, {
  providers: [provideTanStackQuery(new QueryClient(), withDevtools())],
})

Using an InjectionToken for the QueryClient — 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:

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)]