Skip to main content
Server TypeScript types used in logto-authkit server-side authentication and middleware.

Authentication Types

AuthPayload

JWT payload structure returned after token verification.
string
required
Subject - the user ID from Logto
string
required
OAuth scopes granted to the token
any
Additional claims from the JWT token

AuthContext

Authentication context attached to requests after verification.
string | null
required
The authenticated user ID, or null if not authenticated
boolean
required
Whether the request has a valid authentication token
AuthPayload | null
required
The full JWT payload if authenticated, otherwise null
boolean
Whether the request is from a guest user (when allowGuest is enabled)
string
The guest user ID (when in guest mode)

VerifyAuthOptions

Configuration options for token verification.
string
required
The Logto tenant URL (e.g., https://your-tenant.logto.app)
string
required
The API resource identifier configured in Logto
Name of the cookie containing the JWT token
string
Required OAuth scope for authorization (e.g., "read:users")
boolean
default:false
Allow unauthenticated guest users with guest IDs

Express Types

ExpressRequest

Extended Express request interface with authentication context.
{ [key: string]: string }
Parsed cookies from the request
{ [key: string]: string | string[] | undefined }
required
HTTP headers from the request
AuthContext
Authentication context added by the middleware

ExpressResponse

Express response interface for middleware.
(code: number) => ExpressResponse
required
Set HTTP status code
(obj: any) => ExpressResponse
required
Send JSON response

ExpressNext

Express next function type.

Next.js Types

NextRequest

Next.js request interface for route handlers and middleware.
{ get: (name: string) => { value: string } | undefined }
required
Cookie accessor for Next.js requests
{ get: (name: string) => string | null }
required
Header accessor for Next.js requests

NextResponse

Next.js response interface for route handlers.
(body: any, init?: { status?: number }) => NextResponse
required
Send JSON response with optional status code

Usage Examples

Express Middleware

Next.js Route Handler

Guest Mode