Skip to main content

React Router

Official

Official ThunderID integration for React Router (formerly Remix) applications.

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
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) => void

Called when the callback processing fails (e.g., invalid state, token exchange error)

onNavigateoptional
(path: string) => void

Override 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>
  )
}
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.