Documentation Index
Fetch the complete documentation index at: https://docs.ouim.me/llms.txt
Use this file to discover all available pages before exploring further.
Overview
TheverifyNextAuth function is designed specifically for Next.js App Router, providing authentication verification for middleware and API routes with Next.js-specific request handling.
Signature
Parameters
Next.js request object from middleware or API routes
Configuration options for token verification
Returns
Promise that resolves to a result object indicating success or failureSuccess Response:Failure Response:
AuthContext Properties
Examples
Middleware Protection
API Route Protection
With Guest Support
Middleware with Guest Support
Role-Based Access Control
Custom Error Handling
Extracting User Info in Server Component
Token Extraction Order
The function extracts tokens in this order:- Cookie (using
cookieNameoption, defaults tologto_authtoken) - Authorization header (Bearer token)
Response Patterns
Authenticated User
Guest User (when allowGuest: true)
Failed Authentication (when allowGuest: false)
See Also
- verifyAuth - Generic verification function
- createExpressAuthMiddleware - Express.js middleware
- useAuth - React hook for client-side authentication