Upgrade JSS 22.1 Next.js apps to version 22.3
This topic covers most of the changes you must make to your existing JSS 22.1 applications to benefit from the latest improvements in version 22.3. 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.1 application might use the following templates and add-ons:
-
nextjs -
nextjs-styleguide -
nextjs-multisite
-
If you haven't already done so, upgrade your app to JSS 22.1.
-
Upgrade Node to version 22 or later.
-
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 be 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 the following packages to the stated versions:-
Update every
@sitecore-jsspackage to version~22.3.0. -
Update the following packages to the stated versions:
Table 1.Package
New version
@types/node^22.9.0@typescript-eslint/eslint-plugin^8.14.0@typescript-eslint/parser^8.14.0eslint^8.56.0typescript~5.4.0
-
-
Install the dependencies with the following command:
RequestResponsenpm install -
In
.eslintrc, add the following rule or modify your existing rule to match:RequestResponse"@typescript-eslint/no-unused-vars": [ "error", { "caughtErrorsIgnorePattern": "." } ], -
In
tsconfig.json, directly above the"lib"entry, add the following:RequestResponse... "types": ["node"], ...
Create a JSS 22.3 Next.js application
To simplify the upgrade process as much as possible, create a JSS 22.3 Next.js application. You can then copy some files from this app into your existing app.
To create a JSS 22.3 Next.js application:
-
In a console, run the following command:
RequestResponsenpx [email protected] nextjs -
If prompted to install the
[email protected]package, answer y. -
Enter the folder path for the JSS 22.3 Next.js app. For example, enter
./jss223, 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 n to skip installing the XM Cloud add-on.
-
Select other add-ons used by your existing application and press Enter.
The script then installs the application dependencies.
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.3 app.
To update the Next.js template files:
-
If you have not customized the
scripts/config/plugins/scjssconfig.tsfile, replace it with the 22.3 version. Otherwise, modify your file as follows:-
Locate the following code:
RequestResponsetry { scJssConfig = require('scjssconfig.json'); } catch (e) { ... -
Modify it by adding an ESLint rule override as follows:
RequestResponsetry { // eslint-disable-next-line @typescript-eslint/no-require-imports scJssConfig = require('scjssconfig.json'); } catch (e) { ...
-
-
If you have not customized the
scripts/generate-component-builder/index.tsfile, replace it with the 22.3 version. Otherwise, modify your file as follows:-
Locate the following rule:
RequestResponse// eslint-disable-next-line @typescript-eslint/no-var-requires -
Replace it with the following:
RequestResponse// eslint-disable-next-line @typescript-eslint/no-require-imports
-
-
If you have not customized the
scripts/scaffold-component/index.tsfile, replace it with the 22.3 version. Otherwise, modify your file as follows:-
Locate the following rule:
RequestResponse// eslint-disable-next-line @typescript-eslint/no-var-requires -
Replace it with the following:
RequestResponse// eslint-disable-next-line @typescript-eslint/no-require-imports
-
-
If you have not customized the
scripts/config/index.tsfile, replace it with the 22.3 version. Otherwise, modify your file as follows:-
Locate the following rule:
RequestResponse// eslint-disable-next-line @typescript-eslint/no-var-requires -
Replace it with the following:
RequestResponse// eslint-disable-next-line @typescript-eslint/no-require-imports
-
-
If you have not customized the
scripts/utils.tsfile, replace it with the 22.3 version. Otherwise, modify your file as follows:-
Locate the following:
RequestResponsecb && cb(name); -
Replace it with the following:
RequestResponseif (cb) cb(name);
-
Update the Nextjs-styleguide add-on
To upgrade the Nextjs-styleguide add-on:
-
If you have not customized the
src/lib/sitemap-fetcher/plugins/disconnected-sitemap-service.tsfile, replace it with the 22.3 version. Otherwise, modify it as follows:-
Locate the following rule:
RequestResponse// eslint-disable-next-line @typescript-eslint/no-var-requires -
Replace it with the following:
RequestResponse// eslint-disable-next-line @typescript-eslint/no-require-imports
-
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.