Dev News Daily ENDE

Hono 4.13.13 turns app.mount() into a middleware and schedules the method for removal in v5

Hono, the small TypeScript web framework that runs on Cloudflare Workers, Deno, Bun, Node.js and other runtimes, released version 4.13.13 on 4 October. Its headline change is a new way to embed another router or request handler inside a Hono application.

What changes. Until now, app.mount() let a Hono app hand a path prefix to a different router, such as itty-router, or to any function that takes a Request and returns a Response. That capability is now available as the Mount Middleware, imported from hono/mount. Because it is just a handler, it is registered with an ordinary route method:

import { Hono } from 'hono'
import { mount } from 'hono/mount'
const app = new Hono()
app.all('/itty-router/*', mount(ittyRouter.handle))
Hono 4.13.13 turns app.mount() into a middleware and schedules the method for removal in v5
Hono 4.13.13 turns app.mount() into a middleware and schedules the method for removal in v5 — Dev News Daily

The release notes give the migration as a single line: app.mount('/itty-router', ittyRouter.handle) becomes app.all('/itty-router/*', mount(ittyRouter.handle)). Note the explicit wildcard in the path, which the old method implied.

The deprecation. app.mount() still works throughout version 4 but is marked deprecated and will be removed in version 5. No date for Hono 5 is given in the release.

Other fixes in the release. JSX function components may now return a JSXNode, and a test now simulates a network error for an undefined route in the client's response parser. Documentation comments for some request getters were corrected.

Context. The change follows the direction Hono has taken in recent patch releases of moving functionality out of the core class and into separately importable modules. In 4.13.10 at the end of September, for example, the runtime adapters moved into separate packages.

What it means

For most applications nothing changes today, but code that composes Hono with other routers, or mounts legacy handlers under a prefix during a migration, should switch to the middleware form now. It costs one line, makes the matched path explicit, and avoids a forced change on the day version 5 ships.

Primary source
Hono (GitHub release)
https://github.com/honojs/hono/releases/tag/v4.13.13