This is a repo for code examples showing how to integrate Keycloak with various frameworks. Every example is a standalone project: copy its folder and it runs on its own.
| Framework | Code | Live | Tutorial | Local port |
|---|---|---|---|---|
| React (oidc-client-ts) | 🧑💻📁 | 👩💻🚀 | 👩🏫 | 3000 |
| React (oidc-spa) | 🧑💻📁 | 👩💻🚀 | 👩🏫 | 3000 |
| React (oidc-spa tutorial starter) | 🧑💻📁 | — | 👩🏫 | 3000 |
| Next.js (NextAuth.js) | 🧑💻📁 | 👩💻🚀 | 👩🏫 | 3000 |
| React Router v7, formerly Remix (remix-auth) | 🧑💻📁 | 👩💻🚀 | 👩🏫 | 3000 |
| Vue (oidc-client-ts) | 🧑💻📁 | 👩💻🚀 | 👩🏫 | 3000 |
| Nuxt (keycloak-js) | 🧑💻📁 | 👩💻🚀 | 👩🏫 | 3000 |
| Nuxt (oidc-client-ts) | 🧑💻📁 | 👩💻🚀 | 👩🏫 | 3000 |
| SvelteKit (Auth.js) | 🧑💻📁 | 👩💻🚀 | 👩🏫 | 3000 |
| Angular (angular-oauth2-oidc) | 🧑💻📁 | 👩💻🚀 | 👩🏫 | 4200 |
| Django (mozilla-django-oidc) | 🧑💻📁 | 👩💻⚒️ | 👩🏫 | 8000 |
| Spring Boot + Angular | 🧑💻📁 | 👩💻⚒️ | 👩🏫 | 8080 / 4200 |
| SAML IdP-initiated SSO (Spring Boot) | 🧑💻📁 | 👩💻⚒️ | 👩🏫 | 8081 |
Demo Apps to be used as a starting point for a multi-tenant setup with Phase Two Organizations. Uses nx to manage the apps and oidc-spa. Tutorial: Implement Multi-Tenancy Applications with Keycloak Organizations.
Each example's README has its exact steps. They all need:
- Node.js 24 (see
.nvmrc) and pnpm, for the JavaScript examples. With Corepack (corepack enable), the pnpm version pinned in eachpackage.jsonis used automatically. - Python 3.13+ for Django, and a JDK for the Spring Boot examples (Gradle downloads JDK 21 if needed).
- A Keycloak to log in against, either:
- the hosted demo realm
https://app.phasetwo.io/auth/realms/p2examples, which the live demos use, or - a local Phase Two Keycloak:
docker compose -f keycloak/docker-compose.yml up -d --waitstarts one with a pre-configuredp2examplesrealm and demo users. See keycloak/README.md. Each example has a sample env file for it.
- the hosted demo realm
To use your own Phase Two or Keycloak instance, create the client described in the example's README and point the example at your realm.
Every example has a workflow in .github/workflows that builds it on pull requests. The examples with a live demo are also deployed to Vercel: a preview deployment for pull requests and a production deployment for main. Deployments need the VERCEL_ORG_ID, VERCEL_DEPLOYMENT_TOKEN and VERCEL_<EXAMPLE>_PROJECT_ID secrets, and are skipped for forks and Dependabot pull requests. Feel free to use, disable, or remove as desired.
See CONTRIBUTING.md for the conventions the examples follow.