Upgrade JSS 22.11 Next.js apps to version 22.12
This topic covers the changes you must make to your existing JSS 22.11 applications to upgrade to version 22.12. However, because of the nature of JavaScript and Next.js application development, this topic doesn't account for all the customization you might have in your existing application.
While upgrading, consider the JSS templates and add-ons you used when creating your Next.js application. You can find them in your package.json file. For example, a JSS 22.11 application included in the XM Cloud starter foundation uses the following templates and add-ons:
-
nextjs -
nextjs-styleguide -
nextjs-sxa -
nextjs-multisite
Some code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.
-
If you haven't already done so, upgrade your app to JSS 22.11.
-
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.jsonupdate every@sitecore-jsspackage to version~22.12.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.js 24 upgrade guide.
-
Next.js has been updated to version 16. You may need to apply changes not mentioned here to your app based on the Next.js 16 upgrade guide.
NoteIf you see type errors related to
JSX.Element(for example, in components likeCdpPageView), add the following import where you useJSX.Element:
-
-
Install the dependencies with the following command:
Create a JSS 22.12 Next.js application
To simplify the upgrade process as much as possible, create a JSS 22.12 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 JSS 22.12 Next.js application with the XM Cloud add-on included:
-
In a console, run the following command:
-
If prompted to install the
[email protected]package, answery. -
Enter the folder path for the JSS 22.12 Next.js app. For example, enter ./jss2212, to create the app folder in your current working directory.
-
Follow the remaining prompts, selecting the same options for data fetching (
GraphQLorREST) and prerendering (SSGorSSR) as in your existing application. -
When asked if you are building for Sitecore XM Cloud, answer
yto install the XM Cloud add-on. -
Select other add-ons used by your existing application and press Enter.
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 JSS 22.12 app.
To update the Next.js template files:
-
Middleware has been renamed to proxy to better reflect its purpose. Rename
src/middleware.tstosrc/proxy.ts. To update your implementation:-
Modify its export function so that it no longer accepts the
evparameter: -
Modify method signatures in
/src/lib/middleware/index.tsso that it no longer usesNextFetchEvent: -
Remove all imports of
NextFetchEvent.
-
-
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.
-
Update the XM Cloud add-on
To update the XM Cloud add-on:
Some code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.
In the FEAASScripts.ts file:
-
Find the
convertToRegexfunction: -
Replace it with the following:
Update the SXA add-on
To update the SXA add-on:
-
Remove the
sass-aliasdependency: -
Modify
/src/lib/next-config/plugins/sass.js:-
Find all the
sass-aliasimports: -
Replace it with the following:
-
Add a new function called
createAliasImporter: -
Modify the
sassPluginexport to use the new implementation:
-
Next steps
To finalize the upgrade process, make sure you resolve any errors and warnings you encounter. Enable debug logging for JSS specific issues to assist you if necessary.