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

devtools.md

83 lines3.4 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> 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)
11​
12## Install and Import the Devtools
13​
14The devtools are a separate package that you need to install:
15​
16```bash
17npm i @tanstack/solid-query-devtools
18```
19​
20or
21​
22```bash
23pnpm add @tanstack/solid-query-devtools
24```
25​
26or
27​
28```bash
29yarn add @tanstack/solid-query-devtools
30```
31​
32or
33​
34```bash
35bun add @tanstack/solid-query-devtools
36```
37​
38You can import the devtools like this:
39​
40```tsx
41import { SolidQueryDevtools } from '@tanstack/solid-query-devtools'
42```
43​
44By 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.
45​
46## Floating Mode
47​
48Floating 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.
49​
50Place 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!
51​
52```tsx
53import { SolidQueryDevtools } from '@tanstack/solid-query-devtools'
54​
55function App() {
56 return (
57 <QueryClientProvider client={queryClient}>
58 {/* The rest of your application */}
59 <SolidQueryDevtools initialIsOpen={false} />
60 </QueryClientProvider>
61 )
63```
64​
65### Options
66​
67- `initialIsOpen: Boolean`
68 - Set this `true` if you want the dev tools to default to being open
69- `buttonPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right"`
70 - Defaults to `bottom-right`
71 - The position of the Solid Query logo to open and close the devtools panel
72- `position?: "top" | "bottom" | "left" | "right"`
73 - Defaults to `bottom`
74 - The position of the Solid Query devtools panel
75- `client?: QueryClient`,
76 - Use this to use a custom QueryClient. Otherwise, the one from the nearest context will be used.
77- `errorTypes?: { name: string; initializer: (query: Query) => TError}`
78 - 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.
79- `styleNonce?: string`
80 - 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.
81- `shadowDOMTarget?: ShadowRoot`
82 - Default behavior will apply the devtool's styles to the head tag within the DOM.
83 - 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.