hono icon indicating copy to clipboard operation
hono copied to clipboard

Add support for bun router

Open thelovekesh opened this issue 7 months ago • 5 comments

What is the feature you are proposing?

Hono works great out of the box with Bun using the existing routers.

Now that Bun has stable support for its native HTTP router, is there any plan to support or integrate Bun's router when the runtime is Bun?

More info: https://bun.com/docs/api/http#routing

thelovekesh avatar Sep 27 '25 10:09 thelovekesh

it could be implemented but would need a workaround because native http router need a Response or a function that it can invoke. and if you are building natively you would need to add each controller by yourself. to support Bun router we can do is to expose a method to users like - app.BunRoute("METHOD", "PATH", Handler ) and in core hono class we would need to generate each functions dynamically then bun's http router works.

for playing around it , use diese.js which is also a framework and has support of bun's native http router. check - https://github.com/pradeepbgs/diesel/blob/main/example/bun/app.ts line no 395 - https://github.com/pradeepbgs/diesel/blob/main/src/main.ts

pradeepbgs avatar Sep 27 '25 11:09 pradeepbgs

@yusukebe can i workaround this to support native bun http router?

pradeepbgs avatar Sep 27 '25 11:09 pradeepbgs

We never add features that depend on runtime-specific functions.

yusukebe avatar Sep 27 '25 22:09 yusukebe

@yusukebe can this functionality exist as an adapter? or a standalone package which can be passed to hono somehow?

thelovekesh avatar Sep 28 '25 04:09 thelovekesh

@thelovekesh

I think it will be a good idea to create an independent router outside of this hono package. Like this:

import { Hono } from 'hono'
import { BunRouter } from '@hono/bun-router'

const app = new Hono({
  router: new BunRouter()
})

But I don't know if a router with Bun features will be fast enough.

yusukebe avatar Sep 29 '25 08:09 yusukebe