Open History to see the last commit
1---
2id: devtools
3title: Devtools
4---
5β
6Wave your hands in the air and shout hooray because Vue Query comes with dedicated devtools! π₯³
7β
8When you begin your Vue Query journey, you'll want these devtools by your side. They help visualize all of the inner workings of Vue Query and will likely save you hours of debugging if you find yourself in a pinch!
9β
10## Component based Devtools (Vue 3)
11β
12You can directly integrate the devtools component into your page using a dedicated package.
13Component-based devtools use a framework-agnostic implementation and are always up-to-date.
14β
15The devtools component is a separate package that you need to install:
16β
17```bash
18npm i @tanstack/vue-query-devtools
19```
20β
21or
22β
23```bash
24pnpm add @tanstack/vue-query-devtools
25```
26β
27or
28β
29```bash
30yarn add @tanstack/vue-query-devtools
31```
32β
33or
34β
35```bash
36bun add @tanstack/vue-query-devtools
37```
38β
39By default, Vue Query Devtools are only included in bundles when `process.env.NODE_ENV === 'development'`, so you don't need to worry about excluding them during a production build.
40β
41Devtools will be mounted 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.
42β
43Place the following code as high in your Vue app as you can. The closer it is to the root of the page, the better it will work!
44β
45```vue
46<script setup>
47import { VueQueryDevtools } from '@tanstack/vue-query-devtools'
48</script>
49β
50<template>
51 <h1>The app!</h1>
52 <VueQueryDevtools />
53</template>
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"`
61 - Defaults to `bottom-right`.
62 - The position of the React Query logo to open and close the devtools panel.
63- `position?: "top" | "bottom" | "left" | "right"`
64 - Defaults to `bottom`.
65 - The position of the React Query devtools panel.
66- `client?: QueryClient`
67 - Use this to use a custom QueryClient. Otherwise, the one from the nearest context will be used.
68- `errorTypes?: { name: string; initializer: (query: Query) => TError}`
69 - Use this to predefine some errors that can be triggered on your queries. The initializer will be called (with the specific query) when that error is toggled on from the UI. It must return an Error.
70- `styleNonce?: string`
71 - 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.
72- `shadowDOMTarget?: ShadowRoot`
73 - Default behavior will apply the devtool's styles to the head tag within the DOM.
74 - 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.
75β
76## Traditional Devtools
77β
78Vue Query will seamlessly integrate with the [Official Vue devtools](https://github.com/vuejs/devtools-next), adding custom inspector and timeline events.
79Devtool code will be treeshaken from production bundles by default.
80β
81To make it work, you only need to enable it in the plugin options:
82β
83```ts
84app.use(VueQueryPlugin, {
85 enableDevtoolsV6Plugin: true,
86})
87```
88β
89Both v6 and v7 versions of devtools are supported.