Import
Display Routes
showRoutes
Print all registered routes to the console in a formatted table:Hono
required
The Hono application instance
ShowRoutesOptions
Optional configuration object
Options
boolean
default:"false"
When
true, displays all middleware in addition to handlersboolean
Enable or disable colored output. Auto-detects terminal support by default.
Verbose Mode
Show all middleware and handlers:Colorization
Control colored output:Inspect Routes
inspectRoutes
Get route information as a data structure for programmatic use:Hono
required
The Hono application instance
RouteData[] - Array of route information objects
RouteData Type
Get Router Name
getRouterName
Get the name of the router being used:Hono
required
The Hono application instance
string - The name of the router implementation
Named Functions
Use named functions to get meaningful output:Named functions provide better debugging information than anonymous functions. The helper will show
[middleware] or [handler] for unnamed functions.Use Cases
Startup Logging
Display routes when the server starts:Generate Documentation
Generate route documentation from your app:Testing Routes
Validate expected routes in tests:Route Comparison
Compare routes between different configurations:Debug Middleware Order
Visualize middleware execution order:Router Detection
Identify which router implementation is being used:Filtering Routes
Filter routes programmatically:Type Definitions
Best Practices
Development Only
Use these utilities in development only. Avoid in production for performance.
Named Functions
Use named functions for better debugging and route inspection output
Verbose for Debug
Enable verbose mode when debugging middleware order or execution flow
Test Route Coverage
Use
inspectRoutes in tests to validate expected routes are registeredThe
showRoutes function automatically detects color support in your terminal. You can override this with the colorize option.