Steps to Consider: Connect JSS Next.js Project with Sitecore XM Cloud
In this blog, I will show how you can connect your local JSS Next.js App with XM Cloud Deploy. If you are wondering how to setup NextJs App with XM Cloud then do visit this blog.
Please note, this blog refers to
some steps which I have done previously while setting up my site on the portal.
I would suggest you to just a have look into steps so that you can understand
the further stated steps better.
Since we will be running our
local instance with XM Cloud, it would be better to create any component, lets
say XM Cloud Component using component builder, and bind on home page to confirm
and test the changes.
If you are seeking to know How to
create a component in XM Cloud then follow this guide.
Prerequisites
- You must have cloned your NextJs app on your machine.
- Nodejs/Git must be installed.
- Any code editor, Visual Studio Code preferred.
- Site must be created on XM Cloud Portal.
Exploring XM Cloud Deploy
Lets begin with grabbing the environment variables which will
be used while setting up our project Next.js JSS App.
Step 1: Login into your XM Cloud Project and Click XM Cloud
Deploy Option
Remember, you can simply click on XM Cloud Deploy, you don't
have to select your site.
Step 2: Click on your project
Note: You would see ellipses on most of the items, keep on looking into options available as they might be needed in further setups.
Step 3: Viewing environment list
If you have setup your project, then you might know that at
some point XM Cloud setup asks you about naming your environment. That same
value will be visible here.
So click on the Development option.
Step 4: Manage your environment
Note: By default, the environment which you have created is
binding with Master Branch in git or azure. In case if you want to change the
branch then it can be done at this level.
In that case, click on options and select env to another
branch
Step 5: Linking environment to another branch (Optional)
You will notice, the branches you created in the project
repo are visible here. Hence, I have changed the branch from master to develop
with auto deployment option.
Step 6: Goto Developer Settings
This is a very important step because there are
configuration changes between JSS version before 21.5 and after 21.6
Below is for JSS 21.5 and earlier version.
So, How you can check your version?
Goto your source code, and find package.json file
Step 7: Grab the Environment Variable values
Since, I am using the latest version of JSS, so grab the SITECORE_EDGE_CONTEXT_ID, SITECORE_SITE_NAME and JSS_EDITING_SECRET values.
Step 8: Create XM Cloud Component
This topic i have already covered in another blog, which you can follow here.
Below is how home page is looking in XM Cloud Page Builder:
Step 9: Configure Next.js Project
Comments
Post a Comment