keycloakify-custom/src/main.tsx

36 lines
1.4 KiB
TypeScript
Raw Normal View History

2022-09-06 17:22:23 +00:00
import { createRoot } from "react-dom/client";
import { StrictMode, lazy, Suspense } from "react";
import { kcContext as kcLoginThemeContext } from "./keycloak-theme/login/kcContext";
2023-03-21 16:19:01 +00:00
import { kcContext as kcAccountThemeContext } from "./keycloak-theme/account/kcContext";
2022-09-06 17:22:23 +00:00
const KcLoginThemeApp = lazy(() => import("./keycloak-theme/login/KcApp"));
2023-03-21 16:19:01 +00:00
const KcAccountThemeApp = lazy(() => import("./keycloak-theme/account/KcApp"));
2024-01-10 12:38:55 +00:00
// Important note:
// In this starter example we show how you can have your react app and your Keycloak theme in the same repo.
// Most Keycloakify user only want to great a Keycloak theme.
// If this is your case run the few commands that will remover everything that is not strictly related to the
//Keycloak theme:
// https://github.com/keycloakify/keycloakify-starter?tab=readme-ov-file#i-only-want-a-keycloak-theme
2023-03-21 16:19:01 +00:00
const App = lazy(() => import("./App"));
2022-09-06 17:22:23 +00:00
createRoot(document.getElementById("root")!).render(
<StrictMode>
2023-02-27 09:13:07 +00:00
<Suspense>
{(()=>{
if( kcLoginThemeContext !== undefined ){
return <KcLoginThemeApp kcContext={kcLoginThemeContext} />;
}
2023-03-21 16:19:01 +00:00
if( kcAccountThemeContext !== undefined ){
return <KcAccountThemeApp kcContext={kcAccountThemeContext} />;
}
return <App />;
})()}
2023-02-27 09:13:07 +00:00
</Suspense>
</StrictMode>
2022-09-06 17:22:23 +00:00
);