1. JavaScript Services SDK (JSS) for Next.js

Next.js for SitecoreAI environment variables

Version:

For development purposes, the Next.js framework for SitecoreAI supports a .env.local file with environment variables, which is already configured to be ignored by Git.

The following are the supported variables for Next.js for SitecoreAI:

  • PUBLIC_URL - the public URL for absolute URLs, which are required when the Next.js app is run within Sitecore Editors. As your public endpoint changes, update these values accordingly. This is a SitecoreAI system environment variable. When the application runs on the SitecoreAI rendering host, this value is always set to your rendering host instance, and it will override any value set in your .env file. For example, https://<xmc_cm_host>.sitecorecloud.io.

    XM Cloud is now SitecoreAI

    Some code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.

  • JSS_EDITING_SECRET - a secret token that protects the Sitecore editor endpoint (/api/editing/render) exposed by the Next.js app. We recommend an alphanumeric value of at least 16 characters. This client-side value must match the server-side value, as set in the /sitecore/config/<SITE_NAME>.config file. This is a SitecoreAI system environment variable.

  • SITECORE_API_KEY - your Sitecore API key, needed for GRAPH_QL_ENDPOINT authentication. For Experience Edge, you can find the API key in the Sites dashboard by opening the actions menu for a site and navigating to Settings > Developer settings. Copy the value for SITECORE_API_KEY. For a preview endpoint (a CM instance either on SitecoreAI or locally), use your SitecoreAI preview API Key. This is a SitecoreAI system environment variable. When the application runs on the SitecoreAI rendering host, this value is always set to your Sitecore Services Client API Key, and it will override any value set in your .env file.

  • SITECORE_API_HOST - your Sitecore API hostname, needed to build the application. This is a SitecoreAI system environment variable. When the application runs on the SitecoreAI rendering host, this value is always set to your content management instance, and it will override any value set in your .env file. For example, https://<xmc_cm_host>.sitecorecloud.io.

    XM Cloud is now SitecoreAI

    Some code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.

  • GRAPH_QL_ENDPOINT - the Sitecore GraphQL endpoint. For Experience Edge, the value is https://edge.sitecorecloud.io/api/graphql/v1. For a preview endpoint (a CM instance on SitecoreAI or a local one), the value is <xmc_cm_host>/sitecore/api/graph/edge. This is a SitecoreAI system environment variable. When the application runs on the SitecoreAI rendering host, this value is always set to the preview endpoint for your CM instance <xmc_cm_host>/sitecore/api/graph/edge , and it will override any value set in your .env file.

    XM Cloud is now SitecoreAI

    Some code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.

  • JSS_APP_NAME - the name of your JSS app. This variable overrides the config.appName defined in the package.json file. You can find this value on the Sites dashboard by opening the actions menu for a site and navigating to Settings > Developer settings.

  • DEFAULT_LANGUAGE - the default language of your app.

  • GRAPH_QL_SERVICE_RETRIES - the number of times the GraphQL Layout, Dictionary, and ErrorPages services retry to fetch when the endpoint rate limit is reached. See how to enable retries for requests to the SitecoreAI Experience Edge GraphQL endpoint.

  • DEBUG - Sitecore JSS NPM packages utilize the debug module for logging. You can use the debug mode flexibly.

  • FETCH_WITH - the way that layout and dictionary data is fetched from Sitecore. The possible values are REST and GraphQL. You select the value during the app scaffold process. If the value isn't provided, the default is GraphQL.

  • DISABLE_SSG_FETCH - indicates whether, during static site generation (SSG), getStaticPaths pre-renders any pages. This is a SitecoreAI system environment variable. When the application runs on the SitecoreAI rendering host, this value is always set to true at build time and runtime for improved efficiency and stability.

If you have suggestions for improving this article, let us know!