Skip to main content
The Dev helper provides utilities for inspecting and visualizing your application’s routes during development. These tools help you understand your route structure, debug routing issues, and display route information.

Import

Display Routes

showRoutes

Print all registered routes to the console in a formatted table:
Output:
Parameters:
Hono
required
The Hono application instance
ShowRoutesOptions
Optional configuration object

Options

boolean
default:"false"
When true, displays all middleware in addition to handlers
boolean
Enable or disable colored output. Auto-detects terminal support by default.

Verbose Mode

Show all middleware and handlers:
Output:

Colorization

Control colored output:

Inspect Routes

inspectRoutes

Get route information as a data structure for programmatic use:
Output:
Parameters:
Hono
required
The Hono application instance
Returns: RouteData[] - Array of route information objects

RouteData Type

Get Router Name

getRouterName

Get the name of the router being used:
Parameters:
Hono
required
The Hono application instance
Returns: string - The name of the router implementation

Named Functions

Use named functions to get meaningful output:
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:
Output:

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 registered
These helpers are intended for development and debugging. Avoid using them in production code as they may impact performance.
The showRoutes function automatically detects color support in your terminal. You can override this with the colorize option.