Skip to content
Back to skills

Using Hono

ASecurity

Use when building or editing a Hono 4.0+ HTTP API in TypeScript. Triggers on `.ts` files with `hono` or `@hono/*` imports, route handlers, middleware, request validation, error handling, WebSockets, or CORS, even when the user doesn't say 'Hono'.

  • 6 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 30, 2026
ai-agentstypescriptgonodeapisecurity

Works with

  • api

Security analysis

A100/100

Pro scans all 15 files and shows the line behind each finding

Scanned November 30, 2026

npx -y skills add xonovex/platform --skill using-hono --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Using Hono?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Using Hono
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/xonovex-using-hono/badge)](https://www.skillsdirectory.com/skills/xonovex-using-hono)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: using-hono
description: "Use when building or editing a Hono 4.0+ HTTP API in TypeScript. Triggers on `.ts` files with `hono` or `@hono/*` imports, route handlers, middleware, request validation, error handling, WebSockets, or CORS, even when the user doesn't say 'Hono'."
---

# Hono Coding Guidelines

Build typed Hono APIs with explicit validation, middleware order, and error responses.

## Requirements

- Hono ≥ 4.0, @hono/node-server, @hono/zod-validator, TypeScript ≥ 5.8

## Essentials

- **Factory functions** - Use for testability and domain organization, see [references/application-structure.md](references/application-structure.md)
- **Type-safe validation** - Recover types at the `c.req.valid` boundary; schema design in **using-zod**, see [references/validation-type-safety.md](references/validation-type-safety.md)
- **Middleware configuration** - Use factories for CORS, composition with `some()`/`every()`/`except()`, see [references/middleware-patterns.md](references/middleware-patterns.md), [references/middleware-combine.md](references/middleware-combine.md)
- **WebSocket helpers** - Keep object references to maintain `this` binding, see [references/websocket-support.md](references/websocket-support.md)
- **Error responses** - Use RFC 9457 Problem Details with `application/problem+json`, see [references/error-handling.md](references/error-handling.md)
- **Security middleware** - Apply `secureHeaders()` for security headers, see [references/security-middleware.md](references/security-middleware.md)
- **Cookie handling** - Set secure options explicitly, use signed cookies, see [references/cookie-handling.md](references/cookie-handling.md)
- **Platform portability** - Use `env(c)` for environment, `getRuntimeKey()` for detection, see [references/platform-runtime.md](references/platform-runtime.md)

## Example

```typescript
import {Hono} from "hono";
import {secureHeaders} from "hono/secure-headers";

export function createApp() {
  const app = new Hono();
  app.use("*", secureHeaders());
  app.route("/api/v1", v1Router);
  return app;
}
```

## Gotchas

- `c.req.valid('json')` is typed by inference only when `zValidator` is chained inline on the route; an imported base-`Context` controller sees `any`, so cast there, but that cast is unchecked and can hide schema drift
- Middleware runs in the order it's registered: auth before routes, error handlers last; ordering bugs cause silent 200s on protected routes
- `env(c)` is the portable way to read env vars across runtimes: `process.env` works on Node but not Workers/Deno
- WebSocket helpers capture `this` from the closing object: assigning the handler to a variable loses the binding

## Progressive disclosure

- Read [references/application-structure.md](references/application-structure.md) - Load when organizing a new Hono application
- Read [references/validation-type-safety.md](references/validation-type-safety.md) - Load when losing type safety after validation
- Read [references/middleware-patterns.md](references/middleware-patterns.md) - Load when creating reusable middleware or configuring CORS
- Read [references/websocket-support.md](references/websocket-support.md) - Load when implementing WebSocket endpoints
- Read [references/error-handling.md](references/error-handling.md) - Load when standardizing error responses across routes
- Read [references/security-middleware.md](references/security-middleware.md) - Load when configuring auth, CSRF, or security headers
- Read [references/cookie-handling.md](references/cookie-handling.md) - Load when managing sessions or sensitive cookies
- Read [references/context-storage.md](references/context-storage.md) - Load when accessing Context outside handlers
- Read [references/middleware-combine.md](references/middleware-combine.md) - Load when composing complex middleware logic
- Read [references/platform-runtime.md](references/platform-runtime.md) - Load when deploying across multiple runtimes

Files in this skill

  • SKILL.md3.9 KB
  • eval-output.json2.6 KB
  • eval-trigger.json5.4 KB
  • moon.yml86 B
  • references/application-structure.md657 B
  • references/context-storage.md680 B
  • references/cookie-handling.md941 B
  • references/error-handling.md1.3 KB
  • references/middleware-combine.md900 B
  • references/middleware-patterns.md948 B
  • references/platform-runtime.md763 B
  • references/security-middleware.md837 B
  • references/validation-type-safety.md2.2 KB
  • references/websocket-support.md1 KB
  • sources.json3.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.