Backstage
    Preparing search index...

    Module @backstage/frontend-dynamic-feature-loader

    Core API used by Backstage frontend apps.

    @backstage/frontend-dynamic-feature-loader

    Backstage frontend feature loader to load new frontend system plugins exposed as module federation remotes. The frontend feature loader provided in this package works hand-in-hand with the server of frontend plugin module federation remotes server which is part of backend dynamic feature service in package @backstage/backend-dynamic-feature-service.

    NOTE: The new frontend system that this package is relaying upon is in alpha, and we do not yet recommend using it for production deployments

    • To enable this loader, you should:

      • Enable the backend dynamic features in your backend application, as explained in the backend-dynamic-feature-service README.md file

      • Install the @backstage/frontend-dynamic-feature-loader package in your frontend app:

        yarn --cwd packages/app add @backstage/frontend-dynamic-feature-loader
        
      • Add the frontend feature loader to the list of features when creating the frontend application:

        import { dynamicFrontendFeaturesLoader } from '@backstage/frontend-dynamic-feature-loader';

        const app = createApp({
        features: [...someOtherFeatures, dynamicFrontendFeaturesLoader()],
        });

    A dynamically loaded frontend plugin can expose either a FrontendFeature or a FrontendFeatureLoader as the default export of an exposed entry point. When a FrontendFeatureLoader is exported, this package returns it to the application's frontend feature resolution. The application framework invokes the loader with the ConfigApi and resolves its returned features, including nested feature loaders.

    This allows a plugin to select or configure its frontend features using the application configuration while keeping that selection logic within the plugin.

    Adding a frontend plugin (with new frontend system support, possibly in alpha support), is straightforward and consists in:

    • bundling the frontend plugin with the backstage-cli package bundle command, thus producing a self-contained bundle based on Module Federation.
    • copying the bundle folder into the Backstage installation dynamic plugins root folder for dynamic loading.

    So from a my-backstage-plugin frontend plugin package folder, you would use the following command:

    yarn backstage-cli package bundle --output-destination /path/to/dynamic-plugins-root
    # Creates a self-contained bundle in the /path/to/dynamic-plugins-root/my-backstage-plugin/ sub-folder
    DynamicFrontendFeaturesLoaderOptions
    dynamicFrontendFeaturesLoader