Skip to content
otncPublic

About

Helper for replace Express.js to Hono.

Topics

Resources

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

ExpHono

Run your Express app on Hono. A migration-first Express compatibility layer for Node.js, Cloudflare Workers, Deno and Bun.

npm GitHub Workflow Status GitHub Node

ExpHono re-implements the Express API on top of Hono, so an existing Express app can run unmodified on runtimes Express itself cannot reach — Cloudflare Workers, Deno and Bun — while still working on Node.js. The goal is migration, not a rewrite: keep writing app.get(...), req.query, res.json(...) and the middleware you already have.

Install

npm install exphono

Usage

The default export behaves like express(), and app is still a callable function so app.use('/sub', subApp) and http.createServer(app) keep working on Node.js.

import express from 'exphono'

const app = express()

app.get('/', (req, res) => {
  res.json({ hello: 'world' })
})

app.listen(3000)

On Cloudflare Workers, Deno and Bun, deploy the app with app.worker instead of the app itself. A function default export is misread as a Durable Object class on Workers, so the export has to be a plain object:

import express from 'exphono'

const app = express()

app.get('/', (req, res) => {
  res.json({ hello: 'world' })
})

export default app.worker

Pinning an Express version

Express 4 and 5 differ in a few places — the query parser, whether req.host strips the port, and which deprecated APIs still exist. exphono follows Express 5 semantics by default; import exphono/v4 or exphono/v5 to pin one explicitly, independent of whichever module loaded first:

import express from 'exphono/v4'

Diagnostics

Anything ExpHono degrades or cannot reproduce on the current runtime is surfaced with a stable EXPHONO_E0xx code rather than failing silently. By default each code warns once and execution continues; enable strict mode to throw instead:

import { configure } from 'exphono'

configure({ strict: true })

See docs/errors.md for what each code means and how to resolve it.

Status

ExpHono is verified against the real Express test suite, not just its own tests -- and enforced in CI, not just locally. As of the last recorded run, it passes 1113 of 1116 Express 5 tests (about 100%) and 1179 of 1198 Express 4 tests (about 98%, exphono/v4); the failure count for each is tracked as a ratchet so it can only improve. See test/express-suite/ for how the suite is run.

Some gaps are structural rather than missing work — anything that needs a real filesystem or a TCP listener (app.listen(), res.sendFile, on-disk view lookups) has no equivalent on Cloudflare Workers, and ExpHono reports that with a diagnostic code instead of pretending to support it.

Requirements

  • Node.js >= 20 (Node.js is not required on Bun, Deno or Workers deployments)

Contributing

Contributions are welcome! See CONTRIBUTING.md for details.

License

Distributed under the MIT License.

About

Helper for replace Express.js to Hono.

Topics

Resources

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

Generated from oto-lab/npm-biome-ts