Skip to content

About

Vite devtools for locating rendered React and Vue elements in source code.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Inspect Devtools

中文文档

npm version license frameworks live demo

Try it in 10 seconds without installing anything: Live Interactive Sandbox (Vercel) · Mirror (Cloudflare Pages)

Stop describing UI bugs to AI. Click or marquee-select any element in your running app to highlight its component boundary, jump to the exact file, line, and column in your editor, or copy structured AI context (@file:line:col + component hierarchy + route) and background-aware component screenshots straight to Cursor, Claude Code, and GitHub Copilot.

Inspect Devtools workflow


⚡ Why Inspect Devtools?

Capability Inspect Devtools Single-framework tools (e.g. react-grab / click-to-component) Built-in Browser / IDE Inspectors
React, Vue 3, Svelte, Next.js, Nuxt 3 ✅ Unified ❌ React-only ⚠️ Partial / Varies
Vite, Webpack, Rspack, Rollup, Esbuild ✅ Via Unplugin ❌ Bundler-specific ⚠️ Limited
PS-style Marquee (Shift add / Alt subtract) ✅ Multi-select ❌ Single element ❌ Single element
Batch AI Context (@file:line:col + Hierarchy + Route) ✅ Single & Batch ⚠️ Basic path ❌ DOM / HTML only
Background-inherited Visual Crop PNG ✅ No dark-on-dark alpha ❌ Not included ⚠️ Raw screenshot
Monorepo Prefix (copyMentionPrefix) ✅ Built-in ❌ Manual edit ❌ N/A

✨ Features

  • 🚀 Full Major Framework Support: First-class integration for Next.js, Nuxt 3, React, Vue 3, and Svelte.
  • 📦 Universal Bundler Compatibility: Powered by Unplugin, supporting Vite, Webpack, Rollup, Esbuild, and Rspack.
  • 🤖 Rich AI Context Snapshot (Single & Batch): Press Cmd+Alt+C / Ctrl+Alt+C to copy @file:line:col, component hierarchy tree (Hierarchy: App > DashboardPage), and page route (Route: /dashboard) — works for both single clicks and multi-component marquee selections.
  • 📸 Smart Visual Crop: Capture component screenshots directly to your clipboard with automatic page background color inheritance, preventing dark-on-dark transparent image issues.
  • 🧭 Component Hierarchy Breadcrumbs: Interactive breadcrumb bar on the floating badge allows you to traverse and jump to parent components up the render tree.
  • 🎨 Photoshop-Style Marquee Selection: Multi-element marquee, Shift+click/drag to add, Alt+click/drag to subtract, and persistent selection states.
  • 💻 Smart Editor Launching: Automatically detects running instances of VS Code, Cursor, and WebStorm, or direct launching via URL Scheme protocols.

📦 Installation & Setup

Choose the package that fits your framework and bundler:

1. Next.js

Note: @inspect-devtools/next injects source metadata via a Webpack loader during development. If your Next.js dev script uses Turbopack, start dev mode with Webpack (e.g. next dev --webpack).

pnpm add -D @inspect-devtools/next

Wrap your configuration in next.config.mjs:

// next.config.mjs
import { withInspectDevtools } from '@inspect-devtools/next'

/** @type {import('next').NextConfig} */
const nextConfig = {}

export default withInspectDevtools(nextConfig)

Include the client component in your root layout (e.g. app/layout.tsx):

// app/layout.tsx
import { InspectDevtools } from '@inspect-devtools/next/component'

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en" suppressHydrationWarning>
      <body>
        <InspectDevtools />
        {children}
      </body>
    </html>
  )
}

2. Nuxt 3

pnpm add -D @inspect-devtools/nuxt

Register the module in nuxt.config.ts:

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@inspect-devtools/nuxt'],
  inspectDevtools: {
    openOnClick: true, // Optional: open in editor on single click
  },
})

3. Vite + React

pnpm add -D @inspect-devtools/vite-react

Configure in vite.config.ts:

// vite.config.ts
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import { inspectDevtoolsReact } from '@inspect-devtools/vite-react'

export default defineConfig({
  plugins: [react(), ...inspectDevtoolsReact()],
})

4. Vite + Vue 3

pnpm add -D @inspect-devtools/vite-vue

Configure in vite.config.ts:

// vite.config.ts
import vue from '@vitejs/plugin-vue'
import { defineConfig } from 'vite'
import { inspectDevtoolsVue } from '@inspect-devtools/vite-vue'

export default defineConfig({
  plugins: [vue(), ...inspectDevtoolsVue()],
})

