🔩Installation

Before starting: This is not a library for Next.js projects.

If you are using Next the closer alternative is to use NextAuth.js (with the Keycloak adapter if you are using Keycloak).

If you're having issues don't hesitate to reach out on Discord!

Let's install oidc-spa in your project:

npm install --save 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" }).

Last updated