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

devtools.md

65 lines2.6 KB

1---
2id: devtools
3title: Devtools
4---
5​
6## Install and Import the Devtools
7​
8The devtools are a separate package that you need to install:
9​
10```bash
11$ npm i @tanstack/angular-query-devtools-experimental
12# or
13$ pnpm add @tanstack/angular-query-devtools-experimental
14# or
15$ yarn add @tanstack/angular-query-devtools-experimental
16# or
17$ bun add @tanstack/angular-query-devtools-experimental
18```
19​
20You can import the devtools like this:
21​
22```ts
23import { AngularQueryDevtools } from '@tanstack/angular-query-devtools-experimental'
24```
25​
26## Floating Mode
27​
28Floating Mode will mount the devtools as a fixed, floating element in your app and provide a toggle in the corner of the screen to show and hide the devtools. This toggle state will be stored and remembered in localStorage across reloads.
29​
30Place the following code as high in your Angular app as you can. The closer it is to the root of the page, the better it will work!
31​
32```angular-ts
33import { AngularQueryDevtools } from '@tanstack/angular-query-devtools-experimental'
34import { Component } from '@angular/core';
35​
36@Component({
37 selector: 'app-root',
38 standalone: true,
39 imports: [AngularQueryDevtools],
40 template: `
41 <angular-query-devtools initialIsOpen />
42 `,
43})
44```
45​
46### Options
47​
48- `initialIsOpen: Boolean`
49 - Set this `true` if you want the dev tools to default to being open
50- `buttonPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right" | "relative"`
51 - Defaults to `bottom-right`
52 - The position of the TanStack logo to open and close the devtools panel
53 - If `relative`, the button is placed in the location that you render the devtools.
54- `position?: "top" | "bottom" | "left" | "right"`
55 - Defaults to `bottom`
56 - The position of the Angular Query devtools panel
57- `client?: QueryClient`,
58 - Use this to use a custom QueryClient. Otherwise, the QueryClient provided through provideAngularQuery() will be injected.
59- `errorTypes?: { name: string; initializer: (query: Query) => TError}`
60 - Use this to predefine some errors that can be triggered on your queries. Initializer will be called (with the specific query) when that error is toggled on from the UI. It must return an Error.
61- `styleNonce?: string`
62 - Use this to pass a nonce to the style tag that is added to the document head. This is useful if you are using a Content Security Policy (CSP) nonce to allow inline styles.
63- `shadowDOMTarget?: ShadowRoot`
64 - Default behavior will apply the devtool's styles to the head tag within the DOM.
65 - Use this to pass a shadow DOM target to the devtools so that the styles will be applied within the shadow DOM instad of within the head tag in the light DOM.