React Router Framework: prerendered frontend
Register the dedicated callback URL with your identity provider: http://app.localhost:3000/openid-callback/ for development, or https://your-app.example/openid-callback/ in production. The reference example uses the home URL instead.
Include the application basename: with basename: "/dashboard/", register https://mycompany.com/dashboard/openid-callback/. Keep redirectUriPath: "/openid-callback/"; it is relative to that basename. No callback route needs to be created in the application.
What changes from the reference
ssr: falsestays enabled.prerender: ["/", "/inactivity-logout"]produces public page HTML at build time. Protected routes stay client-rendered.- The oidc-spa plugin sets
enableRoutingCookie: falseandredirectUriPath: "/openid-callback/". Callbacks receive a common shell, and early initialization restores the return URL before loading the app. - Because the home is prerendered, React Router generates
__spa-fallback.htmlfor other frontend URLs. The root's emptyHydrateFallbackkeeps it free of application UI. - Public pages must render correctly at build time, without browser APIs or visitor-specific values. Defer those pieces with a client-ready boundary and useful static content. The inactivity page resolves its return link in
useEffectafter the initial render. - Frontend files are static; the Express/tRPC API is the same separate backend as in the reference. Run
npm run typecheck,npm run build, thennpm startto inspect both locally.
CDN routing
This example targets Vercel but can be adapted to another CDN. The application owns vercel.json; the plugin does not generate deployment rules. Serve existing pages and assets first, proxy /api/* to the backend, and use __spa-fallback.html for frontend misses.
OIDC adds one constraint: GET/HEAD requests to /openid-callback/must internally serve /__spa-fallback.html, preserving the callback URL and trailing slash. The explicit callback rule takes precedence over files.
Combine with Framework server features
The same prerendering and callback changes can be applied to the integrated-API variant. Keep ssr: "unstable_api-only", its custom router fetch and backend dispatch rules. That combination retains the integrated variant's unstable APIs.