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

devtools.md

77 lines2.9 KB

1---
2id: devtools
3title: Devtools
4---
5​
6> For Google Chrome users: A third-party Chrome extension is available for debugging TanStack Query directly in Chrome DevTools. This provides the same functionality as the framework-specific devtools packages. Check it out here: [TanStack Query DevTools](https://chromewebstore.google.com/detail/tanstack-query-devtools/annajfchloimdhceglpgglpeepfghfai)
7​
8## Install and Import the Devtools
9​
10The devtools are a separate package that you need to install:
11​
12```bash
13npm i @tanstack/svelte-query-devtools
14```
15​
16or
17​
18```bash
19pnpm add @tanstack/svelte-query-devtools
20```
21​
22or
23​
24```bash
25yarn add @tanstack/svelte-query-devtools
26```
27​
28or
29​
30```bash
31bun add @tanstack/svelte-query-devtools
32```
33​
34You can import the devtools like this:
35​
36```ts
37import { SvelteQueryDevtools } from '@tanstack/svelte-query-devtools'
38```
39​
40## Floating Mode
41​
42Floating 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.
43​
44Place the following code as high in your Svelte app as you can. The closer it is to the root of the page, the better it will work!
45​
46```ts
47<script>
48 import { QueryClientProvider } from '@tanstack/svelte-query'
49 import { SvelteQueryDevtools } from '@tanstack/svelte-query-devtools'
50</script>
51​
52<QueryClientProvider client={queryClient}>
53 {/* The rest of your application */}
54 <SvelteQueryDevtools />
55</QueryClientProvider>
56```
57​
58### Options
59​
60- `initialIsOpen: Boolean`
61 - Set this `true` if you want the dev tools to default to being open
62- `buttonPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right" | "relative"`
63 - Defaults to `bottom-right`
64 - The position of the TanStack logo to open and close the devtools panel
65 - If `relative`, the button is placed in the location that you render the devtools.
66- `position?: "top" | "bottom" | "left" | "right"`
67 - Defaults to `bottom`
68 - The position of the Svelte Query devtools panel
69- `client?: QueryClient`,
70 - Use this to use a custom QueryClient. Otherwise, the one from the nearest context will be used.
71- `errorTypes?: { name: string; initializer: (query: Query) => TError}`
72 - 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.
73- `styleNonce?: string`
74 - 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.
75- `shadowDOMTarget?: ShadowRoot`
76 - Default behavior will apply the devtool's styles to the head tag within the DOM.
77 - Use this to pass a shadow DOM target to the devtools so that the styles will be applied within the shadow DOM instead of within the head tag in the light DOM.