- Functions
CloudSDK
Version:
| Type | Function |
| Import path | @sitecore-cloudsdk/core/server |
Initializes the Cloud SDK and any SDK packages of your choice.
Important
Initialize SDK packages before running any functions in the package modules.
Signature
Parameters
| Name | Type | Description |
|---|---|---|
settings | ServerSettings | Required. Details about your SitecoreAI instance and cookie settings. |
ServerSettings properties
ServerSettings properties| Name | Type | Description | Value |
|---|---|---|---|
| sitecoreEdgeContextId | string | Required.Context ID. | "3axQRoRznWUqHR8B2RSbdo" |
| siteName | string | Required.Site name. | "myRetailSite" |
| cookieDomain | string | Optional.The top-level domain of your app. The cookie domain ensures that the Cloud SDK stores cookies in the web browser as first-party cookies.Default: your domain. | ".myretailsite.com"".beta.myretailsite.com""localhost" |
| cookieExpiryDays | integer | Optional.The number of days before cookies expire.For example, set to 1 for cookies to expire in 1 day.If unset, cookies expire according to the Max-Age set by the web browser. | 365 |
| cookiePath | string | Optional.A URL path that must exist in the requested URL in order to send cookies.Default: "/". | "/" |
| enableServerCookie | boolean | Optional.Whether to set cookies from the server side.If using only the server modules of packages, set to true.If using both the browser and the server modules of packages, set either enableBrowserCookie or enableServerCookie to true, and set the other to false.Default: false. | true |
Return value
Returns an instance of CloudSDKServerInitializer.
Examples
Example 30. Running the CloudSDK function
Here's an example middleware.ts script showing how to initialize the SDK and its packages.
Important
Before initializing SDK packages, first install them and import their modules.
See install and initialize the Cloud SDK and the reference documentation for installation and initialization code for all Cloud SDK packages and modules.
This script initializes the following Cloud SDK packages:
addEventsinitializes theeventspackage.addPersonalizeinitializes thepersonalizepackage.addSearchinitializes thesearchpackage.
:::
If you have suggestions for improving this article, let us know!