What You are Going to Learn
In this tutorial, you will become familiar with the first steps in building a website in XM Cloud. You will learn:
- How to create a new Site in your XM Cloud environment
- How to initialize your Next.js application in your local development environment
- How to connect a Next.js application to your hosted XM Cloud environment
Overview
In XM Cloud, a site is a collection of one or more pages, and a page can have several components. Through this tutorial series we will be creating a new Company Dev site and building out pages and components for the site. You will use the XM Cloud tools and your local development environment to explore the creation of a new site.
In this tutorial you wil do the following:
- Create a new site in XM Cloud
- Download and initialize your Next.js application
- Connect your Next.js application to your XM Cloud instance
- Verify that your connection is working by changing some content and viewing the updated content in your Next.js application
Prerequisites
In order to complete the following tutorial, you will need these resouces:
- A valid organization login for the Sitecore Cloud portal
- The XM Cloud environment created in the Setup XM Cloud tutorial.
- The GitHub repo created in the Setup XM Cloud tutorial.
- An IDE such as Visual Studio (VS) Code.
- A valid XM Cloud license file.
If you haven't already downloaded a license file, refer to the docs on downloading your organization's license file from the portal.
Create the site
With the environment initially created, you can now create your first site in XM Cloud. This will verify that the authoring environment is working and you can start the base of your project that will be used in these tutorials.
-
To begin, open the Sitecore Cloud Portal (https://portal.sitecorecloud.io) and log in.
-
You can access XM Cloud via the XM Cloud Deploy app through the “Go to XM Cloud” button
If you closed that screen already you can also access XM Cloud from the Sitecore Cloud Portal. Click the “Open app” button on the top right.
-
Under the Sites tab, click
Create site
. -
In the New site step you will choose a site template. Choose
Basic Site
.You can choose to create an Empty Site, or a Basic Site that already has some content in it. When creating your own websites outside the scope of this tutorial or as a quick demo, we recommend using the Empty Site, as it requires less cleanup than the Basic Site template. However, for this tutorial, you will select to use the basic site.
-
Name the site
Company Dev
and select a pre-configured language, in this case,English
.In the screenshot and in your dialog you will also see another option where you can select an existing Site identifier, or create a new one. This is required when connecting Sitecore CDP, the Customer Data Platform for embedded analytics and personalization. We will skip that step for now and start the creation process of the site.
-
Click
Create site
, which will scaffold the website in the background. This will take a few minutes.Once your site is scaffolded in the background, you can access it using XM Cloud Pages and start editing the content.
-
Click on the website, which opens up a WYSIWIG editor where you can begin to edit the content, see components that you can use to edit the site, and switch between languages and your sites (top navigation bar).
Download and initialize your Next.js app
You will now get your local application running and connected to XM Cloud. You will need to navigate to your GitHub account and download the repository that was cloned in the previous tutorial by the Sitecore XM Cloud Deploy App.

Download Repository
- In your repositories overview, find the newly created
xm-cloud-tutorial-series
repo. - Download the repository to your local file system.
- Open the newly created folder in VS Code, or your text editor of choice.
- As per the README, run the init script that was delivered with your source code repository and pass the following parameters:
-LicenseXmlPath
: the path to your XM Cloud license file-AdminPassword
: the admin password of your XM Cloud instance (“b”, in this case).
The init script initializes the .env
file with everything necessary.

A note on passwords: You can use any password and will of course have to use a secure password when dealing with client projects. But for now we use “b”, for tradition’s sake.
Connect the App to the XM Cloud Instance
As you may remember from the introduction in the previous tutorial, you need to use a GraphQL endpoint to query the content coming from XM Cloud. To connect to the endpoint, a few things need to be configured up front.
-
Navigate to the
.env
file within your solution under src\sxastarter, and copy it. -
Name it
.env.local
. We do this so that the file is ignored by git by default, so that you do not pass valuable configuration secrets into any repositories.
You can connect using the delivery endpoint of Edge or to the preview endpoint of your CM instance.

Any app showing content to the public must connect to the Edge Delivery Endpoint that is scaled and geographically distributed to serve the right performance. Only published content will be available here. For development purposes, you will connect to the preview endpoint as you do not need to care about publishing at this point, so created content is instantly available. This will simplify the development workflow. If you want to learn more about endpoints and the edge delivery architecture, check out the docs on Experience Edge architecture
Now, you need to set the API key within .env.local
. The API key should be already available within your XM Cloud instance.
-
Get the Context ID from XM Cloud by:
- Go to the XM Cloud deploy app
- Click on the name of the project you created e.g.
XM Cloud Tutorial Series
- Copy the value in the
Context ID (Preview)
column
-
Paste the value of the Context ID into the
SITECORE_EDGE_CONTEXT_ID
environment variable in the.env.local
file. -
Add the Site name (e.g.
Company dev
) to theSITECORE_SITE_NAME
environment variable in the.env.local
file. -
In your terminal navigate to src/sxastarter (your app folder) and run
npm install
-
Now run
npm run start:connected
-
Call your app in the browser: http://localhost:3000
Verify the connection
Let’s change some content to verify you are in fact connected against the preview endpoint.
- Navigate back to your site in XM Cloud.
- Click on the tile that says
Company Dev
. This will open Pages new WYSIWYG page editing experience. When opening for the first time, this might take a moment. - Change the headline to whatever you like. In this case, I’ll add 'in town' to the homepage tagline.
- Your changes are autosaved.
- Switch back to the browser tab where you are viewing the Next.js app on http://localhost:3000
- Reload the page, and see the changes appear in your local app.
Congratulations! You have successfully set up your dev environment with XM Cloud and created your first site! To learn more about XM Cloud and continue on to next steps, check out our next tutorial in this series.
Related XM Cloud Documentation
- Getting started with XM Cloud
- Create websites
- Design webpages
- Understanding components in XM Cloud
- Working with languages
- Working with Pages
- Publishing in XM Cloud
- JSS GraphQL API