vitejs / vitejs/devtools

Feature: Set UI panel defaults from the Plugin

Open
#532 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
1.2k
Forks
89
Avg merge
18h 46m
Merged PRs (30d)
24

Description

Clear and concise description of the problem

Not being able to define the UI defaults for the devtools panel in such a way that can live in your codebase- means that every fresh instance needs a developer to go into the panel and setup those desired codebase defaults, before any actual dev-server usage can properly happen.

This stemmed from me wanting to disable the default Cmd + K global keyboard trigger and figuring out that such a thing had to be manually done by every dev on the team in across their browsers. This becomes worse if you are using worktrees and launching the dev server and passing in the --port flag since you'd need to go through all this again.

Also, as someone who needs to regularly clear their web storage, for clean runs - its becoming annoying that this needs to keep being done.

Suggested solution

I think having an object in the vite plugin for setting the default UI options would make sense.

Something like:

// vite.config.ts
import { DevTools } from '@vitejs/devtools'
import Inspect from 'vite-plugin-inspect'
import { defineConfig } from 'vitest/config'

export default defineConfig(() => {
  return {
    plugins: [
      DevTools({
        // like this
        uiOptions: {
          shortcuts: {
            open:  "Cmd+K"
          }
        }
      }),
      Inspect(),
    ],
  }
})
Alternative

I think TanStack Devtools gets around this by having the devtools be a component that's mounted into the framework's tree, so that means the defaults are set on the component itself - <Devtools config={{ openHotkey: [] }} />. This wouldn't make sense here since the devtools are injected in by vite and not by the UI-framework.

You could try and hack something in by having a dev-only script be fired to check for window.__VITE_DEVTOOLS_CLIENT_CONTEXT__ and if so try and work with that - but this definitely feels like a hack/work-around.

Additional context

No response

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the DevTools({ ... }) entry point shown in vite.config.ts, then trace how UI options, shortcuts, and the window.VITE_DEVTOOLS_CLIENT_CONTEXT context reach the panel. Determine the supported default-options boundary and how fresh or cleared-storage instances apply it; done means plugin-provided UI defaults work without manual panel setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vite
Domain
devtools, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.