Never Search For Svelte Components Again

Published Sep 9, 2022

Table of Contents

The Svelte Inspector

How many times have you bumbled around your editor looking for the component you want to change.

Wouldn’t it be great if you could inspect and open the component inside your editor from your site?

You can thanks to the experimental Svelte inspector option by enabling it inside your config!

Enable For Svelte

For regular Svelte projects using Vite you can enable it inside vite.config.js.

vite.config.js
export default defineConfig({
  plugins: [
    svelte({
      experimental: {
        inspector: true,
      }
    })
  ]
})

Enable For SvelteKit

If you’re using SvelteKit you can enable it inside svelte.config.js.

svelte.config.js
const config = {
  // ...
  vitePlugin: {
    experimental: {
      inspector: true,
    },
  },
}

Configuration

Using the default options the inspector becomes available using the Meta + Shift shortcut but you can change the options.

svelte.config.js
 const config = {
  // ...
  vitePlugin: {
    experimental: {
      inspector: {
        // change shortcut
        toggleKeyCombo: 'meta-shift',
        // hold and release key to toggle inspector mode
        holdMode: true,
        // show or hide the inspector option
        showToggleButton: 'always',
        // inspector position
        toggleButtonPos: 'top-right',
      },
    },
}

Unfortunately there’s no code completion for the options since it’s experimental, so you’re going to have to look at the available options in the documentation.

Thank you for reading! 🏄️

Support

If you want to support the content you're reading or watching on YouTube consider becoming a patreon starting low as 1$ per month.

Become a patreon
Subscribe For Updates
Found a mistake?

Every post is a Markdown file so contributing is simple as following the link below and pressing the pencil icon inside GitHub to edit it.

Edit on GitHub