Last updated 14 days ago
Was this helpful?
Before starting be aware that oidc-spa is not suited for Next.js.
If you are using Next the closer alternative is to use (with if you are using Keycloak). See .
If you're having issues don't hesitate to !
npm install oidc-spa
yarn add oidc-spa
pnpm add oidc-spa
bun add oidc-spa
This is optional but recommended for better performances and security.
First rename your entry point file from main.tsx (or main.ts) to main.lazy.tsx
main.tsx
main.ts
main.lazy.tsx
mv src/main.tsx src/main.lazy.tsx
The create a new main.tsx file:
import { oidcEarlyInit } from "oidc-spa/entrypoint"; const { shouldLoadApp } = oidcEarlyInit({ freezeFetch: true, freezeXMLHttpRequest: true }); if (shouldLoadApp) { import("./main.lazy"); }
Comming soon, .
You can skip this for now. It will be explained in the dedicated setup guide:
mv src/index.tsx src/index.lazy.tsx
The create a new index.tsx file:
index.tsx
import { oidcEarlyInit } from "oidc-spa/entrypoint"; const { shouldLoadApp } = oidcEarlyInit({ freezeFetch: true, freezeXMLHttpRequest: true }); if (shouldLoadApp) { import("./index.lazy"); }