Environment Variables
Environment variables for your front-end app#
These are the environment variables that can be used with the Next.js / Nuxt applications.
Required environment variables#
UNIFORM_API_URL= URL valueDefines the base URL to use in all Uniform content APIs (Map and Page Service, for example). Typically, this will point to your Sitecore instance. If the ContentSync feature is enabled, this can point to a blob storage account with the cached blobs of Uniform API.
For example:
{UNIFORM_API_URL}/uniform/api/content/...UNIFORM_API_TOKEN= secretDefines the security token to use in all Uniform content APIs and will be appended to the
uniform_tokenquery string.For example:
.../map.json?uniform_token={UNIFORM_API_TOKEN}This value must match the value defined in Sitecore as either
Uniform.API.Tokensetting, orUniform.API.Tokenconnection string orUNIFORM_API_TOKENenvironment variable.UNIFORM_API_SITENAME= string valueDefines the name of Site Configuration (configured in Sitecore) to use in all the Uniform content API requests (Map and Page Service).
For example:
.../uniform/api/content/{UNIFORM_API_SITENAME}/...When used with Sitecore JSS, this value set the
sc_sitequery string that is used in the Layout Service requests. For example:.../sitecore/api/layout/render/jss?sc_site={UNIFORM_API_SITENAME}...UNIFORM_API_KEY= guid of Sitecore API key item idThisĀ isĀ usedĀ forĀ SitecoreĀ JSSĀ solutions and specifies the API Key that will be used for the Sitecore Layout Service requests. Required (for Sitecore JSS based solutions only).
Optional environment variables#
UNIFORM_MODE=previewormixedDefault Value:
mixed- When set to
mixed, it enables the deployment service and SSR functionality. - When set to
preview, it disables the ability to handle site deployments within next/nuxt server, useful for when running a Preview service or SSR for JSS Rendering Host to support Experience Editor.
- When set to
UNIFORM_PUBLISH_TARGET=noneorfakeorazurebloborcustomDefault Value:
none.Defines the publish provider to use in all Deployment requests,
noneis the same asfakeand corresponds to the FakePublishProvider that does not do anything except reporting success and preventing.temp/{ticket}folder from being deleted (ifUNIFORM_OPTIONS_DEBUGis off).azureblobstands forAzureBlobPublishProviderand it requires extra configuration to work.customstands forCustomPublishProviderallows running custom shell script to upload files.
Top tip for production environments we recommend configuring this setting in Sitecore.
UNIFORM_OPTIONS_DEBUG= bool valueDefault Value:
false.When enabled (
1ortrueoryesvalue):- enables verbose logging in the console
- prevents deleting
.temp/{ticket}folders after when generating HTML files and publishing them.
UNIFORM_PUBLISH_TEMP_DIR= string valueDefault Value:
.tempAllows changing the default temp directory used when generating HTML files and publishing them.
UNIFORM_PUBLISH_MAP_REQUEST_TIMEOUT= millisecondsDefault Value:
90000(90 seconds)Allows changing the default timeout used by
fetchRetryfromfetch-retrylib used server-side when requestingmap.jsonfile during site deployment requests.UNIFORM_PUBLISH_PREFETCH_REQUEST_TIMEOUT= millisecondsDefault Value:
10000(10 seconds)Allows changing the default timeout used by
fetchRetryfromfetch-retrylib used server-side when fetching content from Uniform APIs during preview and deployment requests
Advanced environment variables#
These variables are all optional and reserved for special use only and not recommended to be used in production unless specifically instructed by our support team.
UNIFORM_CONTENT_URL= URL valueDefault Value:
empty stringReplaces
UNIFORM_API_URLduring the deployment requests for the scope of that deployment operation only.UNIFORM_API_MAPSERVICE= URL valueDefault Value:
/uniform/api/content/{UNIFORM_API_SITENAME}/map.json?uniform_token={UNIFORM_API_TOKEN}Allows changing the default URL that full-site deployment requests will use to get the list of all pages.
UNIFORM_OPTIONS_PREVIEW= bool valueDefault Value:
trueAllows disabling preview mode parameter (
uniform_preview=true) during Uniform API requests in preview mode. Allows using the database defined in the Site Configuration instead of themasterdatabase, which is used by default in preview. To disable, set it to any value other than1,true, oryes.UNIFORM_OPTIONS_PREFETCH_LINKS= bool valueDefault Value:
falseAllows enabling (
1ortrueoryesvalue) links prefetching for near-instant page switch when pure React presentation is used. Renders<link rel="preload" as="fetch" ... />in<head>for every SmartLink rendered on the page.UNIFORM_BUILD_MODE=exportorssrDefault Value:
ssr, controlled by Uniform plugin.- when set to
export: instructs Next.js app to run in SSG mode withnext build && next exportoutputting static articacts to theoutfolder. - when set to
ssr: instructs the Next.js app to work in the SSR mode.
- when set to
Setting defaults#
The starter kits come with the uniform.config.js file that allows setting some of these values as defaults.
You can leverage this pattern to extend which environment variables are defined as defaults here.
const dotenv = require("dotenv");
const defaults = { UNIFORM_API_SITENAME: "uniform-mvc-kit", UNIFORM_PUBLISH_TARGET: "none", UNIFORM_MODE: "mixed"};
function processDefault(key, fallback) { if (!key) { return null; } process.env[key] = process.env[key] || fallback;}
module.exports = function () { dotenv.config(); Object.keys(defaults).forEach((k) => processDefault(k, defaults[k]));};
Overriding the Environment Variables at runtime#
Depending on the use case, you may need to override the value of a certain environment variable at runtime (during site deployment), and therefore the values will be scoped to a given deployment operation.
This allows supporting multi-site environments where the value of UNIFORM_API_SITENAME can be provided when the site deployment service is triggered.
This also means that your Next/Nuxt app can run with minimal configuration and source most of the values from Sitecore.