Skip to Content

Last Updated: 3/11/2026


Routers

Hono has five routers, each optimized for different scenarios.

RegExpRouter

The fastest router in JavaScript.

RegExpRouter compiles all routes into a single large regular expression, enabling one-time matching instead of linear loops.

Traditional approach (slow):

Route 1 → Check Route 2 → Check Route 3 → Check ...

RegExpRouter (fast):

All routes → One regex → Match!

Limitation: Doesn’t support all routing patterns, so it’s typically combined with TrieRouter in SmartRouter.

TrieRouter

Uses Trie-tree algorithm for routing.

Characteristics:

  • No linear loops
  • Supports all routing patterns
  • Slower than RegExpRouter but much faster than Express

SmartRouter

Automatically selects the best router for your routes.

Default configuration:

new SmartRouter({ routers: [new RegExpRouter(), new TrieRouter()], })

SmartRouter detects the fastest router at startup and uses it throughout the application lifecycle.

LinearRouter

Optimized for “one shot” scenarios where the app initializes on every request.

Benchmark (includes registration phase):

LinearRouter 1.82 µs/iter KoaTreeRouter 3.81 µs/iter (2.1x slower) MedleyRouter 4.44 µs/iter (2.45x slower) TrekRouter 5.84 µs/iter (3.21x slower) FindMyWay 60.36 µs/iter (33.24x slower)

Best for: AWS Lambda, environments with frequent cold starts

PatternRouter

The smallest router.

Size: Under 15KB minified

Example:

$ npx wrangler deploy --minify ./src/index.ts Total Upload: 14.68 KiB / gzip: 5.38 KiB

Best for: Extremely resource-constrained environments

Router Comparison

RouterSpeedSizeRegistrationUse Case
RegExpRouterFastestMediumSlowLong-running servers
TrieRouterFastMediumMediumGeneral purpose
SmartRouterAdaptiveMediumAdaptiveDefault choice
LinearRouterFastMediumFastestPer-request init
PatternRouterMediumSmallestFastLimited resources

Choosing a Router

Most apps: Use the default (SmartRouter)

Per-request init: Use hono/quick (LinearRouter)

Smallest bundle: Use hono/tiny (PatternRouter)

Custom needs: Manually specify router in constructor