Deploy Storefront Next to Managed Runtime (MRT)

To redeploy a storefront that was created in Business Manager after initial deployment, use the Storefront Next CLI and the autocreated MRT project and environment. Deploy a storefront with a user-based MRT API key or SCAPI Account Manager authorization.

If using the Developer Workspace beta, see Deploy Bundles in Business Manager (Beta).

  • Node Package Manager (pnpm) version 10.28.0 or later. See Installation on the pnpm site.
  • Node.js version 24.13.0 or later. See Download Node.js on the Node.js site.
  • To install Storefront Next dependencies specified in package.json, run the pnpm install command.
  • To save the MRT API key credentials using the B2C CLI, install the B2C CLI. See Agentic B2C Developer Toolkit.
  1. In Business Manager, navigate to your storefront. Click App Launcher App Launcher, then select Administration > Sites > Storefronts, and click your storefront.

  2. In the storefront detail page, click your environment, and then next to Deployments, click Manage.

  3. If you have an .env file in your storefront with the project ID (MRT_PROJECT) and environment ID (MRT_TARGET), skip this step. Otherwise, get these values from Runtime Admin.

    a. To get the environment ID, click Environment Settings, and copy the Environment ID value.

    b. To get the project ID, click the project name, then Project Settings, and copy the Project ID value.

  1. To authenticate the CLI to Managed Runtime, use an API key. Get the Managed Runtime API key in Managed Runtime Admin. In Account Settings, under Personal API Key:

    a. If you haven’t yet created an API key, click Generate.

    b. If you already have an API key, the value is partially masked. Click Reset, then click Reset my API Key when asked for confirmation.

    c. Run this command to save the API key locally in the ~/.mobify file so it can be reused whenever you run the pnpm sfnext push command. Replace the placeholder values in this command before running it.

    We recommend saving the MRT API key credentials. If you don’t save the MRT API key, you can add the API key in the MRT_API_KEY variable in the .env file or supply it in the --api-key argument on the command line. See MRT API Key in the Agentic B2C Developer Toolkit.

  2. From your local storefront folder, use this command to create a bundle and deploy it to your Managed Runtime environment. Replace the placeholders with the MRT project ID and target environment.

    Always run pnpm sfnext push from the local storefront folder. To run the push command from another folder outside your storefront, use pnpm dlx @salesforce/storefront-next-dev push instead and pass in the storefront folder path with --project-directory {sfnext-project-folder}.

    The .env file in your Storefront Next project folder contains environment variables that the Storefront Next CLI uses. You can set the project ID in the MRT_PROJECT variable and the target environment in the MRT_TARGET variable. If you specify these values in both the command line and the .env file, the command line arguments are used.

  3. Verify that the bundle was deployed to the target environment. In Managed Runtime Admin, in Projects, click your project and then your environment.

  1. Set up an Account Manager API client with the storefront-specific scopes. See Automate Storefront Administration with APIs. Note the Account Manager client ID and client secret (password) because you use them in the next step.

  2. Specify the B2C Commerce and MRT configurations in the local .env file for the sfnext CLI command to use. The Account Manager client that the Business Manager storefront setup creates doesn’t contain the scopes for the storefront, so be sure to specify the Account Manager client you created. To get B2C Commerce settings, go to Administration > Site Development > Salesforce Commerce API Settings.

    • SFCC_OAUTH_CLIENT_ID=Insert_Account_Manager_Client_Id
    • SFCC_OAUTH_CLIENT_SECRET=Insert_Account_Manager_Client_Secret These values are populated when you generate the storefront code using the CLI.
    • PUBLIC__app__commerce__api__organizationId=f_ecom_realm_instance
    • MRT_PROJECT=Insert_project_Id
    • MRT_TARGET=Insert_environment_Id

    If you don’t specify these configuration values in the .env file, pass them as command-line arguments for the pnpm sfnext push command: --client-id, --client-secret, --tenant-id, --short-code, --project, and --environment.

  3. From your local storefront folder, use this command to create a bundle and deploy it to the Managed Runtime environment. Replace the placeholders with the MRT project ID and target environment. The --mrt-backend scapi argument tells the CLI to use SCAPI for the deployment.

    Always run pnpm sfnext push from the local storefront folder. To run the push command from another folder outside your storefront, use pnpm dlx @salesforce/storefront-next-dev push instead and pass in the storefront folder path with --project-directory {sfnext-project-folder}.

  4. Verify that the bundle was deployed to the target environment. In Managed Runtime Admin, in Projects, click your project and then your environment.

If your B2C org is enrolled in the Developer Workspace beta, deploy new bundles from Business Manager and track the deployment progress and history. Before deploying a bundle, create it by following the steps in this page.

To only upload a bundle and not deploy it, omit the --environment argument from the CLI command and remove the MRT_TARGET variable from the .env file. Find the project ID in the downloaded .env file from the storefront detail page in Business Manager, or in the Complete Your Storefront task.

When this command completes, the bundle is uploaded and appears in Business Manager in Administration > Storefronts > Your Storefront > Bundles. Deploy it by clicking Deploy and selecting the environment.

The deployed bundle is displayed in the target environment page

To upload and deploy in one step, specify the environment ID in the --environment argument or in the MRT_TARGET variable in the .env file. The --wait argument waits for the deployment to complete before the command exits.

Use the mrt bundle commands to create and deploy bundles to an environment. See Automate Storefront Administration Tasks with the B2C CLI.