Application
A country app defines its application as a rendered React tree: a GlobalApp element that wires up core services (auth, feature flags, user data), registers the given modules, and routes their screens.
Each country app exports one createApplication() function: it assembles the modules and returns the root component. Everything the application is made of — the module list, the dashboard shell, country adapters — is built inside its body, not at module scope.
This one-app-per-country constraint is expected to change — we plan to support applications serving multiple countries.
import type { ComponentType } from "react";
import { api } from "@alaneu/global-api/<country>";
import { GlobalApp } from "@alaneu/global-shell";
export const createApplication = (): ComponentType => {
const myModules = [myCountryModule, onboardingModule()];
return () => <GlobalApp homePage="/dashboard/company/my-page" api={api} modules={myModules} />;
};
GlobalApp props
| Property | Type | Required | Description |
|---|---|---|---|
api | unknown | Yes | — |
ErrorPage | ComponentType | No | Custom error page displayed on a general error |
homePage | string | Yes | Defines the default page showed after login |
legacyCountryAdapter | LegacyCountryAdapter | No | Legacy hooks for country apps that still need to inject tracking or extra providers into the shell. Defaults to a noop adapter. |
LoadingPage | ComponentType | No | Custom loading page displayed until a screen is ready |
redirectToHomepage | boolean | No | When a capability check fails, redirect to `homePage` instead of rendering the forbidden screen. Opt-in for legacy apps where the homepage itself is unguarded; new apps should leave this off to avoid infinite redirect loops when the homepage is also capability-gated. |
urlScheme | UrlScheme | No | Defaults to `language-prefixed`. |
useCapabilitiesHook | UseCapabilitiesHook | No | Suspense query hook returning the current user's capability map. Required for route guards. |
Plus two props of its own:
| Prop | Description |
|---|---|
modules | The application's modules. Registered once at mount — the array must be stable. |
onRoutesReady | Test/introspection only: fires once, with the routes the router was built from. |
Modules are registered in order. Dependencies declared within each module are resolved automatically via topological sort. Lazy module loading is not supported: declare the array once in createApplication() with everything the app needs.
The dashboard shell
The customer dashboard shell is a module like any other: build it from the dashboard modules and the app's menu, then include it in modules:
import { customerDashboardShell } from "@alan-eu/global-customer-dashboard/module";
const dashboardModule = customerDashboardShell({
modules: [myDashboardModule, customerAdminManagementModule],
menu: { main: { order: 1, items: ["employees", "admins"] } },
});
const myModules = [myCountryModule, dashboardModule];
Menu item keys are checked at compile time against the dashboard modules' menuItems.
Core features
GlobalApp includes these core features — you don't need to register them:
| Feature | Purpose |
|---|---|
| Authentication | Auth state, login/logout flows |
| User | Current user data |
| Feature flags | LaunchDarkly integration |
| Auth screens | Login, password reset, password change screens |
Full example
The Saudi Arabia app (frontend/apps/sa-app/application.tsx):
import type { ComponentType } from "react";
import { customerDashboardShell, rootPath } from "@alan-eu/global-customer-dashboard/module";
import {
customerAdminManagementModule,
customerAdminOnboardingModule,
} from "@alaneu/customer-admin-management";
import { api } from "@alaneu/global-api/sa";
import { GlobalApp, type GlobalAppProps } from "@alaneu/global-shell";
import { onboardingModule } from "@alaneu/member-lifecycle/onboarding";
import { saDashboardModule } from "./modules/saDashboardModule";
import { saModule } from "./modules/saModule";
export const createApplication = (): ComponentType<Pick<GlobalAppProps, "onRoutesReady">> => {
const dashboardModule = customerDashboardShell({
modules: [saDashboardModule, customerAdminManagementModule],
menu: { main: { order: 1, items: ["helloWorld", "inviteEmployees", "admins"] } },
});
const saModules = [saModule, customerAdminOnboardingModule, onboardingModule(), dashboardModule];
const SaApplication = ({ onRoutesReady }: Pick<GlobalAppProps, "onRoutesReady">) => (
<GlobalApp
homePage={`/${rootPath}/some-ksa-page`}
api={api}
modules={saModules}
onRoutesReady={onRoutesReady}
/>
);
return SaApplication;
};
Key takeaways
- The app is a module list: assembling an application is declaring its modules and the dashboard menu — no routing or provider code.
- Country-specific features are just regular
Moduleobjects — noif(country)branching. - The dashboard shell is a module:
customerDashboardShell(config)collapses dashboard modules and the menu into one entry of the list, with menu keys compile-checked. createApplication()is the country module's entry point — it builds the whole application when called;global-appcalls it once and renders the returned component.