Skip to content

Hono

Hono is a fast and lightweight web application framework, built on Web Standards.

Hono is compatible out of the box with fetch handlers (like on Cloudflare, Netlify, Vercel or Node):

src/handler.ts
import type { ExportedHandler } from "@vite-deploy/netlify";
import { Hono } from "hono";
const app = new Hono();
// ...
export default app satisfies ExportedHandler;

If you want to use Hono with a Node handler, you will need to convert the fetch handler to a Node handler. We recommend srvx:

src/server.ts
import * as http from "node:http";
import { fileURLToPath } from "node:url";
import sirv from "sirv";
import { toNodeHandler } from "srvx/node";
import mod from "./handler";
const server = http.createServer((req, res) =>
sirv(fileURLToPath(new URL("../client/", import.meta.url)), {
setHeaders: (res, pathname) => {
if (pathname.startsWith("/assets/")) {
res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
}
},
})(req, res, () => {
// @ts-expect-error
toNodeHandler(mod.fetch)(req, res);
}),
);
server.listen(3000, () => {
console.log("Ready at http://localhost:3000");
});