Keycloakify
HomeGitHubStorybookAlternative to keycloak-js
  • Documentation
  • Release Notes & Upgrade Instructions
  • FAQ
  • v11
  • v10
  • v9
  • v8
  • v7
  • v6.12
  • v6
  • Other guides
    • ⬆️Migrating from Create-React-App to Vite
Powered by GitBook
On this page
  • Main script renamed to keycloakify
  • Components exported using default export
  • i18n: Adding i18n messages keys
  • Terms and conditions
  • useFormValidationSlice()

Was this helpful?

Edit on GitHub

v6

Migration guide from v5 to v6

Main script renamed to keycloakify

You can search and replace build-keycloak-theme -> keycloakify in your project.

package.json

 "scripts": {
     "start": "react-scripts start",
     "build": "react-scripts build",
-    "keycloak": "yarn build && build-keycloak-theme"
+    "keycloak": "yarn build && keycloakify"
 },
 "dependencies": {
-    "tss-react": "^3.6.0",
-    "keycloakify": "^5.7.0",
+    "keycloakify": "^6.8.8"
 }

.github/workflows/ci.yaml

-- run: npx build-keycloak-theme
+- run: npx keycloakify
-- run: npx build-keycloak-theme --external-assets
+- run: npx keycloakify --external-assets

Components exported using default export

In order to enable you to use React.lazy(), Keycloakify components are now exported with default exports instead of named exports.

-import { KcApp, defaultKcProps, getKcContext } from "keycloakify";
+import KcApp, { defaultKcProps, getKcContext } from "keycloakify";

-import { Login } from "keycloakify/lib/components/Login";
+import Login from "keycloakify/lib/components/Login";

You can also have a look at a real world migration:

i18n: Adding i18n messages keys

Keycloakify v6 now has a proper i18n api.

Terms and conditions

 useDownloadTerms({
   kcContext,
   "downloadTermMarkdown": async ({ currentKcLanguageTag }) => {

-     kcMessages[currentKcLanguageTag].termsTitle = "";

     const markdownString = await fetch((() => {
       switch (currentKcLanguageTag) {
         case "fr": return tos_fr_url;
         default: return tos_en_url;
       }
     })()).then(response => response.text());

     return markdownString;

   }
 });

 const i18n = useI18n({
    kcContext,
    "extraMessages": {
        "en": {
+            "termsTitle": "",
        },
        "fr": {
            /* spell-checker: disable */
+           "termsTitle": "",
            /* spell-checker: enable */
        }
    }
});

useFormValidationSlice()

useFormValidationSlice() now require you to pass a i18n object, see I18n API.

 import { useFormValidationSlice } from "keycloakify";

 const {
     formValidationState,
     formValidationReducer,
     attributesWithPassword
 } = useFormValidationSlice({
     kcContext,
     passwordValidators,
+    i18n
 });

Was this helpful?

Once you're at it, it might be a good time to update your app to use <Suspense/> and React.lazy() in order to reduce your bundle size. See or to see how it's supposed to be setup.

In v5 and prior, Keycloakify only provided of customizing internationalized message.

The message termsTitle () was replaced by a blank string in v5. If you want to do the same in v6 you have to use the new i18n API.

If you have performed a modification at the component level of the Terms.tsx component be mindful that we now use an to re render when the terms Markdown have been downloaded.

keycloakify-starter (CSS only)
keycloakify-advanced-starter (component level customization)
An app using Keycloakify v5
The same app after upgrade to v6
a very hacky way
Terms and Conditions in en.ts
Evt
sill-web/Terms.tsx at main · etalab/sill-webGitHub
Example of component level configuration of the Terms page
Cloud IAM - Keycloak Identity and Access Management as a Service
Feeling overwhelmed? Check out our exclusive sponsor's Cloud IAM consulting services to simplify your experience.
Logo
Logo