Install
Install the plugin and Vite DevTools.
npm install -D @sveltejs/vite-devtools-svelte @vitejs/devtoolsConfigure Vite
Turn on Vite DevTools with Vite's devtools option and add the plugin to your vite.config.ts. apply: 'serve' keeps Vite DevTools out of vite build. svelteDevtools() must come before sveltekit() so its transforms run before the Svelte compiler.
import { svelteDevtools } from '@sveltejs/vite-devtools-svelte'
import { sveltekit } from '@sveltejs/kit/vite'
import { defineConfig } from 'vite'
export default defineConfig({
devtools: { apply: 'serve' },
plugins: [svelteDevtools(), sveltekit()],
})Open the dock
npm run devOpen your app, click the floating Vite DevTools handle and open the Svelte tools group. It has Overview, Problems, Inspect, Profile and
Project, the Svelte Inspector (Pick element and Inspector settings), and Add, which
installs sv add-ons.
Vite DevTools signs in the browser once for the whole dock (to skip it on a single-user
machine, see below). The Svelte Inspector loads after that: hold alt-x in your app and click an element to open its source in your editor.
If you use vite-plugin-svelte's own inspector (vitePlugin.inspector), turn it
off: the dev server does not start with both.
Without Vite DevTools
Without @vitejs/devtools, install only the plugin and leave out the devtools option. The panels then open on their own page at /.svelte-devtools/, and the dev server prints its URL. The Svelte Inspector
and the Add panel need the dock.
npm install -D @sveltejs/vite-devtools-svelteThe first time, the page asks for a one-time code: the dev server prints a 6-digit code and a link in the terminal. Type the code, or open the link. That browser is then trusted, also after reloads and dev-server restarts.
On a single-user machine where the dev server only listens on localhost, you
can skip the code with svelteDevtools({ clientAuth: false }), or devtools: { apply: 'serve', clientAuth: false } for the dock. Without
it, any page or device that can reach the dev server can read your project files through the
DevTools, so keep it on if you are unsure.
Options
svelteDevtools({
// Track component instances and their state (default: true)
componentTracking: true,
// Ask for the one-time code on /.svelte-devtools/ (default: true)
clientAuth: true,
// Svelte Inspector options (dock only)
inspector: { toggleKeyCombo: 'alt-x', holdMode: true },
})inspector also takes navKeys, openKey, openMenuKey, escapeKeys and customStyles.