Skip to content
p2-incPublic

About

Framework Examples

Resources

Contributing

Stars

19 stars

Watchers

1 watching

Forks

Repository files navigation

Phase Two Framework Examples

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.

Frameworks

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

Multi-tenant

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.

Build status

Example Status
React (oidc-client-ts) React (oidc-client-ts)
React (oidc-spa) React (oidc-spa)
React (oidc-spa tutorial starter) React (oidc-spa tutorial starter)
Next.js (NextAuth.js) Next.js (NextAuth.js)
React Router v7, formerly Remix (remix-auth) React Router v7, formerly Remix (remix-auth)
Vue (oidc-client-ts) Vue (oidc-client-ts)
Nuxt (keycloak-js) Nuxt (keycloak-js)
Nuxt (oidc-client-ts) Nuxt (oidc-client-ts)
SvelteKit (Auth.js) SvelteKit (Auth.js)
Angular (angular-oauth2-oidc) Angular (angular-oauth2-oidc)
Django (mozilla-django-oidc) Django (mozilla-django-oidc)
Spring Boot + Angular Spring Boot + Angular
SAML IdP-initiated SSO (Spring Boot) SAML IdP-initiated SSO (Spring Boot)
Multi-tenant (Nx) Multi-tenant (Nx)

Running an example

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 each package.json is 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 --wait starts one with a pre-configured p2examples realm and demo users. See keycloak/README.md. Each example has a sample env file for it.

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.

Github Actions

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.

Contributing

See CONTRIBUTING.md for the conventions the examples follow.

About

Framework Examples

Resources

Contributing

Stars

19 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages