Skip to main content

Configuration

The initialize() method accepts a configuration object that controls how the SDK connects to your ThunderID instance and manages authentication.

Basic Configuration​

import { ThunderIDBrowserClient } from '@thunderid/browser'

const auth = new ThunderIDBrowserClient()

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

Configuration Reference​

Required Parameters​

ParameterTypeDescription
clientIdstringThe Client ID from your ThunderID application
baseUrlstringYour ThunderID instance URL (e.g., https://localhost:8090)

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 Management Parameters​

ParameterTypeDefaultDescription
syncSessionbooleanfalseEnable OIDC Session Management via RP iframe. Requires same-domain or third-party cookies
checkSessionIntervalnumber3Interval in seconds between session-check polls
sessionRefreshIntervalnumber300Interval in seconds for silent token refresh
periodicTokenRefreshbooleanfalseAutomatically refresh tokens before expiry
autoLogoutOnTokenRefreshErrorbooleanfalseSign the user out when a token refresh fails

Advanced Parameters​

ParameterTypeDefaultDescription
applicationIdstring-UUID of the ThunderID 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://localhost:8090',
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://localhost:8090',
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://localhost:8090',
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://localhost:8090',
afterSignInUrl: 'http://localhost:5173',
afterSignOutUrl: 'http://localhost:5173',
scopes: ['openid', 'profile', 'email'],
storage: 'sessionStorage',
periodicTokenRefresh: true,
sessionRefreshInterval: 300,
})

export default auth

Explore with AI

ThunderID LogoThunderID Logo

Product

DocsAPIsSDKs
© Copyright Linux Foundation Europe.For web site terms of use, trademark policy and other project policies please see https://linuxfoundation.eu/en/policies.