@aura-stack/hono
v0.1.0
Published
Authentication integration for Hono applications. Provides middleware, route handlers and session verification powered by Aura Auth.
Maintainers
Readme
Hono middleware and utilities for the Aura Stack authentication library
Official Docs · Hono Package Docs
Overview
@aura-stack/hono provides a seamless integration layer for Hono applications using Aura Auth. It allows you to easily mount authentication handlers and protect your routes using type-safe middlewares that run anywhere (Cloudflare Workers, Deno, Bun, Node.js).
It leverages Hono's Context to provide session management and authentication flows with first-class TypeScript support.
Features
- Hono Middleware — Standard
withAuthmiddleware that keeps your handlers clean. - Environment Agnostic — Works on any runtime supported by Hono.
- Type-safe Context — Access the session directly via
c.get('session')with full type safety. - Unified Handlers — Bridge Web Request/Response API handlers to Hono seamlessly.
- Native OAuth Support — Optimized for Hono's internal routing and request handling.
Installation
pnpm add @aura-stack/hono @aura-stack/authQuick Start
1. Configure Auth
Create your authentication instance. This typically goes in a shared file like lib/auth.ts.
import { createAuth } from "@aura-stack/hono"
export const auth = createAuth({
oauth: ["github"],
// your configuration
})
export const { toHandler, withAuth } = auth2. Mount Auth Endpoints
Mount the authentication endpoints using Hono.all().
import { Hono } from "hono"
import { toHandler } from "./lib/auth"
const app = new Hono()
// All Aura Auth routes (sign-in, sign-out, session, etc.)
app.all("/api/auth/*", toHandler)3. Protect Your Routes
Use the withAuth middleware to protect routes. The session will be available in the Hono context.
import { withAuth } from "./lib/auth"
app.get("/api/protected", withAuth, (c) => {
const session = c.get("session")
if (!session) {
return c.json({ error: "Unauthorized" }, 401)
}
return c.json({ message: `Hello, ${session.user.name}!` })
})Documentation
Visit the official documentation website for more detailed guides and API references.
License
Licensed under the MIT License. © Aura Stack
