As Sitecore continues its evolution toward a fully composable and cloud-native architecture, theĀ Content SDK for XM CloudĀ marks a significant shift from the legacy JSS SDK. The Content SDK simplifies development, enhances performance, and introduces modern patterns for integrating Sitecore content into front-end applications.
In my previousĀ blog postĀ on theĀ Sitecore XM Cloud Content SDK, I discussed the key differences between theĀ JSS SDKĀ and theĀ Content SDK, along with some of the new concepts introduced in the Content SDK.
In today’s blog, I’ll walk you through how you can smoothly migrate your project to theĀ Content SDK.
Prerequisites
Before you begin, make sure to:
-
Upgrade your existing app toĀ JSS 22.8.
-
Review theĀ Content SDK changelogĀ to understand major updates.
-
Note that any customizations in your app may require additional migration effort.
-
Identify templates and add-ons used (
nextjs,Ānextjs-xmcloud,Ānextjs-sxa,Ānextjs-multisite) from yourĀ package.jsonĀ file.
Key Changes in the Content SDK
-
Page Editor Only:Ā Experience Editor is no longer available.
-
Centralized Configuration Files:
-
sitecore.config.tsĀ for app configuration. -
sitecore.cli.config.tsĀ for CLI configuration.
-
-
New API:Ā
SitecoreClientĀ replaces old REST/GraphQL services. -
Middleware Handling:Ā
defineMiddlewareĀ replaces middleware plugins. -
Component Handling:Ā
component-mapĀ replacesĀcomponentBuilder.
Update Application Dependencies
To update your application dependencies:
-
In your existing appāsĀ package.json, make the following changes:
-
ReplaceĀ
"@sitecore-jss/sitecore-jss-nextjs"Ā withĀ"@sitecore-content-sdk/nextjs", and update all references accordingly. -
Delete theĀ
"@sitecore-jss/sitecore-jss-cli"Ā dependency. -
Delete theĀ
"@sitecore-jss/sitecore-jss-dev-tools"Ā dependency.
-
-
Install the dependencies:Ā npm install
Create a Template Content SDK App
To create a newĀ Next.js Content SDKĀ application:
-
Run the following command in your terminal:
-
Use the same prerendering mode (SSGĀ orĀ SSR) as your current app.
-
This new template app will serve as yourĀ referenceĀ for migration.
Update the Next.js Template Files in Your Existing App
Update Configurations
Follow these steps to update your JSS app configuration:
-
Copy theĀ
sitecore.config.tsĀ file from your template app to your existing app. -
Replace all imports of config fromĀ
temp/configĀ and use the newĀsitecore.config.tsĀ file.
Example:should be replaced with
-
A newĀ pageĀ parameter has been added toĀ
SitecoreContext.
To support this, set theĀapiĀ parameter to useĀscConfig.apiĀ and include theĀpageĀ parameter in the following files:-
[[...path]].tsx -
500.tsx -
404.tsx
Update the code as shown below:
-
Update Environment Variables
Refactor Components and Interfaces
Several files in your Next.js app need adjustments. Refactor components, interfaces, and utilities to align with the new Content SDK structure.
-
CopyĀ
src/components/SitecoreStyles.tsxĀ from your template app into the same folder in your existing JSS app. -
InĀ
Layout.tsx, import it as follows:
Update References
-
SitecoreContextĀ āĀSitecoreProvider
Interfaces
-
SitecoreContextPropsĀ āĀSitecoreProviderProps -
SitecoreContextStateĀ āĀSitecoreProviderState -
SitecoreContextReactContextĀ āĀSitecoreProviderReactContext -
WithSitecoreContextOptionsĀ āĀWithSitecoreOptions -
WithSitecoreContextPropsĀ āĀWithSitecoreProps -
WithSitecoreContextHocPropsĀ āĀWithSitecoreHocProps
Higher-Order Components
-
useSitecoreContext()Ā āĀuseSitecore() -
withSitecoreContext()Ā āĀwithSitecore()
Properties
-
contextĀ āĀpage -
updateSitecoreContextĀ āĀupdatePage -
sitecoreContextĀ āĀpage
Methods
-
getServerSidePropsĀ /ĀgetStaticPropsĀ āĀgetComponentServerProps
Update Service References and Imports
Final Clean-Up
Remove all obsolete or replaced code and files as per the official documentation.
This includes legacy GraphQL, dictionary, layout, page-props, and middleware utilities now managed by the Content SDK.
Finally, ensure you:
-
Resolve all errors and warnings during migration.
-
EnableĀ debug loggingĀ for Content SDK to identify any runtime issues.
Conclusion
Migrating from theĀ JSS SDKĀ to theĀ Content SDKĀ is a necessary step toward leveraging the full power ofĀ XM Cloud.
The new SDK simplifies configuration, reduces dependency complexity, and offers improved integration with the XM Cloud ecosystem.
While the migration process involves several structural updates, following this guide step by step will help you transition smoothly and ensure your application is ready for the modern Sitecore experience.