Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

provideTanStackQuery.md

69 lines1.8 KB

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

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()),
  ],
})