JWT Middleware #

There is also middleware for JWT Authentication.

Note: On Bun, JWT Middleware is not supported, yet. DO NOT USE this on Bun.

Import #

import { Hono } from 'hono'
import { jwt } from 'hono/jwt'
import { Hono } from 'https://deno.land/x/hono/mod.ts'
import { jwt } from 'https://deno.land/x/hono/middleware.ts'

Usage #

const app = new Hono()

app.use(
  '/auth/*',
  jwt({
    secret: 'it-is-very-secret'
  })
)

app.get('/auth/page', (c) => {
  return c.text('You are authorized')
})
https://github.com/honojs/hono
© Hono developers.
Built with Hugo & Hugo Book Theme - Not Hono :)