The Context ID environment variable
The Context ID environment variable simplifies setting up and configuring XM Cloud solutions. It's a unified identifier that maps to all your configured resources, such as content, sites, files, forms, and integration settings. You include the Context ID in your development setup, and XM Cloud handles the rest. Context ID also handles potential future system configurations added to the XM Cloud solution, saving you additional configuration to support new features or integrations.
When you create an environment in XM Cloud, two context identifiers are created automatically:
-
Live Context ID - provides access to content published to Experience Edge using the Delivery API. Use this Context ID for production sites.
-
Preview Context ID - provides access to all content, including drafts and unapproved content in your XM Cloud environment, using the Preview API.
To simplify application setup, the JavaScript Rendering SDK (JSS) for Next.js includes support for the Context resources through the XM Cloud addon.
Context ID is available only from JSS version 21.6 or later. If you are using an earlier JSS version, to start using Context ID, follow the upgrade guide.
Getting your Context IDs
You can copy both the live and preview context identifiers from the Deploy app. You can find them:
-
In the Projects tab, in the Environments table of the relevant project. Copy the value you need, Context ID (Preview) or Context ID (Live).
-
In the Environment details tab. Copy the Context ID (Preview) or Context ID (Live) .
-
In the Developer settings tab. The Context ID is the value of
SITECORE_EDGE_CONTEXT_ID
.
Regenerate a Context ID
When you regenerate a Context ID, all apps and services using the old Context ID will need to be updated with the new Context ID. You'll also need to redeploy the environment.
To permanently revoke a Context ID and generate a new one, you can regenerate a Context ID. You might do this when someone has unauthorized access to your Context ID.
To regenerate a Context ID:
-
In the Environment details tab, click Regenerate.
-
In the Regenerate Context IDs dialog, copy and save your current Context IDs. After regenerating the Context ID, you can search your code for instances of the old Context ID and replace it with the new one.
-
Click Regenerate.
Next steps
After regenerating a Context ID, the apps and services that use the old Context ID will not work. You need to:
-
Redeploy the environment associated with your Context ID.
-
Replace the revoked Context ID with the new Context ID in all relevant apps and services.
For example, the
SITECORE_EDGE_CONTEXT_ID
in your.env.local
file that you created when you set up your local development environment. Or if you've deployed your app to Vercel, the SITECORE_EDGE_CONTEXT_ID variable.