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 TanStack Router context. :::Props
onErroroptional(error: Error) => voidCalled when 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 TanStack Router's `router.navigate()`
Example
import { createRoute } from '@tanstack/react-router'
import { CallbackRoute } from '@thunderid/tanstack-router'
const callbackRoute = createRoute({
getParentRoute: () => rootRoute,
path: '/callback',
component: CallbackRoute,
})