In a Keycloak Docker Container


npx keycloakify start-keycloak

Testing your theme in Storybook is nice, but at some point you'll want to test your theme in a real Keycloak before shipping it in production!

First you want to install and launch Docker Desktop (or just Docker) on your computer, if you haven't done it already.

You'll also need Maven to build the .jar locally. Try running mvn --version to see if you have it already. If you don't install it with:

Using Homebrew:

brew install maven

You are ready! In your Keycloakify just run:

npx keycloakify start-keycloak

You'll be invited to chose the Keycloak version you want to spin up:

Keycloakify will preconfigure a realm and client for your theme so you don't necessarily need to go in the the Keycloak admin console you can simply lavigate to it will redirect to your local Keycloak login pages!

If you makes changes in your theme while the Keycloak container is running your theme will be automatically recompiled and updated in Keycloak. After a few seconds you'll just have to refresh the page you see them live.

You'll be able to authenticate with the test user:

And see the content of your Open ID Connect Access Tocken JWT:

Here you can chose to go back to the login page or you have a link to the account pages:

Now what's interesting is you can see the real kcContext in the dev tools. You can use it as a reference to create new stories!

If you connect to the Keycloak Admin UI (http://localhost:8080) and make some changes to the Ream configuration you can then export theses change into a .json file using the partial export feature of Keycloak:

Later on, you can then start another container again with the same configuration using:

npx keycloakify start-keycloak --import realm-export.json

Last updated