Authentication
BolkAuth uses an HttpOnly JWT cookie plus a database session record. The JWT contains the session ID and user ID; the adapter stores the backing session.
Session Cookie
The default cookie name is:
Override it with:
Sign Out
POST /api/auth/sign-out
This deletes the database session if a valid cookie is present and clears the cookie in the browser.
Read Current Session
GET /api/auth/session
Authenticated response:
Client Hooks
Server Helpers
| Helper | Behavior |
|---|---|
getSession() | Verifies the cookie and returns { id, userId, token } or null. |
getUser() | Reads the session and fetches the user through the adapter. |
requireAuth(signInUrl?) | Returns the user or redirects to the sign-in URL. |
Cross-Tab Refresh
The React provider listens for BroadcastChannel messages and reloads session state after sign-in, sign-up, and OTP verification.