Getting Started with Sitecore Content SDK for XM Cloud

 


Sitecore has announced the release of the Content SDK. The Content SDK helps developers integrate XM Cloud content with their front-end applications. It is set to replace the existing JSS SDK for XM Cloud. This new Content SDK will exclusively support XM Cloud, providing a cleaner and more streamlined solution.

In this blog, I’ll discuss the key features of the Content SDK, how to install it locally, and how to connect it with an XM Cloud instance for local development.


Key Features

  • Starter Template: Provides a ready-to-use Next.js template for fast project setup and seamless integration.

  • Framework-Specific Support: Leverages Next.js features like locale-based routing for multilingual sites, plus multiple rendering modes including SSR (server-side rendering) and SSG (static site generation).

  • GraphQL Utilities: Includes prebuilt queries to fetch content, layouts, site information, and dictionary data directly from Sitecore APIs.

  • Multi-Site Capabilities: Supports running and managing multiple independent websites from a single environment.

  • Personalization & Testing: Enables audience-based personalization and A/B/n component testing without custom code, making it simple to deliver tailored experiences and run experiments across visitor segments.

  • Analytics Integration: Offers built-in analytics and event tracking through the Sitecore Cloud SDK.

  • XM Cloud Pages Integration: Works seamlessly with XM Cloud Pages for visual authoring, component editing, and experience testing.

Prerequisites

  • Access to an XM Cloud instance.

  • Ensure you have the latest version of Node.js installed on your machine. It’s recommended to use the latest Long-Term Support (LTS) version.

  • A suitable IDE, such as Visual Studio Code.

Getting Started with Content SDK Installation

  1. Create a folder where you want to install the Content SDK.

    • For example: create a folder named Content SDK POC.

    • Open your terminal and execute the following command:
      npx @sitecore-content-sdk/create-sitecore-jss nextjs


  2. If prompted to install the create-sitecore-jss package, type Y to confirm.


  3. When asked, provide the folder path for your new app. You’ll also be asked to choose a rendering strategy between SSG (Static Site Generation) and SSR (Server-Side Rendering).


  4. Installed Successfully. 


Install Content SDK CLI

The Content SDK CLI provides various commands to work with Content SDK applications. By installing this tool globally, you can use these commands while developing any Content SDK applications on your local machine, such as when creating new components.

To install, run:

npm install -g @sitecore-content-sdk/cli



Once installed, the following folder structure will be generated on your file system.



Connecting to an XM Cloud Instance

To connect the app to the XM Cloud instance:

  1. Retrieve the required environment variables from the deployment portal.

  2. Create a .env.local file in the root folder of your newly created app.

  3. Add the environment variables into the .env.local file.


After setting up the environment variables, open a terminal, navigate to the Content SDK app’s folder, and run the following commands:

npm install

npm run start

Conclusion

The Sitecore Content SDK for XM Cloud offers a streamlined way to bring XM Cloud content into modern front-end applications. With its Next.js starter template, GraphQL utilities, CLI support, and seamless integration with XM Cloud Pages, it empowers developers to deliver scalable, personalized, and high-performing digital experiences. Whether using static generation or server-side rendering, the Content SDK provides a strong foundation to accelerate your headless Sitecore development journey.

References

Comments

Popular posts from this blog

Setup New Project in Sitecore XMCloud – Part 1

Step by Step installation of Sitecore 10.3 on Azure PaaS

Step by Step installation of Sitecore 10.3 on Docker