Configuration
The Server SDK provides configuration options for customizing authentication behavior, cookie settings, and token refresh routes.CrossmintAuthServerOptions
Configuration object passed toCrossmintAuth.from().
refreshRoute
Custom route for token refresh. When set, the SDK uses your custom endpoint instead of the default Crossmint refresh endpoint.
null (uses Crossmint’s default refresh endpoint)
Example
- Accept POST requests with a refresh token
- Call the Crossmint refresh endpoint or handle token refresh
- Return refreshed authentication material
cookieOptions
Configuration for authentication cookies. Controls security, expiration, and domain settings.
{} (uses secure defaults)
CookieOptions
Configuration for HTTP cookies used to store authentication tokens.expiresAt
ISO 8601 timestamp for cookie expiration. If not provided, uses the refresh token’s expiration time.
httpOnly
When
true, prevents JavaScript access to cookies. Recommended for security.true (recommended)
Example:
secure
When
true, cookies are only sent over HTTPS connections.false
Example:
Always set
secure: true in production environments. Set to false only for local development over HTTP.sameSite
Controls when cookies are sent with cross-site requests.
Lax: Cookies sent with top-level navigation and same-site requests (recommended)Strict: Cookies only sent with same-site requestsNone: Cookies sent with all requests (requiressecure: true)
Lax
Example:
domain
Domain for which the cookie is valid. Allows cookies to be shared across subdomains.
Include the leading dot (
.example.com) to make cookies available to all subdomains.Complete configuration example
Production configuration
Development configuration
Minimal configuration
Cookie names
The SDK stores authentication material in the following cookies:crossmint_jwt- JWT access tokencrossmint_refresh_token- Refresh token
Security best practices
Always use httpOnly cookies
Always use httpOnly cookies
Enable secure in production
Enable secure in production
Set
secure: true in production to ensure cookies are only sent over HTTPS.Use appropriate sameSite setting
Use appropriate sameSite setting
Use
sameSite: 'Lax' for most applications, or sameSite: 'Strict' for maximum security.Limit cookie domain scope
Limit cookie domain scope
Runtime compatibility
The Server SDK works with both Node.js and Web API environments:- Node.js: Express, Fastify, Next.js API routes (Pages Router)
- Web API: Next.js App Router, Vercel Edge Functions, Cloudflare Workers