Vite + React
Set up debugger in a Vite + React project.
Last updated March 19, 2026
Vite + React
This guide covers adding debugger to a Vite + React project. The setup takes one step.
| Feature | Support |
|---|---|
| Server console | Yes |
| Server errors | Yes |
| HTTP requests | Yes |
| Browser script injection | Automatic |
Prerequisites
- Vite 5 or later
1. Add the plugin
Import and add debuggerPlugin to your Vite config:
// vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { debuggerPlugin } from '@ephem-sh/debugger/vite'
export default defineConfig({
plugins: [react(), debuggerPlugin()],
})
That's it. No other files to create or modify.
Verify
Start your dev server:
npm run dev
The terminal output includes the debugger session line:
VITE v8.x.x ready in 500 ms
-> Local: http://localhost:5173/
-> @ephem-sh/debugger: session dev-abc123
Open your app in a browser, then query with the CLI:
npx dbg statuspnpm dlx dbg statusbun x dbg statusyarn dlx dbg statusnpx dbg browser consolepnpm dlx dbg browser consolebun x dbg browser consoleyarn dlx dbg browser consolenpx dbg server consolepnpm dlx dbg server consolebun x dbg server consoleyarn dlx dbg server consoleHow it works
The Vite plugin does three things during development:
-
configureServercreates the log store, patches server-side console methods, starts the IPC bridge, and adds connect middleware for the ingest endpoint (/_/d) and client script (/_/d.js). -
transformIndexHtmlinjects two script tags into your HTML: one sets the ingest URL, the other loads the browser client. -
apply: 'serve'ensures the plugin only runs in dev mode. Vite strips it entirely from production builds.
Production safety
The apply: 'serve' option means debugger is never included in
production builds. There's no runtime check needed — Vite removes
the plugin at build time. Your production bundle has zero debugger
code.
Full example
See the complete working example at examples/node/react-vite.



