Next.js App Router
@sudomimus/nextjs provides server route handlers for login, callback, logout, and current-session access.
Wire the handlers
Section titled “Wire the handlers”Create one server-only module with your Connect options and a shared durable WebAuthStore:
import { createNextHandlers } from "@sudomimus/nextjs";
export const { start, callback, logout, current, currentFromCookieHeader,} = createNextHandlers(options);Export those handlers from App Router route files:
export { start as POST } from "@/lib/sudomimus";
// app/auth/callback/route.tsexport { callback as GET } from "@/lib/sudomimus";
// app/api/logout/route.tsexport { logout as POST } from "@/lib/sudomimus";Call current(request) in a Route Handler. In a Server Component, pass the request cookie header to currentFromCookieHeader. Never pass returned tokens into a Client Component.
The POST handlers validate Origin against the callback origin. Keep them as POST endpoints and configure a CALLBACK ReturnRule for the exact callback URL.