This is the documentation for v6, checkout the latest version
Keycloakify
v6
  • Keycloakify
  • Release Notes & Upgrade Instructions
  • FAQ
v6
  • ๐Ÿ‘จโ€๐Ÿ’ปQuick start
  • ๐Ÿ”ฉKeycloakify in my App
  • ๐Ÿ“งEmail customization
  • โœ’๏ธTerms and conditions
  • โœ…Realtime input validation
  • โš ๏ธLimitations
  • ๐ŸŒ‰Context persistence
  • ๐ŸŒŽi18n: msg(...)
  • ๐Ÿ’‚Email domain acceptlist
  • ๐Ÿ›‘Keycloak error in log
  • ๐Ÿ’ŸContributing
  • ๐Ÿ“–Build options
  • ๐ŸRequirements
  • โฌ†๏ธv5 -> v6
  • โฌ†๏ธv6.x -> v6.12
Powered by GitBook
On this page
  • Main script renamed to keycloakify
  • Components exported using default export
  • i18n: Adding i18n messages keys
  • Tems and conditions
  • useFormValidationSlice()

Was this helpful?

v5 -> 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(), Keyclaokify 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.

Tems 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()

 import { useFormValidationSlice } from "keycloakify";
 
 const {
     formValidationState,
     formValidationReducer,
     attributesWithPassword
 } = useFormValidationSlice({
     kcContext,
     passwordValidators,
+    i18n
 });
PreviousRequirementsNextv6.x -> v6.12

Last updated 2 days ago

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 suposed to be setup.

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

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

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

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

โฌ†๏ธ
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
๐ŸŒŽi18n: msg(...)
Terms and Conditions in en.ts
i18n API
Evt
I18n API
sill-web/Terms.tsx at main ยท etalab/sill-webGitHub
Example of component level configuration of the Terms page
Logo