24 · Integrations
Auth.js (NextAuth) under WebApp
Mount Auth.js's universal handler under a wildcard. c.req.raw is the underlying Request; Auth.js handles cookies, sessions, OAuth callbacks.
Code
hono-authjs.js
const { WebApp } = require(class="tk-str">39;@hyperbridge/forge/server39;); const { Auth } = require(class="tk-str">39;@auth/core39;); const GitHub = require(class="tk-str">39;@auth/core/providers/github39;).default; const app = new WebApp(); app.all(class="tk-str">39;/auth/*39;, (c) => Auth(c.req.raw, { secret: process.env.AUTH_SECRET, providers: [GitHub({ clientId: process.env.GITHUB_ID, clientSecret: process.env.GITHUB_SECRET, })], })); app.listen(3000);
How it works
Auth.js's Auth() function takes a standard Fetch Request and returns a Response — perfect match for c.req.raw.
All Auth.js providers (50+) work unchanged: GitHub, Google, Apple, Discord, Auth0, Okta, custom OAuth2/OIDC, magic links, credentials.
Add middleware before the catch-all for rate limiting, IP allow-listing, or per-route session checks.
Try it
Quickstart
open http://localhost:3000/auth/signin/github
Related modules
This is HBForge's port of Hono's example. Read the original at hono.dev/examples/hono-authjs.