Upgrade from Cloud SDK version 0.3 to 0.4
Cloud SDK version 0.4 introduces new initialization logic. If you're upgrading from version 0.3 or earlier, follow this walkthrough to upgrade your initialization code. The version 0.3 initialization logic will be deprecated and removed in a future Cloud SDK release.
The majority of your upgrade work involves installing the latest Cloud SDK packages and replacing old init
function calls with new CloudSDK
ones. You'll also set the sc_{SitecoreEdgeContextId}_personalize
cookie manually, which previous SDK versions set automatically if you opted in to setting cookies.
This walkthrough assumes that you have Cloud SDK version 0.3 or earlier installed in your JSS Next.js application.
This walkthrough describes how to:
-
In your code editor, open the root folder of your web app.
Install the latest @sitecore-cloudsdk packages
The first step to upgrading is to install the latest @sitecore-cloudsdk
packages, including a new package called core
. The core
package contains the new initialization logic. You'll set up the new logic in a later procedure.
To install the latest packages:
-
In your code editor, in the root folder of your application where your JSS Next.js app dependencies are installed, open the terminal.
-
To install version 0.4 of the
core
package and any other Cloud SDK packages you currently use in your app, run the following commands:RequestResponsenpm install @sitecore-cloudsdk/[email protected] npm install @sitecore-cloudsdk/[email protected] npm install @sitecore-cloudsdk/[email protected]
-
In
package.json
, check that the Cloud SDK packages are now version0.4
.
Import the CloudSDK function and other SDK modules
The core
package contains a browser
and a server
module. Each module contains a new CloudSDK
function. This function initializes the SDK when you run its initialize
method, and the function also allows you to initialize other SDK packages. The initialize
method runs the initialization logic and sets cookies.
Depending on your application requirements, use the browser
module to initialize the SDK on the browser side, or use the server
module to initialize it on the server.
Rework the init function into CloudSDK code
After making the necessary imports, your app still runs instances of the old init
function, usually one for each Cloud SDK module your app uses. For example, if your app uses the events/browser
, events/server
, and personalize/browser
modules, your application code contains three instances of init
. In this procedure, you replace all init
code with new code that uses the CloudSDK
function.
Next steps
You've now successfully upgraded to the Cloud SDK version 0.4 initialization logic. You can now start your app to check that the Cloud SDK runs. You can also remove the code related to the old init
function that you have previously commented out.
Next, you can:
-
Learn more about the SDK initialization process.
-
Explore the reference documentation for the
core
package. -
Learn more about what changed in Cloud SDK version 0.4 in the release notes.