Micro Frontend API-Referenz
MicroFrontend SDK-API
action- Type
{reload?: typeof window.location.reload}DescriptionUsed to pass a callback to reload the page:
{ reload }. To use this prop,integrateActionsmust be set totrue. auth- Type
{ accessToken, idToken, userInfo {OidcUserInfo | null} }DescriptionUsed to pass an object with tokens and
userInfo:{ accessToken, idToken, userInfo }to make these values available in the micro frontend. To use this prop,integrateAuthmust be set totrueand it is mandatory ifintegrateAuthis enabled. configOverrides- Type
{ customConfig: string, localeSettings: {} }DescriptionAllows the shell app to inject custom configurations into the micro frontend's Jutro config object.
When the
JUTRO_NEW_CONFIG_LOADING_ORDERenvironment variable is set totrue, the config object has precedence over values in the.envfile. In the shell app, you can then useconfigOverridesto inject the values in the config object and they are applied to the micro frontend's configuration.When the
JUTRO_NEW_CONFIG_LOADING_ORDERenvironment variable is set tofalse, the.envfile has precedence over the Jutro config object.configOverridescan still inject values into the Jutro config object, but they're not visible if the same variables are also defined in the.envfile. g11n- Type
LocaleConfig, 'onGlobalizationChange( language?: string; languageChanged?: boolean; locale: string; localeChanged: boolean )'DescriptionAllows you to pass locale configuration. To use this prop,
integrateG11nmust be set totrue. iframeAttributes- Type
{allow?: string; referrerpolicy?: string; sandbox?: string}DescriptionAllows to pass additional attributes for micro frontends. Entries from
iframeAttributesprop are added to theiframeHTML element. integrateActions- Type
booleanDescriptionLets the shell know when reloading on the micro frontend side. When set to
true, you must also pass theactionprop to enable the actions integration. integrateAuth- Type
booleanDescriptionAllows the sharing of authentication information between the shell app and the micro frontend. When set to
true, you must also pass theauthprop to enable the authentication integration. integrateG11n- Type
booleanDescriptionAllows you to listen to globalization changes in the micro frontend. When set to
true, you must also pass theg11nprop to enable the globalization integration. integrateJutro- Type
booleanDescriptionEnables or disables the rest of
integrate*props. By default is set tofalse. All theintegrate*props inherit theintegrateJutrovalue, this means that when it is set totruethe rest of theintegrate*props are set totrue. Then each of the props value can be manually overridden. integrateModal- Type
booleanDescriptionEnables the
modalintegration to trigger a modal from within the micro frontend so it can be displayed by the shell app. When set totrue, you must also pass themodalprop to enable the modal integration. integrateRouter- Type
booleanDescriptionAllows the
routerprop integration. When set totrue, you must also pass therouterprop to enable router integration. integrateTheme- Type
booleanDescriptionAllows you to set the theme that the micro frontend uses. Once enabled, use the prop
themeto specify the theme to use. When set totrue, you must also pass thethemeprop to enable the theme integration. integrateToast- Type
booleanDescriptionEnables the
toastintegration to trigger a toast message from within the micro frontend so it can be displayed by the shell app. When set totrue, you must also pass thetoastprop to enable the toast integration. modal- Type
{ showAlert, showConfirm }DescriptionTriggers a modal from within the micro frontend so it can be displayed by the shell app. It is an object with
modalproperty with a callback value. To use this prop,integrateModalmust be set totrue. onError- Type
({ error: Error, errorInfo?:ErrorInfo }) => voidDescriptionA callback to invoke when an error occurs. See the Microfrontend SDK documentation for more details about this property.
onLoadingFinished- Type
() => voidDescriptionAllows consumers to trigger a callback when a micro frontend finishes loading, enabling them to display their own loader from the shell app for a seamless integration.
onRender- Type
funcDescriptionA function that is called when the micro frontend is rendered or updated.
router- Type
{location?: string; state?: unknown; onLocationChange?(pathname?: string; action?: 'PUSH' | 'REPLACE' | 'GO'; state?: unknown ) => void; basename?: string; onBlockChange(isBlocked: boolean; prompt?: never)}DescriptionSets the current location of the micro frontend. Any change triggers the navigation on the micro frontend side.
theme- Type
{themeConfig?: ThemeConfigType;}DescriptionSets the theme that the micro frontend uses. To use it,
integrateThememust be set totrue. timeout- Type
numberDescriptionThe app waits the specified time in milliseconds for the micro frontend to load. Note: Network errors such as
net::ERR_CONNECTION_REFUSEDget handled at the browser level. As there is no API to detect it, the only way to identify the error is to wait until the timeout handler shows an error view. Developers can identify the error in theNetworktab ofDeveloper Tools. toast- Type
{ message?: IntlMessageShape; type?: 'info' | 'success' | 'warning' | 'error'; autoFocus?: boolean; linkProps?: LinkProps; onClosed?: ToastOptions['onClose']; toastId?: string; }DescriptionTriggers a toast message from within the micro frontend so it can be displayed by the shell app. It is an object with
toastproperty with a callback value. To use this prop,integrateToastmust be set totrue.
Beispiel
jutro: {
integrateJutro: true,
auth: authProps,
router: {
location: route,
onLocationChange: (location, action) => {
if (action === 'PUSH') {
history.push({
pathname: urlBase + location,
});
}
},
},
modal: {
showAlert,
showConfirm,
},
theme: {
themeConfig,
switchTheme,
},
toast: {
toast: ({ message }) => {
const elementToHoldToastMessage =
document.getElementById('toastMessage');
if (elementToHoldToastMessage) {
elementToHoldToastMessage.innerText = message;
}
},
},
configOverrides: {
customConfig: 'Micro-app overridden configuration',
localeSettings: {
availableLocales: ['en-US', 'es-ES'],
preferredLanguage: 'ES',
defaultCurrency: 'EUR',
},
},
onRender: () => { console.log('onRender'); },
onLoadingFinished: () => { console.log('onLoadingFinished'); },
onError: ({ error, errorInfo }) => {
console.error(error);
console.error(errorInfo);
}
}
Eigenschaften der MicroFrontend-Komponente
errorBoundaryComponent- Type
ReactComponentLikeDescriptionOptional error boundary component you wish to render instead of the default one in case a micro frontend throws an error.
jutro- Type
JutroPropsDescriptionAllows to set optional props to handle Jutro behavior, integrations, and overrides. To learn more about these props, check the section
<MicroFrontend>component jutro properties below. loaderComponent- Type
ReactComponentLikeDescriptionOptional loader component you wish to render instead of the default one when micro frontend assets are loading. See the Loader section for more details on the default component.
src- Type
MicroFrontendSrcDescriptionSpecifies the URL of the micro frontend. You can either use the micro frontend app ID along with the URI, for example
mfeAppId@urior use the functionmicroFrontendsConfigin yoursrc/config/config.json.
Alle unbekannten Eigenschaften werden als reguläre Eigenschaften an die Hauptkomponente des Micro Frontend übergeben.
Jutro-Eigenschaften der MicroFrontend-Komponente
configOverrides- Type
{ customConfig: string, localeSettings: {} }DescriptionAllows the shell app to inject custom configurations into the micro frontend's Jutro config object.
When the
JUTRO_NEW_CONFIG_LOADING_ORDERenvironment variable is set totrue, the config object has precedence over values in the.envfile. In the shell app, you can then useconfigOverridesto inject the values in the config object and they are applied to the micro frontend's configuration.When the
JUTRO_NEW_CONFIG_LOADING_ORDERenvironment variable is set tofalse, the.envfile has precedence over the Jutro config object.configOverridescan still inject values into the Jutro config object, but they're not visible if the same variables are also defined in the.envfile. iframeAttributes- Type
{allow?: string; referrerpolicy?: string; sandbox?: string}DescriptionAllows to pass additional attributes for micro frontends. Entries from
iframeAttributesprop are added to theiframeHTML element. This prop is only valid when the mode is set toisolatedoriframe(deprecated). integrateActions- Type
booleanDescriptionLets the shell know when reloading on the micro frontend side.
integrateAuth- Type
booleanDescriptionAllows the sharing of authentication information between the shell app and the micro frontend
integrateG11n- Type
booleanDescriptionAllows you to listen to globalization changes in the micro frontend.
integrateJutro- Type
booleanDescriptionEnables or disables the rest of
integrate*props. By default is set totrue. All theintegrate*props inherit theintegrateJutrovalue, this means that when it is set totruethe rest of theintegrate*props are set totrue. Then each of the props value can be manually overridden. integrateModal- Type
booleanDescriptionEnables the
modalintegration to trigger a modal from within the micro frontend so it can be displayed by the shell app. integrateQuickView- Type
booleanDescriptionAllows to enable/disable QuickView integration for micro frontends. This value can only be used when the mode is set to
sharedormoduleFederation(deprecated). integrateRouter- Type
booleanDescriptionAllows the
routerprop integration. integrateTheme- Type
booleanDescriptionAllows you to set the theme that the micro frontend uses. Once enabled, use the prop
themeto specify the theme to use. WhenintegrateThemeis set totrue, the shell and the micro frontend share a common theme. When set tofalse, the shell and the micro frontend use independent themes. integrateToast- Type
booleanDescriptionEnables the
toastintegration to trigger a toast message from within the micro frontend so it can be displayed by the shell app. When set totrue, assigns a single global toast provider and a toast trigger withtoast: ToastProvider.toastto the shell and all the micro frontends. If set tofalse, each micro frontend has its own toast provider. mode- Type
shared | isolated | moduleFederation (deprecated) | iframe (deprecated)DescriptionSets the MicroFrontend component mode for context sharing or context isolation. There are two modes available,
shared(previouslymoduleFederation) mode to enable context sharing andisolated(previouslyiframe) mode to enable context isolation. onRender- Type
funcDescriptionA function that is called when the micro frontend is rendered or updated.
router- Type
{basename?: string}DescriptionSets the current location of the micro frontend. Any change triggers the navigation on the micro frontend side.
timeout- Type
numberDescriptionThe app waits the specified time in milliseconds for the micro frontend to load. Note: Network errors such as
net::ERR_CONNECTION_REFUSEDget handled at the browser level. As there is no API to detect it, the only way to identify the error is to wait until the timeout handler shows an error view. Developers can identify the error in theNetworktab ofDeveloper Tools.
Beispiel
<MicroFrontend
src="claimMicroFrontend@http://localhost:3001"
exampleProp="Example prop"
loaderComponent={MyLoader}
errorBoundaryComponent={MyErrorBoundary}
jutro={{
mode: 'isolated',
iframeAttributes: {
allow: 'geolocation; camera "none"',
referrerpolicy: 'noreferrer',
sandbox: 'allow-scripts',
},
router: {
basename: '/welcome',
},
configOverrides: {
customConfig: 'Micro-app overridden configuration',
localeSettings: {
preferredLanguage: 'es',
},
},
}}
/>