hono
Assists with building APIs and web applications using Hono, an ultrafast web framework that runs on Cloudflare Workers, Deno, Bun, Vercel, AWS Lambda, and Node.js. Use when creating edge-first APIs, configuring middleware, or setting up type-safe RPC clients. Trigger words: hono, edge framework, web framework, hono routing, hono middleware.
Usage
Getting Started
- Install the skill using the command above
- Open your AI coding agent (Claude Code, Codex, Gemini CLI, or Cursor)
- Reference the skill in your prompt
- The AI will use the skill's capabilities automatically
Example Prompts
- "Review the open pull requests and summarize what needs attention"
- "Generate a changelog from the last 20 commits on the main branch"
Documentation
Overview
Hono is a lightweight, ultrafast web framework built on Web Standards that runs across multiple runtimes including Cloudflare Workers, Deno, Bun, and Node.js. It provides expressive routing, a rich middleware ecosystem, and type-safe RPC capabilities for building performant APIs and web applications.
Instructions
- When creating a new API, set up routing with
app.get(),app.post(), etc., and organize routes into modular sub-routers usingapp.route(). - When adding middleware, use built-in options like
cors(),logger(),secureHeaders()globally withapp.use("*", ...)and scope auth middleware to protected paths. - When handling requests, use the Context API:
c.req.param()for path params,c.req.query()for query strings,c.req.json()for body parsing, andc.json()for responses. - When validating input, integrate
@hono/zod-validatorwithzValidator("json", schema)for request body, query, and param validation with type inference. - When building type-safe clients, use Hono's RPC mode with
hc<AppType>(baseUrl)to generate a typed HTTP client from route definitions without code generation. - When deploying to Cloudflare Workers, type environment bindings with
new Hono<{ Bindings: Env }>()and usec.executionCtx.waitUntil()for background tasks. - When rendering HTML, use Hono's built-in JSX runtime (
hono/jsx) for lightweight server-side rendering without React. - When writing tests, call
app.request("/path")directly to test routes as pure functions without an HTTP server.
Examples
Example 1: Build a REST API with validation
User request: "Create a Hono API with user CRUD endpoints and Zod validation"
Actions:
- Initialize Hono app with typed environment bindings
- Define Zod schemas for user creation and update payloads
- Create route handlers with
zValidator("json", schema)middleware - Group routes with
app.route("/api/users", userRouter)
Output: A type-safe REST API with validated inputs and proper HTTP status codes.
Example 2: Deploy a multi-runtime API
User request: "Set up a Hono API that works on both Cloudflare Workers and Node.js"
Actions:
- Create shared Hono app with routes and middleware
- Configure Cloudflare Workers entry with
export default app - Add Node.js entry using
@hono/node-serveradapter - Set up environment-specific binding types
Output: A portable API deployable to multiple runtimes with shared route logic.
Guidelines
- Use
new Hono<{ Bindings: Env }>()to type environment bindings on Cloudflare. - Group related routes into separate files and merge with
app.route(). - Apply global middleware with
app.use("*", middleware)and scope auth to protected paths. - Use
@hono/zod-validatorfor all user input; never trust raw request data. - Return proper HTTP status codes: 201 for creation, 204 for deletion, 4xx for client errors.
- Prefer Hono's RPC mode over manual fetch calls for internal service communication.
Information
- Version
- 1.0.0
- Author
- terminal-skills
- Category
- Development
- License
- Apache-2.0