Overview
Thethepopebot/auth export provides NextAuth v5 route handlers and session utilities.
Import
Exports
Route Handlers
NextAuth GET route handler for
[...nextauth] catch-all routeNextAuth POST route handler for
[...nextauth] catch-all routeapp/api/auth/[...nextauth]/route.js:
Session Utilities
Get current session. Returns session object or
null if not authenticated.Get auth state and setup status in one call. Returns
{ session, needsSetup }.Implementation
The auth module re-exports fromlib/auth/config.js, which configures NextAuth with:
- Credentials provider - Email/password authentication
- JWT strategy - Session stored in httpOnly cookie
- Database integration - User lookup via
lib/db/users.js - Password hashing - bcrypt with timing-safe comparison
First User Setup
getPageAuthState() checks if any users exist in the database:
Environment Variables
Secret key for JWT encryption. Generate with
openssl rand -base64 32.Related
- thepopebot/auth/actions - Server actions for login/logout
- thepopebot/auth/components - React components for auth UI
- thepopebot/middleware - NextAuth middleware for route protection