🚀 The next iteration of React DevTools - A powerful Vite plugin that brings React DevTools directly into your development workflow with advanced debugging capabilities, source code navigation, and performance analysis.
- 🌳 Component Tree Inspector - Real-time React component hierarchy visualization with search and filtering
- 🔧 Props & State Inspector - View and edit component props, state, and hooks in real-time
- 🪝 Advanced Hooks Debugging - Inspect useState, useEffect, useContext, and custom hooks with dependency tracking
- 📝 Source Code Navigation - Click-to-source functionality with multi-editor support (VS Code, WebStorm, Sublime, etc.)
- 📊 React Profiler Integration - Component rendering performance analysis with flame graphs
- 🔄 Re-render Tracking - Highlight and analyze component re-renders with reason detection
- ⏱️ Time Travel Debugging - State history recording with rollback and replay capabilities
- 🎯 Performance Bottleneck Detection - Identify slow components and optimization opportunities
- 🔌 WebSocket Communication - Real-time updates without page refresh
- 🔥 Hot Module Replacement - Deep integration with Vite's HMR system
- 🎨 Advanced Theming - Light/dark themes with system sync and customization
- 🔍 Smart Search & Filter - Quickly find components in large applications
- 🚀 Zero Configuration - Works out of the box with intelligent defaults
- ⚡ Native Vite Plugin - Built specifically for Vite with optimal performance
- 🏗️ Development Focused - Automatically disabled in production builds
- 📦 Lightweight - Minimal impact on development server performance
- 🗺️ Source Map Integration - Accurate line-by-line navigation with TypeScript support
# npm
npm install vite-plugin-react-devtools --save-dev
# pnpm
pnpm add -D vite-plugin-react-devtools
# yarn
yarn add -D vite-plugin-react-devtoolsAdd the plugin to your vite.config.js or vite.config.ts:
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import reactDevTools from 'vite-plugin-react-devtools'
export default defineConfig({
plugins: [
react(),
reactDevTools(), // Add this line
],
})That's it! Start your development server and you'll see a React logo button in the top-right corner of your app.
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import reactDevTools from 'vite-plugin-react-devtools'
export default defineConfig({
plugins: [
react(),
reactDevTools({
port: 8097, // WebSocket port (default: 8097)
componentInspector: true, // Enable component inspector (default: true)
launchEditor: 'code', // Editor for source navigation (default: 'code')
enableInProduction: false, // Enable in production (default: false)
}),
],
})- Toggle Button: Click the ⚛️ button in the top-right corner of your app
- Keyboard Shortcut: Press
Ctrl+Shift+D(coming soon) - Programmatically: Use
window.__REACT_DEVTOOLS_UI__.open()
- Expand/Collapse: Click the ▶/▼ arrows next to components
- Select Component: Click on any component name to inspect it
- Search: Use the search box to filter components by name
- Props Preview: See a quick preview of component props inline
- Real-time Updates: Props and state update automatically as your app changes
- Nested Objects: Expandable tree view for complex data structures
- Type Information: Clear indication of data types (string, number, function, etc.)
- Edit Values: Click on values to edit them directly (coming soon)
- Hook List: See all hooks used by the selected component
- Hook Values: Current values of useState, useReducer, etc.
- Dependencies: View useEffect and useMemo dependencies
- Custom Hooks: Debug your custom hooks with detailed information
The source navigation feature allows you to quickly jump from React components in the DevTools to their source code in your editor. This dramatically speeds up debugging and development workflows.
- Click-to-Source: Click the 📝 button next to any component to open its source file
- Multi-Editor Support: Works with VS Code, WebStorm, Sublime Text, Atom, Vim, Emacs, and more
- Smart Path Resolution: Automatically finds component files using common naming patterns
- Line-Accurate Navigation: Opens files at the exact line where the component is defined
- Zero Configuration: Works out of the box with sensible defaults
| Editor | Configuration Value | Command |
|---|---|---|
| Visual Studio Code | 'code' |
code |
| VS Code Insiders | 'code-insiders' |
code-insiders |
| WebStorm | 'webstorm' |
webstorm |
| IntelliJ IDEA | 'idea' |
idea |
| Sublime Text | 'sublime' |
subl |
| Atom | 'atom' |
atom |
| Vim | 'vim' |
vim |
| Emacs | 'emacs' |
emacs |
# Install VS Code command line tools
# On macOS: Cmd+Shift+P → "Shell Command: Install 'code' command in PATH"
# On Windows/Linux: Usually installed automatically# Add WebStorm to PATH
# Tools → Create Command-line Launcher# Create symlink (macOS/Linux)
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl-
Component Tree Navigation:
- Open React DevTools by clicking the ⚛️ button
- Navigate to the "Components" tab
- Find the component you want to inspect
- Click the 📝 button next to the component name
- Your editor will open with the component's source file
-
Props Inspector Navigation:
- Select a component in the component tree
- In the props inspector panel, click the 📝 button in the component header
- The component's source file will open in your editor
-
Check if editor is in PATH:
# Test if your editor command works code --version webstorm --version subl --version -
Verify editor configuration:
reactDevTools({ launchEditor: 'code', // Make sure this matches your editor })
-
Check console for errors: Open browser DevTools and look for error messages.
// eslint-disable-next-line ts/no-unused-vars
interface ReactDevToolsOptions {
/**
* Port for the DevTools WebSocket server
* @default 8097
*/
port?: number
/**
* Enable component inspector
* @default true
*/
componentInspector?: boolean
/**
* Target editor when opening source files
* @default 'code'
*/
launchEditor?: 'code' | 'code-insiders' | 'webstorm' | 'atom' | 'sublime' | 'vim' | string
/**
* Enable React DevTools in production
* @default false
*/
enableInProduction?: boolean
}- VS Code:
'code'(default) - VS Code Insiders:
'code-insiders' - WebStorm:
'webstorm' - Atom:
'atom' - Sublime Text:
'sublime' - Vim:
'vim' - Custom: Provide your own editor command
// Open DevTools
window.__REACT_DEVTOOLS_UI__.open()
// Close DevTools
window.__REACT_DEVTOOLS_UI__.close()
// Toggle DevTools
window.__REACT_DEVTOOLS_UI__.toggle()
// Send custom message to DevTools
window.__REACT_DEVTOOLS__.send({
type: 'CUSTOM_MESSAGE',
data: { /* your data */ }
})// In your test setup
beforeEach(() => {
// Ensure DevTools is available in tests
if (window.__REACT_DEVTOOLS_UI__) {
window.__REACT_DEVTOOLS_UI__.close()
}
})The DevTools UI automatically adapts to your system theme (light/dark). You can also manually control the theme:
// Set theme (coming soon)
window.__REACT_DEVTOOLS_UI__.setTheme('dark') // 'light' | 'dark' | 'auto'- Check React Version: Ensure you're using React 16.8+ with hooks support
- Verify Plugin Order: Make sure
reactDevTools()comes afterreact()in your plugins array - Check Console: Look for connection messages in the browser console
- Port Conflicts: Try changing the port if 8097 is already in use
- Large Component Trees: Use the search feature to filter components
- Frequent Updates: The DevTools refresh every second when open
- Production Mode: Ensure the plugin is disabled in production builds
# Check if port is available
netstat -an | grep 8097
# Try a different port
reactDevTools({ port: 8098 })- Component Tree Inspector - Real-time React component hierarchy visualization
- Props & State Inspector - View and edit component props and state
- Hooks Debugging - Inspect useState, useEffect, and custom hooks
- Source Code Navigation - Click-to-source with multi-editor support
- WebSocket Communication - Real-time updates without page refresh
- Basic Theme Support - Light/dark themes with system sync
- React Profiler Integration - Component rendering performance analysis
- Re-render Tracking - Highlight and analyze component re-renders
- Performance Bottleneck Detection - Identify slow components
- Flame Graph Visualization - Visual performance analysis
- Render Timing Statistics - Detailed timing information
- Time Travel Debugging - State history recording with rollback
- Component Snapshots - Save and compare component states
- HMR Deep Integration - Enhanced Hot Module Replacement
- Console Integration - Access selected component via
$r - Network Request Tracking - API calls associated with components
- Advanced Theming - Custom color schemes and theme editor
- Layout Customization - Adjustable panels and multiple layouts
- Keyboard Shortcuts - Full keyboard navigation support
- Search & Filter Enhancements - Advanced component filtering
- Export/Import - Save and share debugging sessions
- Plugin System - Third-party plugin support
- Custom Inspectors - User-defined component inspectors
- API Extensions - Extensible DevTools API
- Integration Ecosystem - Redux, Zustand, React Query support
vite-plugin-react-devtools/
├── src/
│ ├── index.ts # Main plugin entry point
│ ├── types.ts # TypeScript type definitions
│ ├── react-detector.ts # React component detection utilities
│ ├── source-navigation.ts # Source code navigation functionality
│ └── ui.ts # DevTools UI components
├── example/ # Example React app for testing
├── docs/ # Documentation
├── test/ # Test files
└── package.json # Plugin dependencies
- Sets up WebSocket server for DevTools communication
- Injects client script into the browser
- Handles plugin lifecycle and configuration
- Manages source navigation integration
- Accesses React's internal DevTools hook
- Converts Fiber nodes to our component format
- Extracts component hierarchy, props, state, and hooks
- Integrates with React's lifecycle events
- Multi-editor support (VS Code, WebStorm, Sublime, etc.)
- Smart path resolution for component files
- Launches editors with accurate line numbers
- Integrates with Vite's source maps
- Creates the main DevTools panel interface
- Renders component tree visualization
- Implements props/state/hooks inspector
- Manages floating toggle button and interactions
The plugin uses a WebSocket-based architecture for real-time communication:
- Plugin Setup: Vite plugin creates WebSocket server on specified port
- Client Injection: Browser receives DevTools client script via HTML transformation
- React Integration: Client hooks into React's internal DevTools hook
- Data Flow: Component data flows through WebSocket to DevTools UI
- User Interaction: UI sends commands (select component, open source) back to React app
- Node.js 18+
- pnpm (recommended) or npm/yarn
- A React project for testing
-
Clone and Install
git clone https://github.com/Sunny-117/vite-plugin-react-devtools.git cd vite-plugin-react-devtools pnpm install -
Start Development
# Build plugin in watch mode pnpm dev # In another terminal, run example app cd example pnpm install pnpm dev
-
Test the Plugin
- Navigate to
http://localhost:3000 - Click the ⚛️ button to open DevTools
- Test component inspection and source navigation
- Navigate to
Unit Tests
pnpm test # Run unit tests
pnpm test --watch # Watch mode
pnpm typecheck # Type checkingIntegration Tests
- Use the example app to test all features
- Test with different React patterns (hooks, classes, memo, etc.)
- Verify WebSocket communication and error handling
- Test source navigation with different editors
Manual Testing Checklist
- Component tree renders correctly
- Props/state inspection works
- Source navigation opens correct files
- WebSocket connection is stable
- UI responds to component changes
- Search and filtering work
- Theme switching functions properly
- Display React component hierarchy in real-time
- Component search and filtering functionality
- Show component names, props, state, and hooks
- Component selection and highlighting
- Expand/collapse component tree nodes
- Component type indicators (functional/class/memo/etc.)
- Real-time props viewing and editing
- Real-time state viewing and editing
- Support for complex data types (objects, arrays, functions)
- JSON-like expandable tree view
- Type information display
- Value change highlighting
- Inline editing capabilities
- Click component to jump to source code
- Support multiple editors (VS Code, WebStorm, Sublime, etc.)
- Smart path resolution for components
- Line number accuracy
- Integration with Vite's source maps
- Light/dark theme toggle
- Sync with system theme preference
- Basic color scheme customization
- Consistent styling with Vite dev server
- Component rendering performance analysis
- Render timing statistics
- Flame graph visualization
- Performance bottleneck identification
- Commit phase analysis
- Interaction tracking
- Highlight components that re-render
- Analyze re-render reasons (props/state changes)
- Render frequency statistics
- Performance impact assessment
- Re-render cascade visualization
- Display all hooks with current values
- useState, useEffect, useContext detailed info
- Custom hooks debugging support
- Hook dependency tracking
- Hook call order visualization
- useDebugValue integration
- State history recording
- State rollback functionality
- Action replay system
- Timeline visualization
- Snapshot comparison
- Undo/redo operations
- Deep integration with Vite HMR
- Module update visualization
- Dependency graph display
- Preserve DevTools state during HMR
- Smart component state recovery
- Access selected component via
$r - Expose component methods as global variables
- Debug helper functions
- Console logging integration
- Error boundary integration
- Custom color schemes
- Theme editor interface
- Import/export themes
- Component-specific styling
- Animation preferences
- Adjustable panel sizes
- Multiple layout modes (sidebar, bottom panel, popup)
- Dockable panels
- Full-screen mode
- Multi-monitor support
- Component navigation shortcuts
- Search shortcuts
- Panel switching shortcuts
- Quick actions
- Customizable key bindings
- Third-party plugin support
- Plugin marketplace
- Custom inspector plugins
- Theme plugins
- Integration plugins
- Public DevTools API
- Custom message types
- Event system
- Plugin lifecycle hooks
- Configuration API
- Redux DevTools integration
- Zustand store inspection
- React Query cache visualization
- React Router navigation tracking
- Context API visualization
- Touch-friendly interface
- Mobile layout optimization
- Gesture support
- Responsive design
- Mobile debugging features
- Remote device connection
- Network debugging
- Mobile app integration
- Cross-platform support
- Cloud debugging
We welcome contributions! Here's how you can help:
- 🐛 Bug Reports: Found a bug? Open an issue
- 💡 Feature Requests: Have an idea? Start a discussion
- 📝 Documentation: Improve docs, add examples, write guides
- 🔧 Code: Fix bugs, implement features, improve performance
- 🎨 Design: UI/UX improvements, themes, icons
# Clone the repository
git clone https://github.com/Sunny-117/vite-plugin-react-devtools.git
cd vite-plugin-react-devtools
# Install dependencies
pnpm install
# Start development
pnpm dev
# Run tests
pnpm test
# Build the plugin
pnpm build
# Lint and format
pnpm lint
pnpm format- Fork the repository and create a feature branch
- Write tests for new functionality
- Follow the coding style (ESLint + Prettier)
- Update documentation as needed
- Submit a pull request with a clear description
- Use TypeScript for all new code
- Follow the existing ESLint configuration
- Add JSDoc comments for public APIs
- Write tests for new functionality
- Keep commits atomic and well-described
MIT License © 2024-PRESENT Sunny-117
- Inspired by the official React DevTools
- Built with Vite plugin architecture
- UI design inspired by modern developer tools