Upgrade Content SDK 0.1.0 Next.js apps to version 0.2.0
This guide covers most of the changes you must make to your existing Content SDK 0.1.0 applications to take advantage of the improvements in version 0.2.0. However, because this process also involves updating React to version 19 and Next.js to version 15, you'll need to refer to the relevant guides for each framework to complete the upgrade process for your apps.
This version of Content SDK adds a new disableStaticPaths property to scConfig. As a result, you no longer need to directly refer to the process.env.DISABLE_SSG_FETCH variable.
It's now optional to pass a configuration object to the defineConfig function in the Sitecore config file. All required config properties that are not given values will now fetch values from corresponding environment variables or, if those variables are not defined, the properties will use their default values instead.
New 0.2.0 apps, such as the one we recommend you create as part of the upgrade process, include a sitecore.config.ts.example file that you can use to help you create and define your own app's config.
Because of the nature of JavaScript and Next.js application development, this guide doesn't account for all the customization you might have in your existing application.
-
If you have a JSS app that you want to convert into a Content SDK app, follow the migration guide before you upgrade the 0.1.0 app to 0.2.0.
-
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 will need to update dependencies.
To update your dependencies:
-
In your existing application's
package.jsonfile:-
Update every
@sitecore-content-sdkpackage to version0.2.0. -
Update the following packages to the specified versions:
RequestResponse"next": "^15.3.1", "react": "^19.1.0", "react-dom": "^19.1.0", "@types/react": "^19.1.2", "@types/react-dom": "^19.1.3", "eslint-plugin-react": "^7.37.5", "typescript": "~5.7.3"
-
-
Install the dependencies with the following command:
RequestResponsenpm install
Create a template 0.2.0 Content SDK application for Next.js
To simplify the upgrade process as much as possible, create a Content SDK 0.2.0 Next.js application with the XM Cloud add-on. You can then copy some files from this app into your existing app.
To create a 0.2.0 Content SDK Next.js application with the XM Cloud add-on included:
-
In a console, run the following command:
RequestResponsenpx @sitecore-content-sdk/[email protected] nextjs -
If prompted to install the
@sitecore-content-sdk/[email protected]package, answer y. -
Enter the folder path for the new app. For example, enter
./content-sdk-020, to create the app folder in your current working directory. -
When prompted, choose the same prerendering method (
SSGorSSR) as used in your existing Content SDK application.
The script then installs the application dependencies.
Some code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.
Update the Next.js template files in your existing app
This explains how to synchronize files in your existing application with corresponding files from your new Content SDK 0.2.0 template app.
To update the Next.js template files:
-
In any file that imports form utilities from
@sitecore-content-sdk/core/form, amend the import statement to use@sitecore-content-sdk/coreinstead. -
If you have not customized the
next.config.jsfile, replace it with the version in your template app. Otherwise, add the following extra properties to yoursassOptionsconfiguration:RequestResponsesassOptions: { ... quietDeps: true, silenceDeprecations: ["import", "legacy-js-api"], }, -
For every component that uses the
JSXnamespace (for example, if aJSX.Elementtype is present), add aJSXimport fromreact.-
In the
src/Bootstrap.tsxfile, the existingreactimport might look like this:RequestResponseimport { useEffect } from 'react'; -
In which case, add
JSXto create the following:RequestResponseimport { useEffect, JSX } from 'react';
-
-
If you have not customized the
sitecore.config.tsfile, replace it with the version in your template app. Otherwise, do the following:-
Add a new empty export to the end of the file, as shown in the following example:
RequestResponseexport default defineConfig({ // Your existing export ... }); export default defineConfig();TipThe
defineConfigincluded as part of earlier Content SDK versions is no longer required here because passing config properties is no longer mandatory. If any of these properties are not given explicit values, they will use the value of the corresponding environment variables or, if those are not defined, they will revert to default values. -
If your customizations affect your existing export statement and are still needed, make sure you implement equivalent customizations in the new, empty
defineConfigfunction. -
Delete the old
defineConfigexport, leaving only the import statement, the new export statement, and your customizations.
-
-
If you have not customized the
src/assets/sass/components/_component-column-splitter.scssfile, replace it with the version in your template app. Otherwise, do the following:-
Locate the following padding rules:
RequestResponsepadding-left: $default-padding / 2; padding-right: $default-padding / 2; -
Replace those rules with the following:
RequestResponsepadding-left: $default-padding * 0.5; padding-right: $default-padding * 0.5;
-
-
If you have not customized the
src/middleware.tsfile, replace it with the version in your template app. Otherwise, delete all references toclientFactory. For example:-
Imports such as this:
RequestResponseimport { createGraphQLClientFactory } from '@sitecore-content-sdk/nextjs/client'; -
Assignments such as this:
RequestResponseconst clientFactory = createGraphQLClientFactory({ api: scConfig.api }); -
Any usage in the
personalizeandredirectsmiddleware constructors.
-
-
Replace your existing app's
src/pages/api/robots.tsfile with the version in your template app. -
In any file that directly references the
process.env.DISABLE_SSG_FETCHenvironment variable, replace that reference to use the newscConfig.disableStaticPathsproperty instead.-
For example, in your
[[...path]].tsx,404.tsx, and500.tsxfiles, locate the following condition:RequestResponseif (process.env.DISABLE_SSG_FETCH?.toLowerCase() !== 'true') { ... } -
Replace it as follows:
RequestResponseif (!scConfig.disableStaticPaths) { ... }
-
-
In your app's
package.jsonfile, replace the following scripts with updated versions:Existing script
Updated script
"sitecore-tools:build": "sitecore-tools build","sitecore-tools:build": "sitecore-tools project build","start:connected": "cross-env NODE_ENV=development npm-run-all --serial sitecore-tools:build next:dev","dev": "cross-env NODE_ENV=development npm-run-all --serial sitecore-tools:build next:dev","start:production": "cross-env-shell NODE_ENV=production npm-run-all --serial build next:start""start": "cross-env-shell NODE_ENV=production npm-run-all --serial build next:start" -
Use the framework-specific upgrade guides to make the necessary changes to your application for the latest versions:
TipFor any affected files that you've not customized in your existing app, you can save time by replacing them with the versions in your 0.2.0 template app.
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.