Skip to main content

`<ThunderIDProvider />`

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

The ThunderIDProvider is a React Server Component that initializes Choreo Identity & Access Management authentication and wraps your application layout. It manages server-side session state and provides authentication context to all child components.

Usage​

Import ThunderIDProvider from @thunderid/nextjs/server and wrap your root layout:

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

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

Import from @thunderid/nextjs/server, not from @thunderid/nextjs. The provider is a Server Component that reads session cookies and initializes auth state on the server.

Props​

PropTypeDefaultDescription
childrenReactNode-Required. Your application tree
sessionCookieExpiryTimenumber86400Session cookie lifetime in seconds. Also configurable via the THUNDERID_SESSION_COOKIE_EXPIRY_TIME environment variable

How It Works​

  1. Reads the session cookie from the incoming request
  2. Verifies the session token signature and checks whether it has expired
  3. Initializes the ThunderIDNextClient with your configuration (from environment variables)
  4. Passes authentication state (user, session, tokens) to the client-side React context
  5. Wraps children with the client-side ThunderIDProvider from @thunderid/react

Configuration​

The provider reads configuration from environment variables automatically. No props are required beyond children:

Environment VariableDescription
NEXT_PUBLIC_THUNDERID_BASE_URLYour Choreo Identity & Access Management instance URL
NEXT_PUBLIC_THUNDERID_CLIENT_IDThe Client ID from your application
THUNDERID_CLIENT_SECRETThe Client Secret (server-side only)
THUNDERID_SECRETSecret for signing session cookies

Was this page helpful?