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

For development purposes, the Next.js framework for SitecoreAI supports a `.env.local` file with [environment variables](https://nextjs.org/docs/basic-features/environment-variables), which is already configured to be ignored by Git.

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:

- `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`.

    > [!note]
    > **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](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). 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`.

    > [!note]
    > **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](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 `<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.

    > [!note]
    > **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](https://doc.sitecore.com/sai/en/developers/jss/215/jss-sai/enable-retries-for-requests-to-the-sitecoreai-experience-edge-graphql-endpoint.html "Enable retries for requests to the SitecoreAI Experience Edge GraphQL endpoint").
- `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/215/jss-sai/debug-logging-in-jss-apps.html "Debug logging in JSS apps").
- `FETCH_WITH` - the way that layout and dictionary data is [fetched from Sitecore](https://doc.sitecore.com/sai/en/developers/jss/215/jss-sai/switch-between-rest-and-graphql-in-next-js-jss-apps.html "Switch between REST and GraphQL in Next.js JSS apps"). 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 set to `true` at build time and runtime for improved efficiency and stability.