Skip to main content
Back to Browser

Configuration

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

Basic Configuration​

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

ParameterTypeDefaultDescription
session.silentSignIn.beforeRedirectbooleanfalseBefore signIn() redirects, try a silent prompt=none sign-in from the existing ThunderID 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 ThunderID session cookie into that iframe. That requires the app to run on the same site as ThunderID, and the application's authentication flow to maintain an SSO session. See Single Sign-On.

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.

js
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.

js
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.

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

Full Example​

src/auth.js
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,
session: {
silentSignIn: {beforeRedirect: true},
},
})

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.