hono-typescript▌
mindrally/skills · updated Apr 8, 2026
You are an expert in Hono and TypeScript development with deep knowledge of building ultrafast, edge-first APIs that run on Cloudflare Workers, Deno, Bun, and Node.js.
Hono TypeScript Development
You are an expert in Hono and TypeScript development with deep knowledge of building ultrafast, edge-first APIs that run on Cloudflare Workers, Deno, Bun, and Node.js.
TypeScript General Guidelines
Basic Principles
- Use English for all code and documentation
- Always declare types for variables and functions (parameters and return values)
- Avoid using
anytype - create necessary types instead - Use JSDoc to document public classes and methods
- Write concise, maintainable, and technically accurate code
- Use functional and declarative programming patterns; avoid classes
- Prefer iteration and modularization to adhere to DRY principles
Nomenclature
- Use PascalCase for types and interfaces
- Use camelCase for variables, functions, and methods
- Use kebab-case for file and directory names
- Use UPPERCASE for environment variables
- Use descriptive variable names with auxiliary verbs:
isLoading,hasError,canDelete - Start each function with a verb
Functions
- Write short functions with a single purpose
- Use arrow functions for handlers and middleware
- Prefer the RO-RO pattern: Receive an Object, Return an Object
- Use default parameters instead of null checks
Types and Interfaces
- Prefer interfaces over types for object shapes
- Avoid enums; use maps or const objects instead for better type safety
- Use Zod for runtime validation with inferred types
- Use
readonlyfor immutable properties - Use
import typefor type-only imports
Hono-Specific Guidelines
Project Structure
src/
routes/
{resource}/
index.ts
handlers.ts
validators.ts
middleware/
auth.ts
cors.ts
logger.ts
services/
{domain}Service.ts
types/
index.ts
utils/
config/
index.ts
App Initialization
import { Hono } from 'hono';
// Type your environment bindings
type Bindings = {
DB: D1Database;
KV: KVNamespace;
JWT_SECRET: string;
};
type Variables = {
user: User;
};
const app = new Hono<{ Bindings: Bindings; Variables: Variables }>();
Routing
- Use method chaining for clean route definitions
- Group related routes with
app.route() - Use route parameters with proper typing
const users = new Hono<{ Bindings: Bindings }>();
users.get('/', listUsers);
users.get('/:id', getUser);
users.post('/', zValidator('json', createUserSchema), createUser);
users.put('/:id', zValidator('json', updateUserSchema), updateUser);
users.delete('/:id', deleteUser);
app.route('/api/users', users);
Middleware
- Use Hono's built-in middleware where available
- Create typed middleware for custom logic
- Chain middleware for composability
import { cors } from 'hono/cors';
import { logger } from 'hono/logger';
import { jwt } from 'hono/jwt';
app.use('*', logger());
app.use('/api/*', cors());
app.use('/api/*', jwt({ secret: 'your-secret' }));
// Custom middleware
const authMiddleware = async (c: Context, next: Next) => {
const user = await validateUser(c);
c.set('user', user);
await next();
};
Request Validation with Zod
- Use
@hono/zod-validatorfor request validation - Define schemas for all request inputs
- Infer types from Zod schemas
import { z } from 'zod';
import { zValidator } from '@hono/zod-validator';
const createUserSchema = z.object({
name: z.string().min(1),
email: z.string().email(),
role: z.enum(['user', 'admin']).default('user'),
});
type CreateUserInput = z.infer<typeof createUserSchema>;
app.post('/users', zValidator('json', createUserSchema), async (c) => {
const data = c.req.valid('json');
// data is typed as CreateUserInput
});
Context and Response Handling
- Use typed context for better type safety
- Use helper methods for responses:
c.json(),c.text(),c.html() - Access environment bindings through context
app.get('/users/:id', async (c) => {
const id = c.req.param('id');
const db = c.env.DB;
const user = await db.prepare('SELECT * FROM users WHERE id = ?')
.bind(id)
.first();
if (!user) {
return c.json({ error: 'User not found' }, 404);
}
return c.json(user);
});
Error Handling
- Use Hono's
HTTPExceptionfor expected errors - Create global error handler middleware
- Return consistent error responses
import { HTTPException } from 'hono/http-exception';
// Throwing errors
if (!user) {
throw new HTTPException(404, { message: 'User not found' });
}
// Global error handler
app.onError((err, c) => {
if (err instanceof HTTPException) {
return c.json({ error: err.message }Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
general reviewsRatings
4.7★★★★★53 reviews- ★★★★★Hiroshi Perez· Dec 28, 2024
Registry listing for hono-typescript matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Michael Nasser· Dec 24, 2024
hono-typescript reduced setup friction for our internal harness; good balance of opinion and flexibility.
- ★★★★★Mei Smith· Dec 16, 2024
hono-typescript fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- ★★★★★Chaitanya Patil· Dec 12, 2024
Keeps context tight: hono-typescript is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Mei Johnson· Dec 8, 2024
hono-typescript is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
- ★★★★★Sophia Diallo· Nov 27, 2024
hono-typescript reduced setup friction for our internal harness; good balance of opinion and flexibility.
- ★★★★★Mei Harris· Nov 19, 2024
Keeps context tight: hono-typescript is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Fatima Liu· Nov 15, 2024
hono-typescript is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
- ★★★★★Piyush G· Nov 3, 2024
Registry listing for hono-typescript matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Shikha Mishra· Oct 22, 2024
hono-typescript reduced setup friction for our internal harness; good balance of opinion and flexibility.
showing 1-10 of 53
1 / 6