Upgrade JSS 22.7 Next.js apps to version 22.8
JSS SDK 22.8 includes support for the Design Library for early access users. The Design library is a centralized interface designed to help teams visualize and test components across their organization. This topic covers most of the changes you must make to your existing JSS 22.7 applications to take advantage of the new features in version 22.8. 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.7 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.7.
-
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-jsspackage to version~22.8.0. -
Update every
@sitecore-feaas/clientsidepackage to version^0.6.0. -
Update every
@sitecore/componentspackage to version~2.1.0.
-
-
Install the dependencies with the following command:
Update the Next.js template files in your existing app
After updating your dependencies, you must synchronize files in your existing application.
To update the Next.js template files:
-
Modify
src/lib/page-props-factory/plugins/preview-mode.ts:-
Update the
@sitecore-jss/sitecore-jss-nextjs/editingimport statement to includeisDesignLibraryPreviewData: -
Add the following import statements:
-
Find the following line:
Immediately after it, paste this code block:
-
-
Modify
/src/Bootstrap.tsx:-
Add
RenderingTypeto the@sitecore-jss/sitecore-jss-nextjsimport statement, as shown in the following example: -
After the
pageStateconstant declaration, add the following: -
Modify the
pageStatecondition to include arenderingTypecheck as shown in the following example:
-
-
Modify
src/lib/page-props-factory/plugins/component-themes.ts.-
Add the following import statement:
-
Update the
execfunction to usegetDesignLibraryStylesheetLinksinstead ofgetComponentLibraryStylesheetLinks, as shown in the following example:
-
-
Modify
src/Layout.tsx:-
Edit the
@sitecore-jss/sitecore-jss-nextjsimport statement and addDesignLibraryandRenderingType: -
Paste the following code block after the constant declarations.
-
Find the following
div: -
Replace the existing contents of the
divwith the following line:
-
-
Modify
SitecoreContextinsrc/pages/404.tsxandsrc/pages/500.tsxto includeapisettings:
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.