npx skills add ...
npx skills add pedronauck/skills --skill hono
Use when building Hono web applications or when the user asks about Hono APIs, routing, middleware, JSX, validation, testing, or streaming. TRIGGER when code imports from 'hono' or 'hono/*', or user mentions Hono. Use Hono CLI to inspect and test the app.
npx skills add pedronauck/skills --skill hono
Build Hono web applications. This skill provides inline API knowledge for AI. Use Hono CLI to inspect and test the app.
For details beyond this inline reference, fetch the latest documentation from https://hono.dev. Get the index of doc pages from https://hono.dev/llms.txt, then fetch a page with the Accept: text/markdown header to receive it as Markdown:
Use Hono CLI to inspect and test the app. Install it in the project, then let the CLI explain itself:
Follow the output. It explains every command (routes, request, batch, snapshot, benchmark, optimize, ssg), the JSON output contract, and the workflow.
Notes:
hono request sends a request with app.request() — no server needed. Do not pass credentials directly in CLI arguments; use environment variables for sensitive values.
For Cloudflare Workers bindings (KV, D1, R2, etc.), use hono request /path --runtime workerd. It starts the app with the wrangler config of the project, so the local bindings (c.env) are real. wrangler must be installed in the project.
For several requests, or a flow that keeps state (POST, then use the returned id), run them in one hono batch - call. One JSON object per line; save a value and use it as {{id}} in later steps. The steps share one app instance. Declare the expected status/body per step with expect (body is a deep partial match) and iterate until the summary shows "failed": 0:
Before changing existing routes, capture the current behavior: npx hono snapshot prints it as batch JSONL lines (real responses become the expect). Keep the lines, make the change, then rerun them with npx hono batch - until "failed": 0.
On a large API, use npx hono snapshot --status-only and npx hono batch - --compact — same loop, much smaller output. A failed step carries diff: fix what it names.
Middleware executes in registration order. await next() calls the next middleware/handler, and code after next() runs on the way back:
Validation targets: json, form, query, header, param, cookie.
In tsconfig.json:
Or use pragma: /** @jsxImportSource hono/jsx */
Important: Files using JSX must have a .tsx extension. Rename .ts to .tsx or the compiler will fail.
Use jsxRenderer middleware for layouts. For details, see https://hono.dev/docs/middleware/builtin/jsx-renderer
Test endpoints without starting an HTTP server:
Type-safe API client using shared types between server and client.
IMPORTANT: Routes MUST be chained for type inference to work. Without chaining, the client cannot infer route types.
Type utilities:
Helpers are utility functions imported from hono/<helper-name>:
Available helpers: Accepts, Adapter, ConnInfo, Cookie, css, Dev, Factory, html, JWT, Proxy, Route, SSG, Streaming, Testing, WebSocket.
For details, see https://hono.dev/docs/helpers/<helper-name> (fetch with Accept: text/markdown).
Use createFactory to define Env once and share it across app, middleware, and handlers:
app.route() to organize large apps by feature, not Rails-style controllers.createFactory() to share Env type across app, middleware, and handlers.c.set()/c.get() to pass data between middleware and handlers.export type AppType = typeof routesapp.request() for testing — no server startup needed.Hono runs on multiple runtimes. The default export works for Cloudflare Workers, Deno, and Bun. For Node.js, use the Node adapter: