API reference
Functions
function
<CallbackRoute />The
CallbackRoute component handles the OAuth 2.0 authorization code callback. Mount it at your application's redirect URI path. It processes the authorization code, validates the CSRF state parameter, exchanges the code for tokens, and navigates the user back to their original destination. :::note CallbackRoute must be rendered inside a ThunderIDProvider and a React Router context. :::Props
onErroroptional(error: Error) => voidCalled when the callback processing fails (e.g., invalid state, token exchange error)
onNavigateoptional(path: string) => voidOverride the default post-callback navigation. Receives the resolved destination path. Defaults to React Router's `navigate()`
Example
import { BrowserRouter, Routes, Route } from 'react-router'
import { ThunderIDProvider } from '@thunderid/react'
import { CallbackRoute } from '@thunderid/react-router'
function App() {
return (
<ThunderIDProvider
clientId="<your-client-id>"
baseUrl="https://localhost:8090"
afterSignInUrl="http://localhost:5173/callback"
>
<BrowserRouter>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/callback" element={<CallbackRoute />} />
</Routes>
</BrowserRouter>
</ThunderIDProvider>
)
}