OIDC SPA
GitHubHome
v4
  • Documentation
  • Release Notes & Upgrade Instructions
v4
  • Documentation
    • 🔩Installation
    • 👨‍🔧Basic Usage
    • 🔌Web API
    • ⏲️Auto Logout
    • ❗Error Management
    • 🎭Mock
    • 🔁Tokens Renewal
    • 🛡️Globally Enforce Authentication
    • 🔐User Account Management
    • 🔄Doing Something Only When a New Session is Created
  • Example setups
    • 🛣️TanStack Router
    • 🛤️React Router
  • Resources
    • 🔑Keycloak Configuration Guide
    • 👥Accessing Keycloak Groups
    • 🍪End of third-party cookies
    • 🗝️JWT Of the Access Token
    • 💬Discord Server
  • ⭐Sponsors
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. Documentation

Installation

NextBasic Usage

Last updated 9 months ago

Was this helpful?

Before starting be aware that oidc-spa does not yet support Next.js projects.

If you are using Next the closer alternative is to use (with if you are using Keycloak). You can refer to .

If you're having issues don't hesitate to !

Let's install in your project:

npm install --save oidc-spa
yarn add oidc-spa
pnpm add oidc-spa
bun add oidc-spa

Create the following file in your public directory:

public/silent-sso.html
<html>
    <body>
        <script>
            parent.postMessage(location.href, location.origin);
        </script>
    </body>
</html>
Doing without the silent-sso.html file

If for some reasons it's not fesable or practical for you to rely on the silent-sso.html file it's ok, it will work without it.

Just make sure to

  • Set publicUrl to undefined when initializing oidc-spa.

  • Don't use logout({ redirectTo: "home" }) but explicitely tell where you want your users to be redirected after logout using logout({ redirectTo: "specific url", url: "/my-home" }) or use logout({ redirectTo: "current page" }).

🔩
NextAuth.js
the Keycloak adapter
the phase two guide
reach out on Discord
oidc-spa