Skip to main content

Configuration

Cloud has the newest features. Some may not be in a release yet; the newest release is Identity & Access Management 7.3.0.

The Choreo Identity & Access Management Next.js SDK reads configuration primarily from environment variables. This keeps secrets out of your source code and follows Next.js conventions.

Environment Variables​

Create a .env file in your project root:

.env
NEXT_PUBLIC_THUNDERID_BASE_URL=https://<DATA_PLANE_URL>
NEXT_PUBLIC_THUNDERID_CLIENT_ID=<your-client-id>
THUNDERID_CLIENT_SECRET=<your-client-secret>
THUNDERID_SECRET=<a-random-secret-for-session-signing>

Required Variables​

VariableDescription
NEXT_PUBLIC_THUNDERID_BASE_URLYour Choreo Identity & Access Management instance URL. The NEXT_PUBLIC_ prefix makes this available to client components
NEXT_PUBLIC_THUNDERID_CLIENT_IDThe Client ID from your Choreo Identity & Access Management application
THUNDERID_CLIENT_SECRETThe Client Secret from your Choreo Identity & Access Management application. Server-side only, never exposed to the browser
THUNDERID_SECRETA random string (at least 32 characters) used to sign session cookies with HMAC-SHA256. Required in production; a development fallback is used when not set

Optional Variables​

VariableDefaultDescription
THUNDERID_SESSION_COOKIE_EXPIRY_TIME86400Session cookie lifetime in seconds (24 hours by default)

Session Cookies​

The SDK stores authentication state in signed, HttpOnly cookies:

CookiePurposeLifetime
Session cookieStores access token, refresh token, user ID, scopes, the sid of the ID token and the sign-in timeConfigured via THUNDERID_SESSION_COOKIE_EXPIRY_TIME
Temporary session cookieHolds state during the OAuth flow15 minutes
SettingValueDescription
httpOnlytruePrevents client-side JavaScript access
securetrue (production)Requires HTTPS in production
sameSitelaxProtects against CSRF while allowing navigation
path/Available to all routes

Application Configuration​

Beyond environment variables, you can pass additional configuration to the ThunderIDProvider:

app/layout.tsx
import { ThunderIDProvider } from '@thunderid/nextjs/server'

export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body>
<ThunderIDProvider sessionCookieExpiryTime={3600}>
{children}
</ThunderIDProvider>
</body>
</html>
)
}

Key Differences from the React SDK​

AspectReact SDKNext.js SDK
Token storageBrowser storage (sessionStorage, localStorage)HttpOnly cookies (server-managed)
Client typePublic client (no secret)Confidential client (with secret)
PKCERequiredNot required (confidential client)
Token refreshClient-initiatedAutomatic in middleware
ConfigurationProps on ThunderIDProviderEnvironment variables

Was this page helpful?