Environment Variables
#
Environment variables for your front-end appThese are the environment variables that can be used with the Next.js / Nuxt applications.
#
Required environment variablesUNIFORM_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_token
query string.For example:
.../map.json?uniform_token={UNIFORM_API_TOKEN}
This value must match the value defined in Sitecore as either
Uniform.API.Token
setting, orUniform.API.Token
connection string orUNIFORM_API_TOKEN
environment 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_site
query 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 variablesUNIFORM_MODE
=preview
ormixed
Default 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
=none
orfake
orazureblob
orcustom
Default Value:
none
.Defines the publish provider to use in all Deployment requests,
none
is the same asfake
and corresponds to the FakePublishProvider that does not do anything except reporting success and preventing.temp/{ticket}
folder from being deleted (ifUNIFORM_OPTIONS_DEBUG
is off).azureblob
stands forAzureBlobPublishProvider
and it requires extra configuration to work.custom
stands forCustomPublishProvider
allows 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 (
1
ortrue
oryes
value):- 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:
.temp
Allows 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
fetchRetry
fromfetch-retry
lib used server-side when requestingmap.json
file during site deployment requests.UNIFORM_PUBLISH_PREFETCH_REQUEST_TIMEOUT
= millisecondsDefault Value:
10000
(10 seconds)Allows changing the default timeout used by
fetchRetry
fromfetch-retry
lib used server-side when fetching content from Uniform APIs during preview and deployment requests
#
Advanced environment variablesThese 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 string
Replaces
UNIFORM_API_URL
during 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:
true
Allows 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 themaster
database, 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:
false
Allows enabling (
1
ortrue
oryes
value) 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
=export
orssr
Default Value:
ssr
, controlled by Uniform plugin.- when set to
export
: instructs Next.js app to run in SSG mode withnext build && next export
outputting static articacts to theout
folder. - when set to
ssr
: instructs the Next.js app to work in the SSR mode.
- when set to
#
Setting defaultsThe 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 runtimeDepending 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.