1. Developer guides

The Sitecore configuration file

Version: 1.x

Content SDK's Angular implementation includes the sitecore.config.ts file, which is the central configuration point for your app, found in the app's root folder.

To access any value from the configuration file, you can import it into your code as shown in the following example:

import scConfig from 'sitecore.config'

Several of the properties described in this topic have a corresponding environment variable; where they do, that variable is listed here alongside the property's description. If a property is not given an explicit value, it will take the value from the corresponding environment variable where available. If a value is not defined in either place, the property will use a default value instead.

The base configuration

Property

Type

Description

Corresponding environment variable

api

object

Defines the data source for layout and content requests.

N/A

defaultSite

string

The default Sitecore site name used for content resolution.

CSDK_PUBLIC_SITECORE_DEFAULT_SITE

defaultLanguage

string

The fallback language used when no locale is specified. Populated from environment if unset. Defaults to 'en' when both are absent.

CSDK_PUBLIC_SITECORE_DEFAULT_LANGUAGE

editingSecret

string

Editing secret required by SitecoreAI editing and preview functionality. Provide this if you want to use your local or deployed application as an editing host.

SITECORE_EDITING_SECRET

api properties

Property

Type

Description

Corresponding environment variable

edge

object

Edge endpoint credentials used to connect to an instance of SitecoreAI.

N/A

local

object

API endpoint credentials used to connect to a local instance of SitecoreAI running in a Docker container.

N/A

edge properties

Property

Type

Description

Corresponding environment variable

contextId

string

The unique identifier used to connect to and retrieve data from your SitecoreAI instance.

SITECORE_EDGE_CONTEXT_ID

CSDK_PUBLIC_SITECORE_EDGE_CONTEXT_ID

clientContextId

string

Identifier used to connect to and retrieve data from your SitecoreAI instance in client-side operations.

SITECORE_EDGE_CLIENT_CONTEXT_ID

CSDK_PUBLIC_SITECORE_EDGE_CONTEXT_ID

edgeUrl

string

URL of the SitecoreAI endpoint that your Content SDK app will communicate with.

Default: https://edge-platform.sitecorecloud.io

CSDK_PUBLIC_SITECORE_EDGE_HOSTNAME

SITECORE_EDGE_PLATFORM_HOSTNAME

local properties

Property

Type

Description

Corresponding environment variable

apiKey

string

Your Sitecore API key used to connect to the GraphQL endpoint.

SITECORE_API_KEY

CSDK_PUBLIC_SITECORE_API_KEY

apiHost

string

Sitecore API hostname that your app will connect to and retrieve data from.

SITECORE_API_HOST

CSDK_PUBLIC_SITECORE_API_HOST

path

string

A GraphQL endpoint path that will be appended to apiHost to form a full endpoint URL, like apiHost/path.

N/A

Services configuration

These settings provide additional configuration for various Content SDK services.

Property

Type

Description

Corresponding environment variable

layout

object

Extra settings for the layout service.

N/A

dictionary

object

Extra settings for the dictionary service.

N/A

retries

object

Controls GraphQL request retry behavior.

N/A

layout properties

Property

Type

Description

Corresponding environment variable

formatLayoutQuery

function

Custom function to format the layout service query string.

Accepts siteName, itemPath, and optional locale. Set to null to disable.

N/A

dictionary properties

Property

Type

Description

Corresponding environment variable

caching

object

Configuration for local memory caching of dictionary service requests.

N/A

caching properties

Property

Type

Description

Corresponding environment variable

enabled

boolean

Whether local memory caching is used for the dictionary service.

N/A

timeout

number

The length of time, in seconds, to keep cached entries in local memory.

N/A

retries properties

Property

Type

Description

Corresponding environment variable

count

number

The maximum number of retries attempted by the GraphQL client if the first one fails. Set this to 0 if you don't want to use retries.

N/A

retryStrategy

RetryStrategy

Custom retry strategy implementation for the GraphQL client.

N/A

Extra middleware and other configurations

These settings configure functionality that is provided by middleware.

redirects

Property

Type

Description

Corresponding environment variable

enabled

boolean

Whether SXA redirect processing is enabled.

N/A

Note

In Content SDK for Angular, the locales property is not configurable under redirects. Redirect locale awareness is derived automatically from angular.locales at resolve time.

multisite

Property

Type

Description

Corresponding environment variable

enabled

boolean

Whether the multisite resolution is enabled.

N/A

useCookieResolution

function

Custom function to determine whether cookie-based site resolution should be used for a given request.

N/A

personalize

Property

Type

Description

Corresponding environment variable

enabled

boolean

Whether the personalize feature is enabled.

N/A

edgeTimeout

number

The timeout duration, in seconds, for personalization requests to Experience Edge.

PERSONALIZE_MIDDLEWARE_EDGE_TIMEOUT

cdpTimeout

number

The timeout duration, in seconds, for personalization requests to Sitecore CDP.

PERSONALIZE_MIDDLEWARE_CDP_TIMEOUT

scope

string

The Sitecore Personalize scope identifier, which allows you to isolate your personalization data between SitecoreAI environments.

SITECORE_PERSONALIZE_SCOPE

CSDK_PUBLIC_PERSONALIZE_SCOPE

channel

string

The CDP channel to use for events.

N/A

currency

string

The currency type to use for CDP requests.

N/A

other properties

Property

Type

Description

Corresponding environment variable

rewriteMediaUrls

boolean or function

Whether media URLs pointing to the production Experience Edge host are rewritten.

Setting it to true rewrites media URLs using the custom host defined in SITECORE_EXPERIENCE_EDGE_HOSTNAME.

You can also use a function in the format transformer(s: string) => string, where s is the image URL to be transformed and the return value is the transformed URL. See example:

function rewriteEdgeHostInString(str: string): string {
  const customEdgeUrl = 'my-custom.com';
  const EDGE_HOST_PATTERN = new RegExp(
    `custom-matcher-here`,
    'gi'
  );
  return str.replace(EDGE_HOST_PATTERN, customEdgeUrl);
}

N/A

Angular properties

These are Angular-specific configuration options.

Property

Type

Description

Corresponding environment variable

locales

string[]

List of URL segment locales supported by your application. Used for locale-aware routing and dictionary loading. The defaultLanguage value is prepended if not already included. See Internationalization using ngx-translate for more information.

N/A

loadersCache

object

Configuration options for loaders cache.

N/A

linkPrefetch

object

Configuration options for link prefetch on scRouterLink and scRichText links. See Link prefetching for more information.

N/A

loaderCache properties

Property

Type

Description

Corresponding environment variable

enabled

boolean

Whether the loaders cache layer is enabled or not.

Default: true

N/A

revalidate

number

Time-to-live (TTL) in seconds for cache entries before they become stale.

Default: 300

N/A

linkPrefetch properties

Property

Type

Description

Corresponding environment variable

mode

'eager' | 'hover' | 'off'

The prefetch strategy applied to scRouterLink and scRichText links.

Default: 'eager'

N/A

delayMs

number

Hover dwell time, in milliseconds, before prefetch fires. Only used when mode is 'hover'.

Default: 100

N/A

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