Hono

Add authentication to your Hono app with Clowk

Install

pnpm add @clowk/hono @clowk/core

Configure

src/index.ts
import { Hono } from 'hono'
import { clowkMiddleware, requireAuth } from '@clowk/hono'

const app = new Hono()

Protect all routes

Apply the middleware globally. The decoded JWT is available via c.get('auth'):

app.use(clowkMiddleware({
  secretKey: process.env.CLOWK_SECRET_KEY,
}))

app.get('/me', (c) => {
  const auth = c.get('auth')

  return c.json({ user: auth })
})

export default app

Protect specific routes

Use requireAuth() to gate routes — returns 401 if no valid token:

app.get('/public', (c) => {
  return c.json({ message: 'This is public' })
})

app.get('/dashboard', requireAuth(), (c) => {
  const auth = c.get('auth')

  return c.json({ user: auth })
})

Runtimes

Hono + Clowk works on every runtime. @clowk/core uses native fetch and Web Crypto APIs — no Node.js-specific dependencies.

RuntimeDeploy target
Cloudflare Workerswrangler deploy
Bunbun run src/index.ts
Denodeno run src/index.ts
Node.jsnode src/index.ts

Next steps

On this page