---
title: "Next.js for SitecoreAI environment variables"
slug: "next-js-for-sitecoreai-environment-variables"
abstract: "Control important parameters of your SitecoreAI app using environment variables."
---
# Next.js for SitecoreAI environment variables

Starting from JSS version 21.6, the `SITECORE_EDGE_CONTEXT_ID` variable (Context ID) replaces many environment variables that were previously required. However, you must continue to use certain variables when developing locally in a full-stack scenario (since Context ID does not apply). The following sections contain the variables used in each environment type.

The following are the [supported variables for Next.js](https://github.com/Sitecore/jss/blob/release/21.0.0/packages/create-sitecore-jss/src/templates/nextjs/.env) for SitecoreAI:

| Variable name | Description | Usage |
| --- | --- | --- |
| `SITECORE_EDGE_CONTEXT_ID` | The [Context ID](https://doc.sitecore.com/xmc/en/developers/xm-cloud/en/context-id-environment-variables.html), which covers many system configurations required for connecting to the SitecoreAI back end. This is a SitecoreAI system environment variable. When the application runs on the SitecoreAI rendering host, this value is always set to the preview Context ID. | Environments connected to SitecoreAI, local front-end development |
| `SITECORE_API_KEY` | The API key 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](https://doc.sitecore.com/xmc/en/developers/xm-cloud/en/set-up-the-graphql-ides-to-test-content.html#UUID-64a8ce3c-7e9e-4e48-92f6-572088d17523_section-idm4576350245500833774923876875). 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. | Local full-stack development with a local Docker Sitecore environment |
| `SITECORE_API_HOST` | > [!important]<br>> Per-rendering host API keys are deprecated. To authenticate requests to SitecoreAI environments, [use Context IDs](https://doc.sitecore.com/sai/en/developers/sitecoreai/context-id-environment-variables.html).<br><br>The API hostname, needed to build the application. 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://<sitecoreai_cm_host>.sitecorecloud.io`. | Local full-stack development with a local Docker Sitecore environment |
| `GRAPH_QL_ENDPOINT` | The GraphQL endpoint. For Experience Edge, the value is `https://edge.sitecorecloud.io/api/graphql/v1`. For a [preview endpoint](https://doc.sitecore.com/xmc/en/developers/xm-cloud/en/the-architecture-of-experience-edge.html#UUID-538ccae9-1c01-a559-6890-ef9ed6bd5fa6_section-idm1403257543391544) (a CM instance on SitecoreAI or a local one), the value is `<sitecoreai_cm_host>/sitecore/api/graph/edge`. When the application runs on the SitecoreAI rendering host, this value is always set to the preview endpoint for your CM instance `<sitecoreai_cm_host>/sitecore/api/graph/edge` , and it will override any value set in your `.env` file. | Local full-stack development with a local Docker Sitecore environment |
| `PUBLIC_URL` | > [!important]<br>> This environment variable is only needed if you're using the [older, chromes-based editing mode](https://doc.sitecore.com/sai/en/developers/jss/22/jss-sai/editor-integration-using-chromes.html) for Pages. If you're using the [newer, metadata-based editing mode](https://doc.sitecore.com/sai/en/developers/jss/22/jss-sai/editor-integration-using-metadata.html), you can omit this variable.<br><br>The public URL for absolute URLs required for static assets when the Next.js app runs in an editing environment. 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://<sitecoreai_cm_host>.sitecorecloud.io`. This variable is required only to support Sitecore editors, so in non-editing environments, it needs to be *set to empty string* to have relative URLs. Also, if defined, `PUBLIC_URL` takes precedence over the Vercel/Netlify environment variables (used in Vercel/Netlify deployments), so the values of these variables must be adjusted as needed. |  |
| `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_SITE_NAME` | The name of your site. This variable overrides the `config.appName` defined in the `package.json` file. You can find this value in 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](https://doc.sitecore.com/sai/en/developers/jss/216/jss-sai/enable-retries-for-requests-to-the-sitecoreai-experience-edge-graphql-endpoint.html).<br><br>Default: 3 |  |
| `FETCH_WITH` | Determines how layout and dictionary data is [fetched from Sitecore](https://doc.sitecore.com/sai/en/developers/jss/22/jss-sai/switch-between-rest-and-graphql-in-next-js-jss-apps.html). 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](https://github.com/Sitecore/jss/blob/release/21.0.0/packages/create-sitecore-jss/src/templates/nextjs/src/pages/%5B%5B...path%5D%5D.tsx#L65). This is a SitecoreAI *system environment variable*. When the application runs on the SitecoreAI rendering host, this value is always `true` at build time and runtime for improved efficiency and stability. |  |
| `DEBUG` | Sitecore JSS NPM packages utilize the [debug module](https://www.npmjs.com/package/debug) for logging. You can [use the debug mode flexibly](https://doc.sitecore.com/sai/en/developers/jss/217/jss-sai/debug-logging-in-jss-apps.html). |  |