@bolkauth/nextjs provides the App Router route handler, middleware, and server helpers.
Route Handler
Create app/api/auth/[...bolkauth]/route.ts:
The handler forwards all supported /api/auth/* requests to @bolkauth/core.
Server Helpers
Create helpers once near your auth config:
Use them in Server Components:
Helper Behavior
| Helper | Returns | Use it when |
|---|---|---|
getSession() | { id, userId, token } | null | You only need the session payload. |
getUser() | User | null | You need the database user and can handle anonymous access. |
requireAuth(signInUrl?) | User | The page or action must be authenticated. |
Recommended File Layout
lib/auth.ts should export the auth engine. lib/auth-server.ts can export createServerHelpers(auth) so pages and actions import helpers from one place.