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 initialize() method accepts a configuration object that controls how the SDK connects to your Choreo Identity & Access Management instance and manages authentication.

Basic Configuration​

import { ThunderIDBrowserClient } from '@thunderid/browser'

const auth = new ThunderIDBrowserClient()

await auth.initialize({
clientId: '<your-client-id>',
baseUrl: 'https://<DATA_PLANE_URL>',
})

Configuration Reference​

Required Parameters​

ParameterTypeDescription
clientIdstringThe Client ID from your Choreo Identity & Access Management application
baseUrlstringYour Choreo Identity & Access Management instance URL (e.g., https://<DATA_PLANE_URL>)

Authentication Parameters​

ParameterTypeDefaultDescription
afterSignInUrlstringwindow.location.originURL to redirect to after sign-in
afterSignOutUrlstringwindow.location.originURL to redirect to after sign-out
scopesstring[]['openid', 'profile']OAuth 2.0 scopes to request
enablePKCEbooleantrueEnable PKCE for the authorization request
promptstring-Controls the authentication UI behavior (e.g., "login", "none", "consent")
responseModestring'query'OAuth 2.0 response mode for the authorization request
sendCookiesInRequestsbooleantrueInclude cookies in token requests
sendIdTokenInLogoutRequestboolean-Include the ID token hint in the logout request

Storage Parameters​

ParameterTypeDefaultDescription
storagestring'sessionStorage'Storage backend: 'sessionStorage', 'localStorage', or 'browserMemory'

Session Parameters​

ParameterTypeDefaultDescription
session.silentSignIn.beforeRedirectbooleanfalseBefore signIn() redirects, try a silent prompt=none sign-in from the existing Choreo Identity & Access Management session. When the session exists, the user is signed in without leaving the app. Otherwise the redirect continues. Skipped when the sign-in options set their own prompt
session.silentSignIn.timeoutnumber10000How long, in milliseconds, a silent sign-in waits for a response before treating the user as signed out. Also applies to signInSilently()
periodicTokenRefreshbooleanfalseAutomatically refresh tokens before expiry
autoLogoutOnTokenRefreshErrorbooleanfalseSign the user out when a token refresh fails

Silent sign-in loads the authorization endpoint in a hidden iframe, so it can only find the session when the browser sends the Choreo Identity & Access Management session cookie into that iframe. That requires the app to run on the same site as Choreo Identity & Access Management, and the application's authentication flow to maintain an SSO session. See Single Sign-On.

Advanced Parameters​

ParameterTypeDefaultDescription
applicationIdstring-UUID of the Choreo Identity & Access Management application. Used for Application Branding and sign-up flow access URLs
allowedExternalUrlsstring[]-URL prefixes that the SDK may attach access tokens to when making HTTP requests
authParamsRecord<string, string>-Additional query parameters to append to every authorize request

Storage Backends​

The SDK supports three storage backends for persisting session data. Choose one based on your security and UX requirements.

Session Storage (Default)​

Data persists for the browser tab lifetime. Each tab maintains an independent session.

await auth.initialize({
clientId: '<your-client-id>',
baseUrl: 'https://<DATA_PLANE_URL>',
storage: 'sessionStorage',
})

Local Storage​

Data persists across tabs and browser restarts. Use when you want sessions to survive page reloads and new tabs.

await auth.initialize({
clientId: '<your-client-id>',
baseUrl: 'https://<DATA_PLANE_URL>',
storage: 'localStorage',
})

Browser Memory​

Data exists only in memory and is lost on page reload. Use for the highest security requirements where no data should persist to disk.

await auth.initialize({
clientId: '<your-client-id>',
baseUrl: 'https://<DATA_PLANE_URL>',
storage: 'browserMemory',
})

Full Example​

src/auth.js
import { ThunderIDBrowserClient } from '@thunderid/browser'

const auth = new ThunderIDBrowserClient()

await auth.initialize({
clientId: '<your-client-id>',
baseUrl: 'https://<DATA_PLANE_URL>',
afterSignInUrl: 'http://localhost:5173',
afterSignOutUrl: 'http://localhost:5173',
scopes: ['openid', 'profile', 'email'],
storage: 'sessionStorage',
periodicTokenRefresh: true,
session: {
silentSignIn: {beforeRedirect: true},
},
})

export default auth

Was this page helpful?