arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

Installation

circle-info

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 NextAuth.jsarrow-up-right (with the Keycloak adapterarrow-up-right if you are using Keycloak). You can refer to the phase two guidearrow-up-right.

If you're having issues don't hesitate to reach out on Discordarrow-up-right!

Let's install oidc-spaarrow-up-right in your project:

npm install oidc-spa

Create the silent-sso.htm file in your public directory:

chevron-rightDoing without the silent-sso.htm filehashtag

If for some reasons it's not fesable or practical for you to rely on the silent-sso.htm 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" }).

  • yarn add oidc-spa
    pnpm add oidc-spa
    bun add oidc-spa
    public/silent-sso.htm
    <!doctype html>
    <html>
        <body>
            <script>
                parent.postMessage(location.href, location.origin);
            </script>
        </body>
    </html>