Create Storefront Next in Business Manager with Local Code
Create a storefront and its dependent API and Managed Runtime (MRT) resources in Business Manager with the local CLI option to generate and store your code locally.
- A developer B2C Commerce instance or on-demand sandbox (ODS) instance. See Create On-Demand Sandboxes for B2C Commerce in Salesforce Help.
- Managed Runtime User or Managed Runtime Admin role in Account Manager.
- Business Administrator role in Account Manager or a role for the Business Manager Module and Organization context with read-write access to storefronts. See Create a Role in B2C Commerce in Salesforce Help.
- The prerequisites for creating storefront code with the CLI. See the prerequisites in Explore Storefront Next Code Locally.
- Storefront setup supports only one storefront per site. A site can’t be associated with more than one storefront.
- If storefront setup fails, you must delete and recreate the storefront.
-
In Business Manager, click App Launcher
and then select Administration > Sites > Storefronts > New. -
Select Storefront Next.
-
Enter the storefront name. For example,
my-local-storefront. -
Select a site. You can select one or more sites for your storefront. For this task, select one site.
You can assign a site to one storefront only. You can’t reuse it for another storefront.
-
Select Salesforce CLI to generate the storefront code manually.

-
Click Start Setup.
-
After setup completes, in Source Code, click Download .env from the completion page to download the
env.txtenvironment file. It contains your storefront’s configuration, Business Manager settings, and your Account Manager and Shopper Login and API Access Service (SLAS) credentials.
For your security, the client secrets are available for download only once and are deleted on subsequent downloads. You use the Account Manager and SLAS client credentials to run the storefront locally. When you run the storefront on MRT, MRT uses the autocreated environment variables.
-
To view the storefront on MRT, click the view icon next to the environment.

-
To view details about the autocreated environment, in the Environments section, click the environment name. The new environment links to deployments, environment variables on MRT, and shows the eCDN routing rules for the default domain.
Setup created an MRT project and sent an initial deployment of the storefront. The deployed bundle is a generated storefront that mirrors the storefront you generate with the CLI.
-
To view the deployment on MRT, from the storefront page in Business Manager, click Manage in the Deployments section. Verify that the setup process created an MRT project and environment and sent an initial deployment of the storefront app. To view the deployment on MRT, click Managed Runtime Environment.

-
To generate the storefront code, type this command in a terminal window.
a. Provide the same storefront name you used earlier. For example,
my-local-storefront.The storefront corresponds to a project in MRT. The autogenerated project ID, which is based on the storefront name, identifies your project in MRT. You set the project ID in a later step from the downloaded environment file.
b. For the Storefront Next UI template, select
Salesforce B2C Commerce Retail Storefront.c. For the extensions, press Enter to accept the selected extensions.
d. Accept the defaults for the client IDs and the B2C Commerce instance values. You overwrite the configuration with your own storefront environment file in the next steps.
-
Open the project folder in an IDE, and then open the environment file:
{project-folder}/.env. -
Replace the contents of
{project-folder}/.envwith the contents of the downloadedenv.txtfile, which contains values specific to the new storefront and the B2C Commerce instance.The MRT project has a name and an ID, which are different. The
env.txtfile contains the MRT project ID. -
Make sure that your site’s search indexes are up-to-date. For more information, see Generate Search Indexes in Salesforce Help.
-
In a terminal window, go to the storefront folder.
-
Install Storefront Next project dependencies that are specified in
package.json. -
Build the storefront.
-
Run the development server.
-
Open the development server URL shown in the output to view the storefront in the browser. For example, the URL with the default port is
http://localhost:5173.