import "./KcApp.css"; import { lazy, Suspense } from "react"; import Fallback, { type PageProps } from "keycloakify/login"; import type { KcContext } from "./kcContext"; import { useI18n } from "./i18n"; import Template from "./Template"; const Login = lazy(() => import("./pages/Login")); // If you can, favor register-user-profile.ftl over register.ftl, see: https://docs.keycloakify.dev/realtime-input-validation const Register = lazy(() => import("./pages/Register")); const RegisterUserProfile = lazy(() => import("./pages/RegisterUserProfile")); const Terms = lazy(() => import("./pages/Terms")); const MyExtraPage1 = lazy(() => import("./pages/MyExtraPage1")); const MyExtraPage2 = lazy(() => import("./pages/MyExtraPage2")); const Info = lazy(() => import("keycloakify/login/pages/Info")); // This is like adding classes to theme.properties // https://github.com/keycloak/keycloak/blob/11.0.3/themes/src/main/resources/theme/keycloak/login/theme.properties const classes = { // NOTE: The classes are defined in ./KcApp.css "kcHtmlClass": "my-root-class", "kcHeaderWrapperClass": "my-color my-font" } satisfies PageProps["classes"]; export default function KcApp(props: { kcContext: KcContext; }) { const { kcContext } = props; const i18n = useI18n({ kcContext }); if (i18n === null) { //NOTE: Text resources for the current language are still being downloaded, we can't display anything yet. //We could display a loading progress but it's usually a matter of milliseconds. return null; } /* * Examples assuming i18n.currentLanguageTag === "en": * i18n.msg("access-denied") === Access denied * i18n.msg("foo") === foo in English */ return ( {(() => { switch (kcContext.pageId) { case "login.ftl": return ; case "register.ftl": return ; case "register-user-profile.ftl": return case "terms.ftl": return ; // Removes those pages in you project. They are included to show you how to implement keycloak pages // that are not yes implemented by Keycloakify. // See: https://docs.keycloakify.dev/limitations#some-pages-still-have-the-default-theme.-why case "my-extra-page-1.ftl": return ; case "my-extra-page-2.ftl": return ; // We choose to use the default Template for the Info page and to download the theme resources. // This is just an example to show you what is possible. You likely don't want to keep this as is. case "info.ftl": return ( import("keycloakify/login/Template"))} doUseDefaultCss={true} /> ); default: return ; } })()} ); }