# How to add a theme for a specific client in Keycloak without restarting the server?

**URL:** <https://forum.keycloak.org/t/how-to-add-a-theme-for-a-specific-client-in-keycloak-without-restarting-the-server/29787>\
**Category:** Configuring the server\
**Created:** [March 21, 2025, 4:18pm UTC](https://forum.keycloak.org/t/how-to-add-a-theme-for-a-specific-client-in-keycloak-without-restarting-the-server/29787 "2025-03-21T16:18:15Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![VladimirU](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/vladimiru/32/12050_2.png) [@VladimirU](https://forum.keycloak.org/u/VladimirU)\
**Post date:** [March 21, 2025, 4:18pm UTC](https://forum.keycloak.org/t/how-to-add-a-theme-for-a-specific-client-in-keycloak-without-restarting-the-server/29787/1 "2025-03-21T16:18:15Z")

</div>

Hi everyone,

I’m using **Keycloak** in production with multiple clients, and I need to add **custom themes** for specific clients without restarting the server or affecting the other clients.

Is there a way to add a new theme for a specific client dynamically, without having to restart the Keycloak instance or interrupting service for other clients?

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [March 24, 2025, 1:04pm UTC](https://forum.keycloak.org/t/how-to-add-a-theme-for-a-specific-client-in-keycloak-without-restarting-the-server/29787/2 "2025-03-24T13:04:28Z")

</div>

Adding themes without restarting the server is not supported.  
If you run Keycloak in a cluster, you can do rolling restarts, so no clients/users should be affected.

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [March 25, 2025, 6:53pm UTC](https://forum.keycloak.org/t/how-to-add-a-theme-for-a-specific-client-in-keycloak-without-restarting-the-server/29787/3 "2025-03-25T18:53:56Z")

</div>

We have an extension that allows hot loading/reloading of theme jars at runtime. We use this in our hosted system to allow per-realm themes without restarting Keycloak.

> **[GitHub - p2-inc/keycloak-themes: Themes and theme utilities meant for simple theme...](https://github.com/p2-inc/keycloak-themes?tab=readme-ov-file#jar-folder-theme-provider)**
>
> Themes and theme utilities meant for simple theme customization without deploying a packaged theme

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [March 25, 2025, 7:10pm UTC](https://forum.keycloak.org/t/how-to-add-a-theme-for-a-specific-client-in-keycloak-without-restarting-the-server/29787/4 "2025-03-25T19:10:54Z")

</div>

Cool, didn’t know about that.  
Is caching also properly supported with hot reload?

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [March 25, 2025, 8:02pm UTC](https://forum.keycloak.org/t/how-to-add-a-theme-for-a-specific-client-in-keycloak-without-restarting-the-server/29787/5 "2025-03-25T20:02:32Z")

</div>

Caching isn’t implemented yet. This was due to the `DefaultThemeManagerFactory` not being overridable, and its `clearCache` method clearing the whole `Map`, rather than giving fine-grained control over which cache to remove. There’s a dead PR somewhere that I started for Keycloak to expose a proper SPI for `ThemeManagerFactory` (doesn’t exist), but it’s not a priority right now.

However, one point to make on this is that we did a test ages ago when we were building another theme extension on the actual performance improvement of caching, and it was pretty negligible. That, and we front the resource paths with a CDN in our hosted service, which makes caching in Keycloak even less relevant. Have you experienced a different performance profile?

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [March 25, 2025, 8:03pm UTC](https://forum.keycloak.org/t/how-to-add-a-theme-for-a-specific-client-in-keycloak-without-restarting-the-server/29787/6 "2025-03-25T20:03:29Z")

</div>

So, to clarify further, the above mentioned extension needs to be run with `KC_SPI_THEME_CACHE_THEMES=false` in order for hot reloading to work properly.

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [March 25, 2025, 8:31pm UTC](https://forum.keycloak.org/t/how-to-add-a-theme-for-a-specific-client-in-keycloak-without-restarting-the-server/29787/7 "2025-03-25T20:31:16Z")

</div>

Thanks for clarifying.  
I once made some bad experience with disabled caching, also some time ago. This was noticed under high load. With only a few users, Keycloak has enough resources to load and deliver the resource files without caching and you won’t take note of it.  
The option with a CDN seems to be good fit and works around the most caching issues. But also the message resources are cached, so a CDN will only solve the things partly.

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [March 26, 2025, 9:54am UTC](https://forum.keycloak.org/t/how-to-add-a-theme-for-a-specific-client-in-keycloak-without-restarting-the-server/29787/8 "2025-03-26T09:54:22Z")

</div>

I think it’s worthwhile for us to do the test again. We don’t see an issue with our hosted customers that have large load, but it would be better to quantify the difference,

Also, created an enhancement request here [Make `ThemeManagerFactory` into a proper SPI so that it can be accessed/overridden · Issue #38433 · keycloak/keycloak · GitHub](https://github.com/keycloak/keycloak/issues/38433) I’ll dust off the PR and add it later this week.

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [April 25, 2025, 3:21pm UTC](https://forum.keycloak.org/t/how-to-add-a-theme-for-a-specific-client-in-keycloak-without-restarting-the-server/29787/9 "2025-04-25T15:21:24Z")

</div>

Update: I PR’ed that idea and got it merged. It’s tagged to be released in `26.3.0`. [Make `ThemeManagerFactory` into a proper SPI so that it can be accessed/overridden · Issue #38433 · keycloak/keycloak · GitHub](https://github.com/keycloak/keycloak/issues/38433)

Once that’s released, I’ll update the `ThemeProvider` implementations in our [`keycloak-themes`](https://github.com/p2-inc/keycloak-themes) project so that they clear the cache when runtime updates are made to the theme. This will eliminate the need to have theme caching turned off when using these extensions.

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [July 12, 2025, 11:27am UTC](https://forum.keycloak.org/t/how-to-add-a-theme-for-a-specific-client-in-keycloak-without-restarting-the-server/29787/10 "2025-07-12T11:27:29Z")

</div>

FYI, the PR went out in `26.3.0`

> <https://github.com/keycloak/keycloak/issues/38433>
>
> \### Description
> 
> Currently, \`DefaultThemeManagerFactory\` is an internal class an…d can't be accessed/overridden by extensions.  
> 
> 
> \### Discussion
> 
> \_No response\_
> 
> \### Motivation
> 
> It is desirable to allow other extensions to override and/or use the functionality of this class.
> 
> For example, the \`clearCache\` method in \`DefaultThemeManagerFactory\` is not exposed via any public SPI, so you cannot directly access it in a standard Keycloak extension. An author of a \`ThemeProvider\` or \`ThemeSelector\` may want to access this as part of building a dynamic \`Theme\` that changes at runtime.
> 
> 
> 
> \### Details
> 
> To implement:
> \- create a \`ThemeManagerSpi\` class
> \- expose the current \`DefaultThemeManagerFactory\` methods as a \`ThemeManagerFactory\` interface
> \- update the code that uses the \`DefaultThemeManagerFactory\` (looks like only the \`DefaultKeycloakSessionFactory\` and \`DefaultThemeManager\`) to load the implementation using \`session.getProvider...\`
> 
> I'll submit a PR in a few days.

---

<div class="post-metadata">

**Author:** ![ps10251](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/ps10251/32/12495_2.png) [@ps10251](https://forum.keycloak.org/u/ps10251)\
**Post date:** [March 5, 2026, 4:37am UTC](https://forum.keycloak.org/t/how-to-add-a-theme-for-a-specific-client-in-keycloak-without-restarting-the-server/29787/11 "2026-03-05T04:37:14Z")

</div>

Hi @xgp , just following up on this. Since the change was planned for 26.3.0, do you know if there are any updates on the ThemeProvider changes in the keycloak-themes project? Appreciate your work on this!

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [March 8, 2026, 9:36pm UTC](https://forum.keycloak.org/t/how-to-add-a-theme-for-a-specific-client-in-keycloak-without-restarting-the-server/29787/12 "2026-03-08T21:36:29Z")

</div>

We haven’t had a chance to update this yet. Follow the issue here: [Clear cache when changes are made in dynamic themes · Issue #59 · p2-inc/keycloak-themes · GitHub](https://github.com/p2-inc/keycloak-themes/issues/59)
