
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
@hono/node-server
Advanced tools
This adapter @hono/node-server allows you to run your Hono application on Node.js.
Initially, Hono wasn't designed for Node.js, but with this adapter, you can now use Hono on Node.js.
It utilizes web standard APIs implemented in Node.js version 18 or higher.
Hono is 3.5 times faster than Express.
Express:
$ bombardier -d 10s --fasthttp http://localhost:3000/
Statistics Avg Stdev Max
Reqs/sec 16438.94 1603.39 19155.47
Latency 7.60ms 7.51ms 559.89ms
HTTP codes:
1xx - 0, 2xx - 164494, 3xx - 0, 4xx - 0, 5xx - 0
others - 0
Throughput: 4.55MB/s
Hono + @hono/node-server:
$ bombardier -d 10s --fasthttp http://localhost:3000/
Statistics Avg Stdev Max
Reqs/sec 58296.56 5512.74 74403.56
Latency 2.14ms 1.46ms 190.92ms
HTTP codes:
1xx - 0, 2xx - 583059, 3xx - 0, 4xx - 0, 5xx - 0
others - 0
Throughput: 12.56MB/s
It works on Node.js versions greater than 18.x. The specific required Node.js versions are as follows:
Essentially, you can simply use the latest version of each major release.
You can install it from the npm registry with npm command:
npm install @hono/node-server
Or use yarn:
yarn add @hono/node-server
Just import @hono/node-server at the top and write the code as usual.
The same code that runs on Cloudflare Workers, Deno, and Bun will work.
import { serve } from '@hono/node-server'
import { Hono } from 'hono'
const app = new Hono()
app.get('/', (c) => c.text('Hono meets Node.js'))
serve(app, (info) => {
console.log(`Listening on http://localhost:${info.port}`) // Listening on http://localhost:3000
})
For example, run it using ts-node. Then an HTTP server will be launched. The default port is 3000.
ts-node ./index.ts
Open http://localhost:3000 with your browser.
portserve({
fetch: app.fetch,
port: 8787, // Port number, default is 3000
})
createServerimport { createServer } from 'node:https'
import fs from 'node:fs'
//...
serve({
fetch: app.fetch,
createServer: createServer,
serverOptions: {
key: fs.readFileSync('test/fixtures/keys/agent1-key.pem'),
cert: fs.readFileSync('test/fixtures/keys/agent1-cert.pem'),
},
})
overrideGlobalObjectsThe default value is true. The Node.js Adapter rewrites the global Request/Response and uses a lightweight Request/Response to improve performance. If you don't want to do that, set false.
serve({
fetch: app.fetch,
overrideGlobalObjects: false,
})
autoCleanupIncomingThe default value is true. The Node.js Adapter automatically cleans up (explicitly call destroy() method) if application is not finished to consume the incoming request. If you don't want to do that, set false.
If the application accepts connections from arbitrary clients, this cleanup must be done otherwise incomplete requests from clients may cause the application to stop responding. If your application only accepts connections from trusted clients, such as in a reverse proxy environment and there is no process that returns a response without reading the body of the POST request all the way through, you can improve performance by setting it to false.
serve({
fetch: app.fetch,
autoCleanupIncoming: false,
})
Most built-in middleware also works with Node.js. Read the documentation and use the Middleware of your liking.
import { serve } from '@hono/node-server'
import { Hono } from 'hono'
import { prettyJSON } from 'hono/pretty-json'
const app = new Hono()
app.get('*', prettyJSON())
app.get('/', (c) => c.json({ 'Hono meets': 'Node.js' }))
serve(app)
Use Serve Static Middleware that has been created for Node.js.
import { serveStatic } from '@hono/node-server/serve-static'
//...
app.use('/static/*', serveStatic({ root: './' }))
If using a relative path, root will be relative to the current working directory from which the app was started.
This can cause confusion when running your application locally.
Imagine your project structure is:
my-hono-project/
src/
index.ts
static/
index.html
Typically, you would run your app from the project's root directory (my-hono-project),
so you would need the following code to serve the static folder:
app.use('/static/*', serveStatic({ root: './static' }))
Notice that root here is not relative to src/index.ts, rather to my-hono-project.
rewriteRequestPathIf you want to serve files in ./.foojs with the request path /__foo/*, you can write like the following.
app.use(
'/__foo/*',
serveStatic({
root: './.foojs/',
rewriteRequestPath: (path: string) => path.replace(/^\/__foo/, ''),
})
)
onFoundYou can specify handling when the requested file is found with onFound.
app.use(
'/static/*',
serveStatic({
// ...
onFound: (_path, c) => {
c.header('Cache-Control', `public, immutable, max-age=31536000`)
},
})
)
onNotFoundThe onNotFound is useful for debugging. You can write a handle for when a file is not found.
app.use(
'/static/*',
serveStatic({
root: './non-existent-dir',
onNotFound: (path, c) => {
console.log(`${path} is not found, request to ${c.req.path}`)
},
})
)
precompressedThe precompressed option checks if files with extensions like .br or .gz are available and serves them based on the Accept-Encoding header. It prioritizes Brotli, then Zstd, and Gzip. If none are available, it serves the original file.
app.use(
'/static/*',
serveStatic({
precompressed: true,
})
)
You can use the ConnInfo Helper by importing getConnInfo from @hono/node-server/conninfo.
import { getConnInfo } from '@hono/node-server/conninfo'
app.get('/', (c) => {
const info = getConnInfo(c) // info is `ConnInfo`
return c.text(`Your remote address is ${info.remote.address}`)
})
You can access the Node.js API from c.env in Node.js. For example, if you want to specify a type, you can write the following.
import { serve } from '@hono/node-server'
import type { HttpBindings } from '@hono/node-server'
import { Hono } from 'hono'
const app = new Hono<{ Bindings: HttpBindings }>()
app.get('/', (c) => {
return c.json({
remoteAddress: c.env.incoming.socket.remoteAddress,
})
})
serve(app)
The APIs that you can get from c.env are as follows.
type HttpBindings = {
incoming: IncomingMessage
outgoing: ServerResponse
}
type Http2Bindings = {
incoming: Http2ServerRequest
outgoing: Http2ServerResponse
}
You can directly respond to the client from the Node.js API.
In that case, the response from Hono should be ignored, so return RESPONSE_ALREADY_SENT.
[!NOTE] This feature can be used when migrating existing Node.js applications to Hono, but we recommend using Hono's API for new applications.
import { serve } from '@hono/node-server'
import type { HttpBindings } from '@hono/node-server'
import { RESPONSE_ALREADY_SENT } from '@hono/node-server/utils/response'
import { Hono } from 'hono'
const app = new Hono<{ Bindings: HttpBindings }>()
app.get('/', (c) => {
const { outgoing } = c.env
outgoing.writeHead(200, { 'Content-Type': 'text/plain' })
outgoing.end('Hello World\n')
return RESPONSE_ALREADY_SENT
})
serve(app)
Yusuke Wada https://github.com/yusukebe
MIT
FAQs
Node.js Adapter for Hono
The npm package @hono/node-server receives a total of 5,947,766 weekly downloads. As such, @hono/node-server popularity was classified as popular.
We found that @hono/node-server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.