5. Vite + Svelte (Svelte 4/5)

pnpm add -D @inspect-devtools/vite-svelte

Configure in vite.config.ts:

// vite.config.ts
import { svelte } from '@sveltejs/vite-plugin-svelte'
import { defineConfig } from 'vite'
import { inspectDevtoolsSvelte } from '@inspect-devtools/vite-svelte'

export default defineConfig({
  plugins: [svelte(), ...inspectDevtoolsSvelte()],
})

6. Universal Bundlers (Webpack / Rollup / Rspack / Esbuild)

pnpm add -D @inspect-devtools/unplugin

Example with Webpack:

// webpack.config.js
const inspectDevtools = require('@inspect-devtools/unplugin/webpack')

module.exports = {
  plugins: [
    inspectDevtools({ framework: 'react' }), // or 'vue' / 'svelte'
  ],
}

⚙️ Configuration Options

All packages share a consistent options interface:

Option Type Default Description
openOnClick boolean false / framework preset Whether clicking an element immediately opens your editor. If false, opens on double-click or badge click
openInEditor string Auto-detect Specific editor CLI command, e.g. 'code' (VS Code), 'cursor', 'webstorm'
editorProtocol 'auto' | 'vscode' | 'cursor' | 'webstorm' 'auto' Editor trigger mechanism. 'auto' uses the dev server RPC; specific values launch via OS URL Schemes
theme 'light' | 'dark' 'light' Default theme for bottom dock and overlay elements
copyRoute boolean false Whether to append the current URL route (e.g. Route: /dashboard) when copying references
copyLineColumn boolean | 'line' | 'column' false Whether to include line and column numbers in standard reference copies (e.g. @App.vue:15:3)
copyFormat 'mention' | 'link' 'mention' Source reference format: 'mention' for @path; 'link' for Markdown link [name](path)
copyMentionPrefix string '' Path prefix added to ordinary @ mentions, for a dev server started inside one folder of a multi-root workspace. copyMentionPrefix: 'web/' turns @src/App.vue into @web/src/App.vue. Markdown links are unchanged

⌨️ Keyboard Shortcuts

Shortcut Action Description
Alt+Shift+I Toggle Inspect Mode Globally toggle component inspection on and off
Cmd+Alt+C / Ctrl+Alt+C Copy AI Context Snapshot Copies @file:line:col + Hierarchy breadcrumbs + Page route
Cmd+Shift+C / Ctrl+Shift+C Copy Visual Component Screenshot Copies visual PNG crop to clipboard with inherited background color
Shift + click / drag Add to selection Add more components into the active selection
Alt + click / drag Subtract from selection Remove components from the active selection
Cmd/Ctrl + click Direct open inside selection While selection is active, modifier-click directly opens in editor
Escape Exit / Clear selection Exit inspect mode or clear existing selection frames

Note: Shortcuts are automatically ignored when focus is inside an input, textarea, or content-editable element.


🤖 AI Rich Context Snapshot

Press Cmd+Alt+C (or click the ✨ button on the floating badge) to copy structured component context:

@/Users/project/src/pages/HomePage.tsx:12:5
Hierarchy: `App` > `HomePage` > `MetricCard`
Route: /dashboard

When multiple components are selected via marquee or Shift+click, Cmd+Alt+C deduplicates and batches all selected components with one shared route:

@/Users/project/src/components/HeaderBar.tsx:8:2
Hierarchy: `App` > `HeaderBar`

@/Users/project/src/components/MetricCard.tsx:24:5
Hierarchy: `App` > `DashboardPage` > `MetricCard`

Route: /dashboard

Paste directly into Cursor, Claude Code, or Copilot prompts so the AI immediately understands every target component's exact file location and runtime tree position.


🎯 Playgrounds

The repository provides 5 preconfigured playgrounds for hands-on testing:

# React Playground (Vite)
pnpm play:react

# Vue 3 Playground (Vite)
pnpm play:vue

# Svelte Playground (Vite)
pnpm play:svelte

# Next.js Playground (App Router)
pnpm play:next

# Nuxt 3 Playground (Vite + Nitro)
pnpm play:nuxt

🏗️ Architecture

This repository is structured as a pnpm monorepo:


🛠️ Local Development

# Install dependencies
pnpm install

# Run unit tests
pnpm test

# Run type check
pnpm typecheck

# Build all packages
pnpm build

# Full pipeline check
pnpm release:check

📄 License

MIT

About

Vite devtools for locating rendered React and Vue elements in source code.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages