Skip to content
>_devvkit
$devvkit learn --librarie hono-guide

Hono Guide

[nodejs][edge][serverless][framework]
JavaScript / TypeScript
Install
npm create hono@latest my-app
npm install hono

Hono means "flame" in Japanese. It's built for edge computing — supporting Cloudflare Workers, Deno, Bun, Vercel Edge, AWS Lambda, and Node.js from the same codebase. No dependencies, zero runtime overhead.

The router (TrieRouter or SmartRouter) is the fastest JS router — matching routes in O(n) with no regex overhead. Middleware ecosystem includes auth, CORS, JWT, compression, GraphQL, and JSX.

Hono's RPC mode gives you tRPC-like type safety. Define a route on the server and call it from the client with full TypeScript inference, no code generation.

Setup

Basic appHono server.
import { Hono } from 'hono'

const app = new Hono()

app.get('/', (c) => c.text('Hello Hono!'))

export default app
// npx wrangler dev  # Cloudflare Workers
// deno run --allow-net app.ts  # Deno

Routing

Route paramsURL parameters.
app.get('/users/:id', (c) => {
  const id = c.req.param('id')
  return c.json({ id })
})
Query paramsQuery string.
app.get('/search', (c) => {
  const q = c.req.query('q')
  return c.json({ query: q })
})

Middleware

MiddlewareReusable handlers.
import { cors, logger } from 'hono/middleware'

app.use('*', cors())
app.use('*', logger())

// Custom middleware
app.use('/api/*', async (c, next) => {
  const token = c.req.header('Authorization')
  if (!token) return c.json({ error: 'Unauthorized' }, 401)
  await next()
})
JSX middlewareServer-side rendering.
import { jsxRenderer } from 'hono/jsx-renderer'

app.get('*', jsxRenderer(({ children }) => {
  return <html><body>{children}</body></html>
}))

app.get('/', (c) => c.render(<h1>Hello</h1>))

RPC

Hono RPCType-safe client.
// server.ts
import { z } from 'zod'
import { zValidator } from '@hono/zod-validator'

const route = app.get('/users/:id',(c) => c.json({ id: c.req.param('id'), name: 'Alice' }))
export type AppType = typeof route

// client.ts
import { hc } from 'hono/client'
import type { AppType } from './server'
const client = hc<AppType>('http://localhost:3000')
const res = await client.users[':id'].({ param: { id: '1' } })

Deployment

Deploy to CloudflareWrangler deployment.
npx wrangler deploy
# wrangler.toml:
# main = "src/index.ts"
# compatibility_date = "2025-04-01"