Next.js API reference
Every export is fully typed. The signatures and props below come from the package's own reference documentation, so what is listed here is what the installed version ships.
Functions
ThunderIDProvider /
function
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.
Props
| Name | Type | Description |
|---|---|---|
| children | ReactNode | Required. Your application tree |
| sessionCookieExpiryTime | number | Session cookie lifetime in seconds. Also configurable via the THUNDERID_SESSION_COOKIE_EXPIRY_TIME environment variable |
import { ThunderIDProvider } from '@thunderid/nextjs/server'
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body>
<ThunderIDProvider>
{children}
</ThunderIDProvider>
</body>
</html>
)
}
Configuration
function
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.
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>
Middleware
function
The Choreo Identity & Access Management Next.js SDK provides Edge Runtime-compatible middleware for automatic token refresh and route protection.
import {
thunderIDProxy,
createRouteMatcher,
} from '@thunderid/nextjs/server'
const isProtectedRoute = createRouteMatcher(['/dashboard(.*)'])
export default thunderIDProxy(async (thunderid, request) => {
if (isProtectedRoute(request)) {
await thunderid.protectRoute()
}
})
export const config = {
matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
}
Server Actions
function
The Choreo Identity & Access Management Next.js SDK provides server actions for authentication, session management, and user operations. These run only on the server and never expose tokens to the client. Import all server actions from @thunderid/nextjs/server.
import { signInAction } from '@thunderid/nextjs/server'
// Redirect-based sign-in (default)
await signInAction()
// With embedded flow payload (advanced)
await signInAction(payload, requestConfig)
Was this page helpful?