For Chrome, Firefox, and Edge users: Third-party browser extensions are available for debugging TanStack Query directly in browser DevTools. These provide the same functionality as the framework-specific devtools packages:
Add the devtools package (in addition to @tanstack/angular-query):
npm install @tanstack/angular-query-devtoolsThe devtools help you debug and inspect your queries and mutations. You can enable the devtools by adding withDevtools to provideTanStackQuery.
By default, Angular Query Devtools only load in development.
import { QueryClient, provideTanStackQuery } from '@tanstack/angular-query'
import { withDevtools } from '@tanstack/angular-query-devtools'
export const appConfig: ApplicationConfig = {
providers: [provideTanStackQuery(() => new QueryClient(), withDevtools())],
}If you need the real implementation in production, import from the production entrypoint.
import { withDevtools } from '@tanstack/angular-query-devtools/production'To control when devtools are rendered, use the loadDevtools option.
When omitted or set to 'auto', devtools are only rendered in development mode.
import { withDevtools } from '@tanstack/angular-query-devtools'
providers: [provideTanStackQuery(() => new QueryClient(), withDevtools())]
// which is equivalent to
providers: [
provideTanStackQuery(
() => new QueryClient(),
withDevtools(() => ({ loadDevtools: 'auto' })),
),
]When setting the option to true, the devtools will be rendered in both development and production mode.
This is useful if you want to load devtools based on Angular environment configurations. E.g. you could set this to true when the application is running on your production build staging environment.
// Make sure to use the production sub-path to load devtools in production builds
import { withDevtools } from '@tanstack/angular-query-devtools/production'
import { environment } from './environments/environment'
providers: [
provideTanStackQuery(
() => new QueryClient(),
withDevtools(() => ({ loadDevtools: environment.loadDevtools })),
),
]When setting the option to false, the devtools will not be rendered.
providers: [
provideTanStackQuery(
() => new QueryClient(),
withDevtools(() => ({ loadDevtools: false })),
),
]Some webpack-based Angular builders do not apply package export conditions when they bundle application code. Use the explicit production and stub entrypoints with Angular CLI file replacements to keep the devtools dependency out of production bundles.
Create an application-level import that can be replaced:
// src/app/query-devtools.ts
export { withDevtools } from '@tanstack/angular-query-devtools/production'// src/app/query-devtools.stub.ts
export { withDevtools } from '@tanstack/angular-query-devtools/stub'Import the application-level module from your config:
import { withDevtools } from './query-devtools'Then configure the production build:
{
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/app/query-devtools.ts",
"with": "src/app/query-devtools.stub.ts"
}
]
}
}
}The same pattern is available for the embedded panel: @tanstack/angular-query-devtools/devtools-panel/production and @tanstack/angular-query-devtools/devtools-panel/stub.
Mutable options can be Angular signals. For example, a signal derived from a keyboard shortcut can show devtools on demand:
import { Injectable, isDevMode } from '@angular/core'
import { toSignal } from '@angular/core/rxjs-interop'
import { fromEvent, map, scan } from 'rxjs'
@Injectable({ providedIn: 'root' })
export class DevtoolsOptionsManager {
loadDevtools = toSignal(
fromEvent<KeyboardEvent>(document, 'keydown').pipe(
map(
(event): boolean =>
event.metaKey && event.ctrlKey && event.shiftKey && event.key === 'D',
),
scan((acc, curr) => acc || curr, isDevMode()),
),
{
initialValue: isDevMode(),
},
)
}The callback runs once in an Angular injection context, so it can call inject(). Return signals as option values to update them reactively:
// ...
// 👇 Import from the production sub-path to make devtools available in production builds
import { inject } from '@angular/core'
import { withDevtools } from '@tanstack/angular-query-devtools/production'
export const appConfig: ApplicationConfig = {
providers: [
provideHttpClient(),
provideTanStackQuery(
() => new QueryClient(),
withDevtools(() => ({
loadDevtools: inject(DevtoolsOptionsManager).loadDevtools,
})),
),
],
}loadDevtools, client, position, errorTypes, buttonPosition, initialIsOpen, and theme accept either their documented static value or a signal containing that value.
styleNonce, shadowDOMTarget, and hideDisabledQueries are construction-time options and do not accept signals.
Embedded mode will show the development tools as a fixed element in your application, so you can use our panel in your own development tools.
Use injectDevtoolsPanel to render the devtools panel inside an element of your component. Like withDevtools, it is only included in development mode bundles. To use it in production builds, import it from @tanstack/angular-query-devtools/devtools-panel/production.
import { Component, signal, viewChild } from '@angular/core'
import { injectDevtoolsPanel } from '@tanstack/angular-query-devtools/devtools-panel'
import type { ElementRef } from '@angular/core'
@Component({
selector: 'app-root',
template: `
<button type="button" (click)="isOpen.set(!isOpen())">
{{ isOpen() ? 'Close' : 'Open' }} the devtools panel
</button>
@if (isOpen()) {
<div #div style="height: 500px"></div>
}
`,
})
export class AppComponent {
readonly isOpen = signal(false)
readonly divEl = viewChild<ElementRef>('div')
readonly devtools = injectDevtoolsPanel(() => ({
hostElement: this.divEl(),
onClose: () => this.isOpen.set(false),
}))
}injectDevtoolsPanel must be called in an injection context. To create the panel later, for example after lazy loading the entry point, wrap the call in runInInjectionContext. It returns a DevtoolsPanelRef; call its destroy() to remove the panel before the injector that created it is destroyed.
See the devtools panel example for both variants.
The callback is reactive: hostElement, client, errorTypes, onClose, and theme are applied whenever a signal read in the callback changes.
styleNonce, shadowDOMTarget, and hideDisabledQueries are construction-time options, read when the panel is created.
The Filter input above the query and mutation lists uses the Key scope by default. Select the scope button inside the input to switch between Key, Data, and All:
The selected scope is remembered across reloads, like the other filter settings.
Select a query or mutation and use Search data in its Data Explorer to search nested property names and primitive values. Search uses case-insensitive text matching and treats special characters as plain text.
Matching text is highlighted. Matching editable values have a highlighted input. The explorer opens matching branches and the first matching page in each paginated collection. Other pages with matches are highlighted so you can open them. You can still inspect other rows and edit query data.
The Data Explorer highlights up to 1,000 matches at a time.
Select Clear or press Escape in the search field to restore your manual expansion. Selecting another query or mutation clears the search, unless the filter scope is Data or All: then the search starts with the filter text. For a mutation, it starts only in the variables or data that match the filter.