Every feature in its own compartment.

hono-bento is an opinionated framework for Hono APIs. Each feature is one folder whose spec drives its routes and its OpenAPI docs, and its schemas live in a package every app shares. Small, contained changes, for people and for agents.

$ bun add hono-bento hono zod

Why hono-bento

One folder per feature

A feature's routing table, handlers and data access sit together. Adding an endpoint touches one folder, and nothing outside it reaches in.

apps/api/src/
  features/
    todos/
      spec.ts
      list.ts
      create.ts
      store.ts
    me/
      spec.ts
      retrieve.ts
  specs.ts
packages/schemas/src/
  todos.ts
  me.ts

One spec, two outputs

spec.ts drives the Hono router and the OpenAPI 3.1 document, so what you serve and what you document can't drift.

Shared schemas

Request and response schemas live in a workspace package. The API validates with them; your web app and CLI parse with them.

Pluggable auth

Bring your own strategies (JWT, API keys, sessions) and authorizer (roles, scopes). Scopes without an authorizer fail at startup.

Built for agents

An AGENTS.md to copy, a layout test that says what to move, and these docs as /llms.txt.

Declare it once

A route's contract names its auth, its input and its output. The handler takes every type from it, and the compiler checks the two fit. hono-bento runs authentication, then validation, then your handler.

features/todos/spec.ts
export const contracts = {
  create: contract({
    operation: 'create',
    method: 'post',
    path: '/',
    auth: { scopes: ['todos.write'] },
    validation: { body: todoCreateSchema },
    responses: { 201: { description: 'The todo.', schema: todoSchema } },
  }),
};

export const spec = defineSpec({
  basePath: '/v1/todos',
  name: 'Todos',
  collection: 'todos',
  routes: [route({ ...contracts.create, handler: createTodo })],
});
features/todos/create.ts
export const createTodo = defineHandler<
  Session,
  typeof contracts.create
>(({ body, respond }) =>
  respond(201, store.create(body))
);
app.ts
mountSpecs(app, specs, {
  strategies,
  authorizer,
  validateResponses: true,
});
Walk through adding a feature