Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/keycloakify/docs.oidc-spa.dev
Markdown source of the GitBook documentation website for oidc-spa
https://github.com/keycloakify/docs.oidc-spa.dev
Last synced: about 1 month ago
JSON representation
Markdown source of the GitBook documentation website for oidc-spa
- Host: GitHub
- URL: https://github.com/keycloakify/docs.oidc-spa.dev
- Owner: keycloakify
- Created: 2024-01-04T22:06:45.000Z (12 months ago)
- Default Branch: v5
- Last Pushed: 2024-10-21T00:05:44.000Z (2 months ago)
- Last Synced: 2024-10-21T03:35:16.450Z (2 months ago)
- Homepage: https://docs.oidc-spa.dev
- Size: 6.99 MB
- Stars: 0
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🔩 Installation
{% hint style="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.js](https://next-auth.js.org/) (with [the Keycloak adapter](https://next-auth.js.org/providers/keycloak) if you are using Keycloak). \
You can refer to [the phase two guide](https://phasetwo.io/docs/securing-applications/next/).
{% endhint %}If you're having issues don't hesitate to [reach out on Discord](https://discord.gg/mJdYJSdcm4)!
Let's install [oidc-spa](https://github.com/keycloakify/oidc-spa) in your project:
{% tabs %}
{% tab title="npm" %}
```bash
npm install --save oidc-spa
```
{% endtab %}{% tab title="yarn" %}
```bash
yarn add oidc-spa
```
{% endtab %}{% tab title="pnpm" %}
```bash
pnpm add oidc-spa
```
{% endtab %}{% tab title="bun" %}
```bash
bun add oidc-spa
```
{% endtab %}
{% endtabs %}Create the silent-sso.htm[^1] file in your public directory:
{% code title="public/silent-sso.htm" %}
```html
parent.postMessage(location.href, location.origin);
```
{% endcode %}Doing without the silent-sso.htm 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" })`.[^1]: Yes .htm and not .html. \
Some web server such as [serve](https://github.com/vercel/serve#readme) will rewrite `/silent-sso.html` to `/silent-sso` and serve the `index.html` of your distribution. \
Using the `.htm` extention prevend any potential issue.