advanced.ipAddress configuration
advanced.ipAddress configuration includes: ipAddressHeaders (trusted header names to read client IP addresses from); disableIpTracking (disable IP address tracking); trustedProxies (reverse-proxy IPs or CIDR ranges, forwarded chain walked right to left with trusted hops skipped and first untrusted address used as client IP).
advanced.database configuration
advanced.database configuration includes: generateId (controls how record IDs are generated, accepts custom function, false, "serial", or "uuid", default is random base62 string); defaultFindManyLimit (default maximum records returned by findMany adapter method, default: 100); joins (enable database joins for adapters that support them, when disabled related data fetched via separate queries, default: false).
advanced.cookies configuration
advanced.cookies allows customizing cookie names and attributes. Each cookie can have a name and attributes object with httpOnly and secure properties. Example: session_token with custom name and attributes.
advanced.defaultCookieAttributes configuration
advanced.defaultCookieAttributes specifies default attributes applied to all cookies, with properties like httpOnly and secure.
advanced.crossSubDomainCookies configuration
advanced.crossSubDomainCookies configuration includes: enabled (enable sharing cookies across subdomains); additionalCookies (additional cookies to share); domain (explicit domain for cookies).
advanced.useSecureCookies option
advanced.useSecureCookies forces the Secure cookie attribute in all environments. By default, cookies are secure in production environments. Set to true to force Secure in all environments.
advanced.disableCSRFCheck option
advanced.disableCSRFCheck disables all CSRF protection including origin header validation and Fetch Metadata checks. This is a security risk and not recommended.
advanced.disableOriginCheck option
advanced.disableOriginCheck disables URL validation for callbackURL, redirectTo, and other redirect URLs. This is a security risk and not recommended.
advanced.cookiePrefix option
advanced.cookiePrefix specifies a prefix for cookies, allowing customization of cookie naming for multi-tenant or multi-app deployments.
advanced.skipTrailingSlashes option
advanced.skipTrailingSlashes skips trailing slash validation in route matching. Default: false.
advanced.backgroundTasks configuration
advanced.backgroundTasks configures background task handling for deferred operations. Background tasks allow non-critical operations like cleanup, analytics, timing-attack mitigation, or rate limit counter updates to run after response is sent. This can improve response times on serverless platforms. Configure with a handler that accepts a promise, such as waitUntil from @vercel/functions on Vercel or cloudflare:workers on Cloudflare Workers. This introduces eventual consistency where response returns optimistic data before database is updated.
logger configuration options
logger configuration includes: disabled (disable all logging when true, default: false); disableColors (disable colors in default logger, default: determined by terminal color support); level (minimum log level to display: "debug" shows all logs including debug, "info" shows all except debug, "warn" shows warnings and errors, "error" shows only errors, default: "warn"); log (custom logging function receiving level, message, and additional args).
databaseHooks configuration
databaseHooks provide database lifecycle hooks for core operations. Hooks are available for user, session, account, and verification with before and after callbacks for create and update operations. before callbacks can modify data before operation, after callbacks perform actions after operation.
onAPIError configuration
onAPIError configuration includes: throw (throw error on API error, default: false); onError (custom error handler receiving error and ctx); errorURL (URL to redirect to on error, default: /api/auth/error); customizeDefaultErrorPage (configure default error page with colors, size, font, and display options).
onAPIError customizeDefaultErrorPage colors
onAPIError customizeDefaultErrorPage colors configuration: background, foreground, primary, primaryForeground, mutedForeground, border, destructive, titleBorder, titleColor, gridColor, cardBackground, cornerBorder.
onAPIError customizeDefaultErrorPage size
onAPIError customizeDefaultErrorPage size configuration: radiusSm (small border radius), radiusMd (medium border radius), radiusLg (large border radius), textSm (small text size), text2xl (2xl text size), text4xl (4xl text size), text6xl (6xl text size).
onAPIError customizeDefaultErrorPage font
onAPIError customizeDefaultErrorPage font configuration: defaultFamily (default font family, default: system-ui, sans-serif), monoFamily (monospace font family).
onAPIError customizeDefaultErrorPage display options
onAPIError customizeDefaultErrorPage display options: disableTitleBorder (disable border around title, default: false), disableCornerDecorations (disable corner decorations, default: false), disableBackgroundGrid (disable background grid pattern, default: false).
hooks request lifecycle configuration
hooks configuration provides request lifecycle hooks with before and after hooks. before hook executes before processing the request, after hook executes after processing the request. Hooks are created using createAuthMiddleware from better-auth/api and receive ctx with request path and context properties.