For the complete documentation index, see llms.txt. This page is also available as Markdown.

Deploying Your Theme

This section explains how to load and enable your theme in your production Keycloak instance.

Building the JAR File

Keycloak uses an extension system where themes or other custom plugins are packaged as standardized JAR files.

The first step is to build your theme into a JAR file that can be loaded into Keycloak.

npm run build-keycloak-theme

This command will create a /dist_keycloak directory containing the necessary JAR files.

By default, Keycloakify generates multiple JAR files to support different Keycloak versions. Here’s how to choose the correct JAR file for your production environment:

• Keycloak 11 to 21 and 26 and newer: Use keycloak-theme-for-kc-all-other-versions.jar.

• Keycloak 22 to 25: Use keycloak-theme-for-kc-22-to-25.jar.

You can configure which JAR files are generated and how they are named. For details, refer to this guide:

keycloakVersionTargets

If you have an OPS team and your responsibility is limited to developing the theme, your job ends here. The JAR file is your deliverable. You can provide it to the person managing your Keycloak instance—they will know what to do with it.

If you are responsible for both development and deployment, keep reading to learn how to load and enable the theme in Keycloak.

Loading the JAR File into Keycloak

Now that your theme is packaged as a JAR file, you can load it into your Keycloak server, just like any other Keycloak extension.

For official guidance, refer to the Keycloak documentation on registering provider implementations. While the official documentation provides a general overview, you might wonder how to apply those instructions in practice. Below, you’ll find a few code snippets illustrating how to load your theme, depending on the method you use to deploy Keycloak in production.

If Phase Two manages your Keycloak instance, upload the theme JAR from its dashboard.

  1. In the left sidebar, select Config → Resources.

  2. Click + Add new resource.

  3. Select Theme.

  4. Upload your JAR file, such as dist_keycloak/keycloak-theme-for-kc-all-other-versions.jar.

One of the most common ways to deploy Keycloak in production is by using the official Docker image.

If you are following this approach, you can use the -v option to mount your JAR file into the /opt/keycloak directory inside the container.

Here’s an example of how to run the Keycloak container with your custom theme:

This approach builds on the basic Docker setup, providing a more streamlined way to manage your Keycloak deployment with Docker Compose. Let’s assume you have the following directory structure:

If you use Bitnami's Keycloak Helm chart you can leverage the initContainers parameter to load your theme.

Here we only list the relevant values:

Read this section of the starter project readme to learn how to get GitHub Action to publish your theme's JAR as assets of your GitHub release.

What you need to know is that your keycloak-theme.jar should be placed in the provider directory of your Keycloak (e.g: /opt/keycloak/providers) After that you should run bin/kc.sh build (e.g: sh /opt/keycloak/bin/kc.sh build)

Then you can start your Keycloak server, your theme should be available in it.

Another common approach is to build a custom Docker image of Keycloak that extends the official Keycloak image and includes your theme.

Ref to official doc: https://www.keycloak.org/server/containers

Enabling Your Theme

Once your JAR file is loaded into your Keycloak instance, enable your theme in the Keycloak Admin Console:

1. Go to Realm Settings in your desired realm.

2. Under the Themes section, select your theme from the dropdown menus (e.g., Login Theme).

Note that the name that appears in the dropdown (here "keycloakify-starter") can be configured with the themeName option. If you implement theme variants you'll have more than one option.

Enabling diffrent theme for diffrent client

The login theme can be applied at the client level. You typically have one Keycloak client per web application. Setting the login theme at the client level means that each application of your realm can have different login/register pages. This comes in handy if you're implementing Theme Variants.

To enable a login theme on one of your clients:

  • Select your realm in the top left corner

  • -> Clients

  • -> Select your client in the list

  • -> Scroll down to "Login Theme" and select your theme.

The account theme can only be enabled at the realm level; however, accessing the account pages requires authentication. If you don't want your user to inadvertently come across the default login theme when navigating to the account pages after their session has expired, you might want to enable your login theme on the "account-console" client.

  • Select your realm in the top left corner

  • -> Clients

  • -> Select "account console"

  • -> Scroll down to "Login Theme" and select one of your login theme.

Last updated

Was this helpful?