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

devtools.md

81 lines3.0 KB

1---
2id: devtools
3title: Devtools
4---
5​
6Wave your hands in the air and shout hooray because Solid Query comes with dedicated devtools! πŸ₯³
7​
8When you begin your Solid Query journey, you'll want these devtools by your side. They help visualize all of the inner workings of Solid Query and will likely save you hours of debugging if you find yourself in a pinch!
9​
10## Install and Import the Devtools
11​
12The devtools are a separate package that you need to install:
13​
14```bash
15npm i @tanstack/solid-query-devtools
16```
17​
18or
19​
20```bash
21pnpm add @tanstack/solid-query-devtools
22```
23​
24or
25​
26```bash
27yarn add @tanstack/solid-query-devtools
28```
29​
30or
31​
32```bash
33bun add @tanstack/solid-query-devtools
34```
35​
36You can import the devtools like this:
37​
38```tsx
39import { SolidQueryDevtools } from '@tanstack/solid-query-devtools'
40```
41​
42By default, Solid Query Devtools are only included in bundles when `isServer === true` ([`isServer`](https://github.com/solidjs/solid/blob/a72d393a07b22f9b7496e5eb93712188ccce0d28/packages/solid/web/src/index.ts#L37) comes from the `solid-js/web` package), so you don't need to worry about excluding them during a production build.
43​
44## Floating Mode
45​
46Floating 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.
47​
48Place the following code as high in your Solid app as you can. The closer it is to the root of the page, the better it will work!
49​
50```tsx
51import { SolidQueryDevtools } from '@tanstack/solid-query-devtools'
52​
53function App() {
54 return (
55 <QueryClientProvider client={queryClient}>
56 {/* The rest of your application */}
57 <SolidQueryDevtools initialIsOpen={false} />
58 </QueryClientProvider>
59 )
61```
62​
63### Options
64​
65- `initialIsOpen: Boolean`
66 - Set this `true` if you want the dev tools to default to being open
67- `buttonPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right"`
68 - Defaults to `bottom-right`
69 - The position of the Solid Query logo to open and close the devtools panel
70- `position?: "top" | "bottom" | "left" | "right"`
71 - Defaults to `bottom`
72 - The position of the Solid Query devtools panel
73- `client?: QueryClient`,
74 - Use this to use a custom QueryClient. Otherwise, the one from the nearest context will be used.
75- `errorTypes?: { name: string; initializer: (query: Query) => TError}`
76 - 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.
77- `styleNonce?: string`
78 - 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.
79- `shadowDOMTarget?: ShadowRoot`
80 - Default behavior will apply the devtool's styles to the head tag within the DOM.
81 - 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.