The Dev Helper provides utilities for inspecting routes and middleware during development.
Import
import { showRoutes, inspectRoutes, getRouterName } from 'hono/dev'
Functions
showRoutes()
Print all routes to the console.
function showRoutes(app: Hono, options?: ShowRoutesOptions): void
The Hono application instance
Example
import { Hono } from 'hono'
import { showRoutes } from 'hono/dev'
const app = new Hono()
app.get('/api/users', (c) => c.json([]))
app.post('/api/users', (c) => c.json({}))
showRoutes(app)
// Output:
// GET /api/users
// POST /api/users
inspectRoutes()
Get route information as an array.
function inspectRoutes(app: Hono): RouteData[]
The Hono application instance
Array of route information objects
Example
import { inspectRoutes } from 'hono/dev'
const routes = inspectRoutes(app)
routes.forEach(route => {
console.log(`${route.method} ${route.path}`)
console.log(` Middleware count: ${route.middleware.length}`)
})
getRouterName()
Get the name of the router being used.
function getRouterName(app: Hono): string
The Hono application instance
The router name (e.g., ‘SmartRouter’, ‘RegExpRouter’)
Types
type ShowRoutesOptions = {
verbose?: boolean
colorize?: boolean
}
type RouteData = {
path: string
method: string
name: string
isMiddleware: boolean
middleware: string[]
}
Verbose Mode
import { showRoutes } from 'hono/dev'
showRoutes(app, { verbose: true })
// Output includes middleware information:
// GET /api/users
// [logger, cors, auth]