Appearance
Hono Tutorial
Official Documentation
This tutorial is based on the official Hono documentation. For the most up-to-date information, visit: https://hono.dev
Welcome to the comprehensive Hono tutorial! Learn how to build fast, lightweight web applications with Hono - the ultrafast web framework for the Edge.
What is Hono?
Hono (炎 means "flame" in Japanese) is a small, simple, and ultrafast web framework for the Edge. It works on any JavaScript runtime: Cloudflare Workers, Deno, Bun, Vercel, AWS Lambda, Node.js, and more.
typescript
// A simple Hono application
import { Hono } from 'hono'
const app = new Hono()
app.get('/', (c) => c.text('Hello Hono!'))
export default appWhy Hono?
Key Features
| Feature | Description |
|---|---|
| Ultrafast | One of the fastest routers in the JavaScript ecosystem |
| Lightweight | Zero dependencies, small bundle size (~14KB) |
| Multi-runtime | Works on Cloudflare Workers, Deno, Bun, Node.js, and more |
| TypeScript | First-class TypeScript support with type inference |
| Middleware | Rich middleware ecosystem for common tasks |
| Web Standards | Built on Web Standard APIs (Request/Response) |
Performance Comparison
Hono is designed for speed. Here's how it compares:
Hono ████████████████████████████████ 100%
Express ███████████████ 47%
Fastify ██████████████████████████ 81%Runtime Support
Hono runs everywhere:
- Cloudflare Workers - Edge computing
- Deno - Secure runtime
- Bun - Fast all-in-one toolkit
- Node.js - Traditional server
- AWS Lambda - Serverless
- Vercel - Edge Functions
- Netlify - Edge Functions
Tutorial Structure
Beginner
- Getting Started - Installation, first app, basic concepts
- Routing - Routes, parameters, groups, methods
Intermediate
- Middleware - Built-in and custom middleware
- Context API - Request, response, and context helpers
- Validation - Input validation with Zod
Advanced
- Testing - Unit and integration testing
- Deployment - Deploy to various platforms
- Advanced Topics - RPC, streaming, WebSockets, best practices
Quick Example
Here's a taste of what you'll learn:
typescript
import { Hono } from 'hono'
import { cors } from 'hono/cors'
import { logger } from 'hono/logger'
import { validator } from 'hono/validator'
const app = new Hono()
// Middleware
app.use('*', logger())
app.use('/api/*', cors())
// Routes
app.get('/', (c) => {
return c.html('<h1>Welcome to Hono!</h1>')
})
// Route with parameters
app.get('/users/:id', (c) => {
const id = c.req.param('id')
return c.json({ id, name: 'John Doe' })
})
// POST with validation
app.post('/users',
validator('json', (value, c) => {
const { name, email } = value
if (!name || !email) {
return c.json({ error: 'Invalid input' }, 400)
}
return { name, email }
}),
(c) => {
const data = c.req.valid('json')
return c.json({ message: 'User created', data }, 201)
}
)
// Error handling
app.onError((err, c) => {
console.error(err)
return c.json({ error: 'Internal Server Error' }, 500)
})
// 404 handling
app.notFound((c) => {
return c.json({ error: 'Not Found' }, 404)
})
export default appPrerequisites
Before starting this tutorial, you should have:
- Basic knowledge of JavaScript/TypeScript
- Node.js 18+ (or Bun/Deno)
- A code editor (VS Code recommended)
- Basic understanding of HTTP and REST APIs
What You'll Build
Throughout this tutorial, you'll build:
- REST API - A complete CRUD API
- Authentication System - JWT-based auth
- Validated Endpoints - Input validation with Zod
- Edge-ready App - Deploy to Cloudflare Workers
Video Tutorials
Recommended Video Resources
Learn Hono through these excellent video tutorials from the community.
Free Courses
| Course | Creator | Description |
|---|---|---|
| Hono.js Crash Course | Traversy Media | 45-minute crash course |
| Hono Tutorial | Beyond Fireship | Build APIs with Hono |
| Hono + Cloudflare Workers | James Q Quick | Deploy to the Edge |
Official Resources
| Resource | Description |
|---|---|
| Hono Documentation | Official Hono documentation |
| Hono Examples | Official code examples |
Topic-Specific Videos
| Topic | Video | Duration |
|---|---|---|
| Cloudflare Workers | Hono on Workers | ~20 min |
| Authentication | JWT with Hono | ~25 min |
| Zod Validation | Hono + Zod | ~15 min |
Let's begin your Hono journey!