Handlers

Any route file can export const app, a Hono sub-app that serves any HTTP method. Its routes are file-relative. A handler at routes/api.ts declares .get("/") for GET /api and .post("/echo") for POST /api/echo.

// app/routes/api.ts  →  mounted at /api
import { Hono } from "hono";

export const app = new Hono()
  .get("/", (c) => c.json({ ok: true })) // GET  /api
  .post("/echo", async (c) => c.json({ echo: await c.req.json() })); // POST /api/echo

Use a handler for a standalone endpoint with no page. For a form that belongs to a page, use an action.

Health checks

For a health check a load balancer or uptime probe can hit, add a handler that returns 200:

// app/routes/health.ts  →  GET /health returns { ok: true }
import { Hono } from "hono";

export const app = new Hono().get("/", (c) => c.json({ ok: true }));