Upgrade Content SDK 1.5.1 Next.js apps to version 2.0
This guide covers most of the changes you must make to your existing Content SDK 1.5.1 applications to take advantage of the new features and improvements in version 2.0.0. However, because this process also involves updating Next.js to version 16 and Node.js to version 24, you'll need to refer to the relevant guides for each framework to complete the upgrade process for your apps.
This version of the Content SDK introduces tracking, events, and personalization capabilities, custom query parameters in editing render handlers, custom hostname support, and more.
Because JavaScript and Next.js development is very flexible and customizable, this guide provides only general instructions and might not cover the specific configurations, custom code, or architectural decisions present in your existing application.
-
Familiarize yourself with the changelog. If your application is heavily customized, the changelog can provide guidance on what additional changes you need that are not covered in this topic.
This topic describes how to:
Update application dependencies in your existing app
For your upgraded application to work correctly, you must update dependencies.
To update your dependencies:
-
In your existing application's
package.jsonfile, update every@sitecore-content-sdkpackage to version2.0.0. -
Update the following dependencies to the specified versions:
-
Node.js has been updated to version 24. You may need to apply changes not mentioned here to your app based on the Node 24 upgrade guide.
-
Next.js has been updated to version 16. See the Upgrade Next.js to version 16 section for further steps to complete the update:
-
Remove any dependencies that start with
@sitecore-cloudsdk/and add the following:See the Cloud SDK integration section for further steps to complete the update.
-
-
Install the dependencies with the following command:
Create a template 2.0.0 Content SDK application for Next.js
To simplify the upgrade process as much as possible, create a Content SDK 2.0.0 Next.js application. You can then copy some files from this app into your existing app.
To create a 2.0.0 Content SDK Next.js application:
-
In a console, run the following command:
-
If prompted to install the
[email protected]package, answery. -
When prompted, choose the same template as your existing app (
nextjsfor Pages Router andnextjs-app-routerfor App Router). -
Enter the folder path for the new app. For example, enter
./content-sdk-200, to create the app folder in your current working directory. -
When prompted, choose the same prerendering method (SSG or SSR) as used in your existing Content SDK application.
The script then installs the application dependencies.
Update your existing app
After updating your dependencies, you must synchronize files in your existing application. The following sections contains steps to complete the Next.js 16 upgrade, Cloud SDK integration, React 19 refactor, and updating other template files.
Upgrade Next.js to version 16
The Content SDK uses Next.js 16 starting from version 2.0. The following section describes the updates you must make for your app to work with Next.js 16:
-
Middleware has been renamed to proxy to better reflect its purpose. Rename
middleware.tstoproxy.tsor copy it from the template app. Instead of Next.js discovering your middleware automatically by filename, it now runs theproxy.tsfile directly. To update your implementation:-
Create
src/proxy.tsor rename your currentmiddleware.tsfile toproxy.ts. Add your proxy logic here. The file must export a single function (default export or namedproxy) that accepts aNextRequestand returns the result of the proxy chain as shown: -
Ensure that your proxy order is correct:
-
For Next.js apps using App Router - locale → multisite → redirects → personalize
-
For Next.js apps using Pages Router - multisite → redirects → personalize
-
-
When renaming your current
middleware.tsfile, you must replace the following import statements: -
Replace it with the following:
Ensure that you use the updated names in the initialization logic.
-
-
Individual API route files (for sitemap, robots, editing endpoints, health) still use the
Middlewareclasses to implement their actual behavior for those specific routes. Theproxy.tsfile only handles edge requests and routing behavior.Item
Description
For sitemap and robots.txt
Use
SitemapMiddlewareorRobotsMiddlewarefrom@sitecore-content-sdk/nextjs/middlewareEditing APIs
Use
EditingConfigMiddleware,EditingRenderMiddleware, orFEAASRenderMiddlewarefrom@sitecore-content-sdk/nextjs/editingHealthcheck
Use the
HealthcheckMiddlewarefrom@sitecore-content-sdk/nextjs/monitoring -
Next.js 16 expects you to define allowed external image sources using
remotePatternsinstead ofimages.domains. Remove all entries ofimages.domainsand useremotePatternsto allow Sitecore/media image URLs. You can refer the template app'snext.config.js|tsfile for more information.
Please refer to the official Next.js 16 upgrade guide to update other parts of your application that's not specific to the Content SDK.
Cloud SDK integration
The Content SDK has undergone a major architectural transformation to include functionality from the Cloud SDK. The Content SDK now includes tracking, events, and personalization.
To enable these changes:
-
In
Bootstrap.tsx:-
Find the CloudSDK initialization logic:
-
Replace it with the following:
-
Remove the following imports:
-
Add the following imports:
-
-
In
CdpPageView.tsx:-
Find the following import:
-
Replace it with the following:
-
You might also have to make further changes to other files that contains older Cloud SDK logic based on your implementation. See Initializing tracking, events, and personalization in the Content SDK for more information.
Refactor aligned with React 19 best practices
React logic in the Content SDK has been refactored to follow React 19 best practices. The following section outlines the breaking changes introduced by this refactor and provides examples of the new implementations.
-
The
@sitecore-content-sdk/reactpackage introduces the following updated types and signatures:-
useSitecore(options?: UseSitecoreOptions): SitecoreProviderState -
SitecoreProviderStatenow includes:-
page: Page -
api?: SitecoreProviderProps['api'] -
setPage?: (value: Page) => void(renamed from updatePage) -
componentMap: ComponentMap(new) -
loadImportMap: () => Promise<ImportMapImport>(new)
-
-
PlaceholderPropsis expanded to explicitly list all supported properties:
These updates make the context shape and placeholder behavior explicit and compatible with React 19 best practices, especially for server and client components. The additional fields (
componentMap,loadImportMap) support more flexible composition and lazy loading. To update your code:-
Review all imports and usages of
SitecoreProviderStateandPlaceholderProps. -
If you relied on implicit properties, update your type annotations to the new explicit interface.
-
If you used
updatePage, rename it tosetPage. -
If you previously inferred types from usage, consider importing the updated types from
@sitecore-content-sdk/reactto align with 2.0.
No runtime changes are required in this step beyond adjusting renamed fields.
-
-
The
withPlaceholderhigher-order component now only accepts the component as an argument and injects a placeholders prop derived fromprops.rendering.placeholders.To update your code:
-
Find implementations of a single placeholder:
-
Replace it with the following:
NoteWhen rendering the wrapper on a server component in Next.js App Router while using
withAppPlaceholder, you must still pass therendering,page, andcomponentMapprops: -
If you rely on a multi-placeholder mapping as shown:
-
Convert it as shown:
-
-
The
withSitecorehigher-order component is deprecated. The recommended alternative is theuseSitecorehook.To update your code, find the current implementation:
Replace it with the following:
NoteIf you continue using
withSitecore, theupdatePageprop it previously injected is now namedsetPage. -
PlaceholderandAppPlaceholderare stricter and now pass only the following props to the components rendered for a placeholder:-
Context properties (
page,componentMap) -
fields,paramsandrenderingdata
The
modifyComponentPropscallback is still available, but it should not be required for simple prop injection. For example, the following usage:Can be streamlined using
passThroughComponentPropsas shown: -
-
All built-in Content SDK components that previously relied on
React.forwardRef(such asRichText,Link, and others) now treatrefas a regular prop instead of usingforwardRef. This change follows React 19 recommendations best practices.
Please refer to the official React 19 upgrade guide to update other parts of your application that's not specific to the Content SDK.
Update Next.js template files
To update the Next.js template files:
-
In
sitecore.cli.config:-
Previously, all functions in the
buildarray of thedefineCliConfigoptions object accepted ascConfigproperty in their options object. This property is no longer required and is provided internally during build time. For example, the previous implementation forwriteImportMapcontained thescConfigproperty as shown:The rest of the configuration remains the same after removing the property:
-
-
The
renderEmptyPlaceholdermethod from thePlaceholderclass has been removed.If your implementation relies on that method for custom placeholders, you can use the
renderEmptyPlaceholderhelper method exported fromreactandnextjspackages. -
The
DesignLibrarycomponent no longer receives an import map as a prop. Instead, it is provided by theSitecoreProvidercomponent. For Content SDK apps based on Pages Router, theDesignLibrarycomponent is present insrc/Layout.tsxand must be updated: -
The
SitecoreProvidercomponent now requires theloadImportMapprop. Update theSitecoreProviderimplementation as shown: -
If your application currently depends on
SITECORE_EDGE_URL, remove all instances ofSITECORE_EDGE_URLfrom env files and deployment configurations. Set the following new variable(s) to the same value and restart the app. Rebuild for Next.js so thatNEXT_PUBLIC_*is in the client bundle.-
NEXT_PUBLIC_SITECORE_EDGE_PLATFORM_HOSTNAME- for Next.js projects so both server and client use the custom host. -
SITECORE_EDGE_PLATFORM_HOSTNAME- non Next.js or server only
NoteThe default value of
<https://edge-platform.sitecorecloud.io>is used unless you use the new variables.If you have explicitly configured
edgeUrlinsitecore.config, set it to the following:For non‑Next.js environments, mirror this pattern with the
SITECORE_EDGE_PLATFORM_HOSTNAMEvariable instead.NoteNewly scaffolded apps use
defineConfig({})and getedgeUrlfrom the new environment variable automatically, so you might not have theedgeUrlsection underedge. -
-
A new configuration option,
rewriteMediaUrlsis available insitecore.config. When set to true, the SDK inspects media URLs in the layout that are pointing to the production Experience Edge host (edge.sitecorecloud.io), and rewrites those URLs to use your custom host defined inSITECORE_EXPERIENCE_EDGE_HOSTNAME. The rewrite only targets the production Experience Edge host. -
By disabling React Suspense in placeholders, components render faster without the added Suspense overhead. However, if your app uses lazy-loaded components inside a
<Placeholder>and expects a loading fallback to appear, you need to perform the following steps while upgrading:-
Audit
<Placeholder>usages where dynamic or lazy components are rendered. -
Add
disableSuspense={false}to any placeholder that depends on Suspense-based loading states.
-
-
The
@sitecore-content-sdk/contentpackage has been decoupled from@sitecore-content-sdk/coreto create a more focused "core" that can be referenced by other packages. The following changes are only required if you directly import from@sitecore-content-sdk/core.-
The following submodules have been moved from
@sitecore-content-sdk/coreto@sitecore-content-sdk/content:Submodule
Old path
New path
client@sitecore-content-sdk/core/client@sitecore-content-sdk/content/clientcodegen@sitecore-content-sdk/core/codegen@sitecore-content-sdk/content/codegenconfig-cli@sitecore-content-sdk/core/config-cli@sitecore-content-sdk/content/config-cliconfig@sitecore-content-sdk/core/config@sitecore-content-sdk/content/configediting@sitecore-content-sdk/core/editing@sitecore-content-sdk/content/editingi18n@sitecore-content-sdk/core/i18n@sitecore-content-sdk/content/i18nlayout@sitecore-content-sdk/core/layout@sitecore-content-sdk/content/layoutmedia@sitecore-content-sdk/core/media@sitecore-content-sdk/content/mediapersonalize@sitecore-content-sdk/core/personalize@sitecore-content-sdk/content/personalizesite@sitecore-content-sdk/core/site@sitecore-content-sdk/content/siteUpdate all references to the old paths with the new ones.
-
All exports from the
utilssubmodule are now available from thetoolssubmodule. Update all references to the@sitecore-content-sdk/core/utilssubmodule and replace it with@sitecore-content-sdk/core/tools. -
The following types and functions have been moved from
@sitecore-content-sdk/coreto@sitecore-content-sdk/content:Item
Old path
New path
HTMLLinktype@sitecore-content-sdk/core@sitecore-content-sdk/contentStaticPathtype@sitecore-content-sdk/core@sitecore-content-sdk/contentdefineConfig@sitecore-content-sdk/core@sitecore-content-sdk/contentform@sitecore-content-sdk/core@sitecore-content-sdk/contentUpdate all references to the old paths with the new ones.
-
The following tools have been moved from
@sitecore-content-sdk/core/toolsto@sitecore-content-sdk/content/tools:Item
Old path
New path
generateSites@sitecore-content-sdk/core/tools@sitecore-content-sdk/content/toolsGenerateSitesConfig@sitecore-content-sdk/core/tools@sitecore-content-sdk/content/toolsGenerateMapFunction@sitecore-content-sdk/core/tools@sitecore-content-sdk/content/toolsGenerateMapArgs@sitecore-content-sdk/core/tools@sitecore-content-sdk/content/toolsextractFiles@sitecore-content-sdk/core/tools@sitecore-content-sdk/content/toolswriteImportMap@sitecore-content-sdk/core/tools@sitecore-content-sdk/content/toolsWriteImportMapArgs@sitecore-content-sdk/core/tools@sitecore-content-sdk/content/toolsUpdate all references to the old paths with the new ones.
-
The following utilities and types have been removed from
@sitecore-content-sdk/core/toolsas they are no longer relevant or unused:Item
Description
generatePluginsNo longer relevant
PluginDefinitionNo longer relevant
ModuleTypeNo longer relevant
tryParseEnvValueUnused utility
isAbsoluteUrlUnused utility
-
The default SXA rewrite logic has been changed to align with Next.js best practices for locale and to support the optional Shall language be preserved upon redirect? checkbox introduced in the Redirect Rules section in SitecoreAI. For example, earlier, when en is set as the default locale, URLs that do not specify a locale (like /my-page) resolves to that default locale. With this change, the same rule results in a redirect without the default locale if no locale is present. To continue using it as before, you must enable the Shall language be preserved upon redirect?.
Next steps
To finalize the upgrade process, make sure you resolve any errors and warnings you encounter. Enable debug logging for Content SDK specific issues to assist you if necessary.