close
Skip to content

feat(mount)!: introduce Mount Middleware and obsolete app.mount - #5221

Draft
yusukebe wants to merge 1 commit into
mainfrom
feat/mount-middleware
Draft

feat(mount)!: introduce Mount Middleware and obsolete app.mount#5221
yusukebe wants to merge 1 commit into
mainfrom
feat/mount-middleware

Conversation

@yusukebe

@yusukebe yusukebe commented Aug 12, 2026

Copy link
Copy Markdown
Member

I realized that app.mount() doesn't need to be placed in hono-base.ts. The codebase of app.mount() is a little bit fat compared to other methods in hono-base.ts, though the lines are very few in the real world. Anyway, the unnecessary should be removed from hono-base.ts.

So, we can make it a middleware called Mount Middleware. The usage is below:

import { Router as IttyRouter } from 'itty-router'
import { Hono } from 'hono'
import { mount } from 'hono/mount'

const ittyRouter = IttyRouter()
ittyRouter.get('/hello', () => new Response('Hello from itty-router'))

const app = new Hono()
app.all('/itty-router/*', mount(ittyRouter.handle))

I think the API syntax is very Hono-like and love it.

As a result, the bundle size will be 501B smaller (vs current main):

CleanShot 2026-08-12 at 21 31 59@2x

This PR will obsolete app.mount() completely, so this is a breaking change. Should be introduced in the next major release v5.

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code
  • Add TSDoc/JSDoc to document the code

@yusukebe
yusukebe marked this pull request as draft August 12, 2026 12:27
@github-actions

Copy link
Copy Markdown

Bundle size check

main (26de731) #5221 (7bf1a2b) +/-
Bundle Size (B) 19,000B 18,499B -501B
Bundle Size (KB) 18.55K 18.07K -0.48K

Compiler Diagnostics (tsc)

main (26de731) #5221 (7bf1a2b) +/-
Files 83 83 0
Lines 59,440 59,400 -40
Identifiers 60,621 60,569 -52
Symbols 106,532 106,201 -331
Types 163,091 163,074 -17
Instantiations 414,023 413,935 -88
Memory used 168,508K 169,101K 593K
I/O read 0.02s 0.01s -0.01s
I/O write 0s 0s 0s
Parse time 0.33s 0.33s 0s
Bind time 0.13s 0.15s 0.02s
Check time 1.37s 1.32s -0.05s
Emit time 0s 0s 0s
Total time 1.83s 1.81s -0.02s

Compiler Diagnostics (typescript-go)

main (26de731) #5221 (7bf1a2b) +/-
Files 215 215 0
Lines 147,088 147,048 -40
Identifiers 121,974 121,922 -52
Symbols 189,100 188,569 -531
Types 262,348 262,330 -18
Instantiations 621,588 621,500 -88
Memory used 161,795K 161,172K -623K
Memory allocs 1,781,183 1,780,945 -238
Config time 0.001s 0.001s 0s
BuildInfo read time 0.001s 0s -0.001s
Parse time 0.084s 0.093s 0.009s
Bind time 0s 0s 0s
Check time 0.428s 0.431s 0.003s
Emit time 0.005s 0.005s 0s
Changes compute time 0.023s 0.028s 0.005s
Total time 0.571s 0.591s 0.02s

Reported by octocov

@github-actions

Copy link
Copy Markdown

HTTP Performance Benchmark

Framework Runtime Average Ping Query Body
hono (origin/main) bun 36,812.83 49,950.15 34,020.43 26,467.90
hono (current) bun 36,039.57 49,446.31 32,514.94 26,157.47
Change -2.10% -1.01% -4.43% -1.17%

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.92%. Comparing base (26de731) to head (ef48b56).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5221      +/-   ##
==========================================
+ Coverage   79.77%   79.92%   +0.15%     
==========================================
  Files         155      156       +1     
  Lines       10930    10906      -24     
  Branches     2290     2290              
==========================================
- Hits         8719     8717       -2     
+ Misses       2211     2189      -22     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yusukebe yusukebe added the v5 label Aug 12, 2026
@yusukebe yusukebe mentioned this pull request Aug 12, 2026
12 tasks
@yusukebe

Copy link
Copy Markdown
Member Author

Hey @usualoma !

What do you think of moving the mount feature from hono-base.ts to middleware? I want your opinion on the direction only (no implementation yet)!

@usualoma

Copy link
Copy Markdown
Member

@yusukebe
That's a great change!

I think mount is a feature that symbolizes Hono, but I don't think it's a “characteristic of the Hono instance itself,” so I think it makes sense for it to be implemented as middleware (which will also make the Hono instance smaller).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants