Astro
Set up debugger in an Astro project.
Last updated March 19, 2026
Astro
This guide covers adding debugger to an Astro project. The setup takes two steps.
| Feature | Support |
|---|---|
| Server console | Yes |
| Server errors | Yes |
| HTTP requests | Yes |
| Browser script injection | Automatic |
1. Add the Vite plugin
Update your Astro config:
// astro.config.mjs
import { defineConfig } from 'astro/config'
import { debuggerPlugin } from '@ephem-sh/debugger/vite'
export default defineConfig({
vite: {
plugins: [debuggerPlugin()],
},
})
2. Add the middleware
Create src/middleware.ts:
export { onRequest } from '@ephem-sh/debugger/vite/astro'
If you have existing middleware, compose with sequence:
import { sequence } from 'astro:middleware'
import { onRequest as debuggerMiddleware } from '@ephem-sh/debugger/vite/astro'
export const onRequest = sequence(debuggerMiddleware, yourMiddleware)
Verify
npm run dev
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 consoleProduction safety
The Vite plugin uses apply: 'serve' and is stripped from production
builds. The middleware checks for </body> and the debugger script
before injecting — no injection occurs in production.
Full example
See the complete working example at examples/node/astro.



