Set up your storefront
This tutorial provides detailed instructions for setting up and using ÃÛ¶¹ÊÓÆµ Commerce Storefront powered by Edge Delivery Services to create a performant, scalable, and secure Commerce storefront powered by data from your ÃÛ¶¹ÊÓÆµ Commerce Optimizer instance.
automatically. Then, you can use these instructions to understand how the storefront was created, and learn more about the components available to you.
Prerequisites
-
Ensure that you have a GitHub account (github.com) that can create repositories and is configured for local development.
-
Learn about the concepts and workflow to develop Commerce storefronts on ÃÛ¶¹ÊÓÆµ Edge Delivery Services by reviewing the Overview in the ÃÛ¶¹ÊÓÆµ Commerce Storefront documentation.
-
Set up your development environment
Set up your development environment
Install Node.js and the Sidekick browser extension required to develop and test your ÃÛ¶¹ÊÓÆµ Commerce Optimizer storefront on Edge Delivery Services.
Install Node.js
Install Node Version Manager (NVM) and the required Node.js version (22.13.1 LTS).
-
Install Node Version Manager (NVM).
code language-bash curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
-
Install Node.js and NPM. For more information, see .
code language-bash nvm install 22
code language-bash npm install -g npm
-
Verify the installation.
code language-bash npm -v
Install Sidekick
Install the Sidekick browser extension to edit, preview, and publish content to the storefront. See .
Create your storefront
The storefront you create for your ÃÛ¶¹ÊÓÆµ Commerce Optimizer project uses a customized version of the ÃÛ¶¹ÊÓÆµ Commerce on Edge Delivery Services Storefront boilerplate. The boilerplate is a set of files and folders that provide a starting point for storefront development. This setup process is different than the standard setup process for an ÃÛ¶¹ÊÓÆµ Commerce on Edge Delivery Services Storefront.
Workflow overview
Follow these steps to set up a storefront to use with ÃÛ¶¹ÊÓÆµ Commerce Optimizer.
- Create a code repository–Create a GitHub repository from the ÃÛ¶¹ÊÓÆµ Commerce + Edge Delivery Services boilerplate template. Include all branches from the source repository.
- Update the storefront boilerplate–Update the custom boilerplate template on the
aco
branch to connect your content folder to the storefront. - Deploy changes–Overwrite the code on the
main
branch with the updated code from theaco
branch. - Add the CodeSync app–Connect your repository to the Edge Delivery Service. Do not connect the Code Sync app until you have completed the source code customization and have pushed the code to the
main
branch. - Add content–Use the demo content clone tool to create and initialize your storefront content in the Document Author environment hosted on
https://da.live
. - Preview demo site–Connect to your storefront site to view the sample content and data from the ÃÛ¶¹ÊÓÆµ Commerce Optimizer demo instance.
- Develop in your local environment–Install the required dependencies. Start the local development server, and update the storefront configuration to connect to the ÃÛ¶¹ÊÓÆµ Commerce Optimizer instance that ÃÛ¶¹ÊÓÆµ provisioned for you.
- Next steps–Learn more about managing and displaying content and data in the storefront.
Step 1: Create site code repository
Create a GitHub repository for the site boilerplate code for your storefront using the Edge Delivery Services + ÃÛ¶¹ÊÓÆµ Commerce Boilerplate template.
-
Log in to your GitHub account.
-
Navigate to the GitHub repository.
-
Select Use this template, and then select Create a new repository from the drop-down menu.
The repository configuration page displays.
-
Complete the configuration form with the following details:
- Repository template—
hlxsites/aem-boilerplate-commerce
(default). - Owner—Your organization or account (required).
- Repository name—A unique name for your new repo (required).
- Description—A brief description of your repo (optional).
- Public or Private—ÃÛ¶¹ÊÓÆµ recommends public (default).
- Repository template—
-
Select Create repository.
After several minutes, your new repository opens.
Ignore any pull request notifications displayed in the GitHub user interface.
Step 2: Update the storefront boilerplate
You need the following information to update the storefront boilerplate code:
-
GitHub repository URL from Step 2—
github.com/{ORG}/{SITE}
-
{ORG}
is the organization name or username for the repository -
{SITE}
is your repository name
-
-
Content folder URL from Step 1—
https://drive.google.com/drive/folders/{YOUR_FOLDER_ID}
{YOUR_FOLDER_ID}
is the ID of the folder that you created with the sample content data.
Link the repository to the Document Author environment
-
Clone the repository to your local machine.
code language-bash git clone https://github.com/{ORG}/{SITE}.git
If you encounter errors when cloning the repository, see in the GitHub documentation.
-
Open the repository in your terminal or IDE.
-
Create your configuration file by copying the
default-fstab.yaml
file tofstab.yaml
.code language-bash cp default-fstab.yaml fstab.yaml
-
Update the mountpoint in the storefront configuration file to point to your content URL.
-
Open the fstab.yaml configuration file.
code language-yaml mountpoints: /: url: https://content.da.live/{org}/{site}/ type: markup folders: /products/: /products/default
-
Replace the
{ORG}
and{SITE}
strings with the values for the GitHub repository that you created for your boilerplate code.For example, the updated code should look like this.
code language-yaml mountpoints: /: url: https://content.da.live/owner-name/aco-storefront/ type: markup
-
Save the file.
-
Configure the Sidekick extension
- Add the project configuration for the Sidekick extension. This configuration ensures that Sidekick is available to manage content for your storefront project.
-
Create a new directory
tools/sidekick
.code language-shell mkdir tools/sidekick
-
Copy the
demo-sidekick.json
file in the root directory to thetools/sidekick
directory and rename it toconfig.json
.code language-shell cp demo-sidekick.json tools/sidekick/config.json
-
Customize the Sidekick configuration for your site.
From
tools/sidekick/
directory, edit theconfig.json
file.accordion Sidekick configuration file code language-json { "project": "My Project", "editUrlLabel": "Document Authoring", "editUrlPattern": "https://da.live/edit#/{{org}}/{{site}}{{pathname}}" }
-
Update the
url
key values with the values for your GitHub repository.-
Replace the
{{ORG}}
string with the organization or username for your repository. -
Replace the
{{SITE}}
string with the repository name. -
The
pathname
variable is populated by the system.
accordion Example of updated configuration file If your GitHub repository is named
aco-storefront
and your organization isearly-adopter
, the updated URL should look like this:code language-json { "project": "My Project", "editUrlLabel": "Document Authoring", "editUrlPattern": "https://da.live/edit#/aco-storefront/early-adopter{{pathname}}" }
-
-
Save the file.
Step 3: Deploy changes
To use the customized storefront boilerplate code, overwrite the code on the main
branch with your updates.
-
From your editor or IDE, commit and save the files you updated.
code language-bash git add .
-
Verify that you are committing the two updated files.
code language-bash git status On branch main Your branch is up to date with 'origin/main'. Changes to be committed: (use "git restore --staged <file>..." to unstage) new file: fstab1.yaml modified: tools/sidekick/config.json
-
Commit the changes.
code language-bash git commit -m "Update storefront boilerplate for ÃÛ¶¹ÊÓÆµ Commerce Optimizer"
-
Apply your changes.
code language-bash git push
Step 5: Add the AEM Code Sync app
Connect your repository to the Edge Delivery Service by adding the AEM Code Sync GitHub app to your repository.
-
Open the configuration page.
-
Select Configure, then authenticate with the organization or account that contains the repository you created.
-
From the form, choose Only select repositories, and then select the repository you created.
-
Select Install to add the AEM Code Sync app to your repository.
You should see a message that the app was successfully installed.
Step 6: Add content
Create and initialize your storefront content in the Document Author environment hosted on https://da.live
using the Site Creator tool. This tool imports the sample content into the Document Author environment and completes the content preview and publish process for all documents in the sample content. The sample content includes the page layouts, banners, labels, and other elements to populate your storefront.
-
Open the
-
Confgure your repository:
- Select Use Existing Repository.
- Enter the Organization/Username for your storefront boilerplate project.
- Enter the Repository Name.
-
Import, preview, and publish the content to the Document Author environment by selecting Create site.
After the site is created, you can use the links in the Edit content and View Site sections to explore the demo storefront.
The main links to your content and site follow these formats:
- Root content folder—
https://da.live/#/{ORG}/{SITE}
- Site preview—
https://main--{SITE}--{ORG}.aem.page/
- Site production:—
https:/main--{SITE}--{ORG}.ae.live/
- Root content folder—
-
Open the root content folder link to view the content.
note tip TIP In the side navigation, use the Learn and Discover links to access learning resources for managing your site and site content.
Step 7: Preview demo site
Verify that both the sample content and the data from the ÃÛ¶¹ÊÓÆµ Commerce Optimizer demo instance are displayed correctly.
- Sample content is served from the content folder in the Document Author environment. It includes the page layouts, banners, and labels for your site.
- Sample data is served from the ÃÛ¶¹ÊÓÆµ Commerce Optimizer demo instance. Data includes product data with product attributes, images, product descriptions, and prices populated based on the header values specified in the storefront configuration file,
config.json
.
Connect to your site to view sample content and data
-
View your site by navigating to
https://main--{SITE}--{ORG}.aem.live
.Replace
{ORG}
and{SITE}
with the organization and name for your boilerplate repository.If the page returns a 404, verify the following:
-
View the sample catalog data coming from the Commerce Optimizer default instance.
-
In the storefront header, click the magnifying glass to search for
tires
. -
Press Enter to view the search results page.
The search results page components are defined by the
search
content document. The search results data is populated based on the storefront configuration inconfig.json
. -
View the product details page by selecting any tire product on the page.
The product details page components are defined by the
default
content document in theproduct
folder.
-
Step 8: Develop in your local environment
In this section, you update the storefront configuration from your local development environment.
- Update the storefront configuration to connect to the GraphQL endpoint for the ÃÛ¶¹ÊÓÆµ Commerce Optimizer instance that ÃÛ¶¹ÊÓÆµ provisioned for you.
- Update the header values to retrieve data from your instance.
Start local development
-
In your IDE, checkout your main branch, and reset it to the last commit on the remote branch.
code language-bash git checkout main git reset --hard origin/main
-
Install the required dependencies.
code language-bash npm install
-
Start the local development server.
code language-bash npm start
The first page of your boilerplate storefront should be visible in your browser at
http://localhost:3000
.
Update the storefront configuration
Update the storefront configuration file and preview the changes in your local development environment.
-
In your IDE, update the storefront configuration to connect to the ÃÛ¶¹ÊÓÆµ Commerce Optimizer instance that ÃÛ¶¹ÊÓÆµ has provisioned for you.
-
Open the
config.json
file. -
Update the following values using the endpoint for your ÃÛ¶¹ÊÓÆµ Commerce Optimizer instance:
-
commerce-endpoint
–Replace the existing value with your endpoint URL.code language-json "commerce-endpoint": "https://na1-sandbox.api.commerce.adobe.com/{tenantId}/graphql"
-
ac-environment-id
—Replace the existing value with the tenant ID from your endpoint URL.code language-json "ac-environment-id": "{tenantId}"
-
-
Save the file.
If your local preview is working correctly, the updates are applied to your local storefront.
-
-
Check the site to see the results of the configuration change.
-
In the browser, navigate to
http://localhost:3000
and refresh the page. -
In the storefront header, click the magnifying glass to search for
tires
. -
Press Enter to display the Search Results page.
The search doesn’t return any results because the header values in your storefront configuration file are based on the default instance. Now that the configuration points to the ÃÛ¶¹ÊÓÆµ Commerce Optimizer instance provisioned for you, those values are invalid.
-
Next steps
See the Storefront and Catalog Administrator end-to-end use case to learn more about managing and displaying content and data in the storefront.