Skip to content

Commit c82362e

Browse files
docs(svelte-query): add the devtools page to the svelte-query docs (#8149)
* docs(svelte-query): add the devtools page to the svelte-query docs * docs(svelte-query): remove the angular stuff, what is skipped --------- Co-authored-by: Lachlan Collins <[email protected]>
1 parent 30d18ee commit c82362e

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

docs/config.json

+4
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@
120120
"label": "Installation",
121121
"to": "framework/svelte/installation"
122122
},
123+
{
124+
"label": "Devtools",
125+
"to": "framework/svelte/devtools"
126+
},
123127
{
124128
"label": "SSR & SvelteKit",
125129
"to": "framework/svelte/ssr"

docs/framework/svelte/devtools.md

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
id: devtools
3+
title: Devtools
4+
---
5+
6+
## Install and Import the Devtools
7+
8+
The devtools are a separate package that you need to install:
9+
10+
```bash
11+
npm i @tanstack/svelte-query-devtools
12+
```
13+
14+
or
15+
16+
```bash
17+
pnpm add @tanstack/svelte-query-devtools
18+
```
19+
20+
or
21+
22+
```bash
23+
yarn add @tanstack/svelte-query-devtools
24+
```
25+
26+
or
27+
28+
```bash
29+
bun add @tanstack/svelte-query-devtools
30+
```
31+
32+
You can import the devtools like this:
33+
34+
```ts
35+
import { SvelteQueryDevtools } from '@tanstack/svelte-query-devtools'
36+
```
37+
38+
## Floating Mode
39+
40+
Floating 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.
41+
42+
Place 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!
43+
44+
```ts
45+
<script>
46+
import { QueryClientProvider } from '@tanstack/svelte-query'
47+
import { SvelteQueryDevtools } from '@tanstack/svelte-query-devtools'
48+
</script>
49+
50+
<QueryClientProvider client={queryClient}>
51+
{/* The rest of your application */}
52+
<SvelteQueryDevtools />
53+
</QueryClientProvider>
54+
```
55+
56+
### Options
57+
58+
- `initialIsOpen: Boolean`
59+
- Set this `true` if you want the dev tools to default to being open
60+
- `buttonPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right" | "relative"`
61+
- Defaults to `bottom-right`
62+
- The position of the TanStack logo to open and close the devtools panel
63+
- If `relative`, the button is placed in the location that you render the devtools.
64+
- `position?: "top" | "bottom" | "left" | "right"`
65+
- Defaults to `bottom`
66+
- The position of the Svelte Query devtools panel
67+
- `client?: QueryClient`,
68+
- Use this to use a custom QueryClient. Otherwise, the one from the nearest context will be used.
69+
- `errorTypes?: { name: string; initializer: (query: Query) => TError}`
70+
- 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.
71+
- `styleNonce?: string`
72+
- 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.
73+
- `shadowDOMTarget?: ShadowRoot`
74+
- Default behavior will apply the devtool's styles to the head tag within the DOM.
75+
- 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.

0 commit comments

Comments
 (0)