---
title: "init (deprecated)"
slug: "cloud-sdk-personalize-server-init"
abstract: "The init function initializes the server module of the Cloud SDK personalize package. Run init before running other functions in the module."
---
# init (deprecated)

> [!warning]
> Deprecated. Use the [`core`](https://doc.sitecore.com/sdk/en/developers/004/cloud-sdk/cloud-sdk-reference/cloud-sdk-personalize/cloud-sdk-personalize-server/functions/cloud-sdk-core.html "@sitecore-cloudsdk/core") package to initialize the Cloud SDK and its packages. See also [install and initialize the Cloud SDK](https://doc.sitecore.com/sdk/en/developers/004/cloud-sdk/cloud-sdk-reference/cloud-sdk-personalize/cloud-sdk-personalize-server/functions/install-and-initialize-the-cloud-sdk.html "Install and initialize the Cloud SDK").

|     |     |
| --- | --- |
| Type | Function |
| Import path | `@sitecore-cloudsdk/personalize/server` |

Initializes the `server` module of the Cloud SDK `personalize` package.

> [!important]
> Run `init` before running other functions in the module.

## Signature

```typescript
export async function init(
  request: Request,
  response: Response,
  settings: ServerSettings
): Promise<void>
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `request` | `Request` | Required.<br><br>The HTTP request. |
| `response` | `Response` | Required.<br><br>The HTTP response. |
| `settings` | [`ServerSettings`](https://doc.sitecore.com/sdk/en/developers/004/cloud-sdk/cloud-sdk-reference/cloud-sdk-personalize/cloud-sdk-personalize-server/functions/cloud-sdk-personalize-server-init.html#UUID-7fc17129-3dc7-0f4e-f181-fdafb9c53e21_section-idm1903440007612340 "ServerSettings properties") | Required.<br><br>Details about your SitecoreAI instance and cookie settings. |

### `ServerSettings` properties

| Name | Type | Description | Value |
| --- | --- | --- | --- |
| sitecoreEdgeContextId | string | Required.Context ID.Accessible and stored as an environment variable in your app. | "3axQRoRznWUqHR8B2RSbdo" |
| siteName | string | Required.The name of the site.Accessible and stored as an environment variable in your app. | "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.ImportantSet the same value for this property in every Cloud SDK module.Default: your domain. | ".myretailsite.com"".beta.myretailsite.com""localhost" |
| cookieExpiryDays | integer | Optional.The number of days before cookies expire.ImportantSet the same value for this property in every Cloud SDK module.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.ImportantSet the same value for this property in every Cloud SDK module.Default: "/". | "/" |
| enableServerCookie | boolean | Optional.Flag 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 a promise. The promise resolves with an object that handles the module functionality.

## Examples

:::tab{title="Next.js"}
Here's an example `middleware.ts` script showing how to initialize the module:

```typescript
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
import { init } from "@sitecore-cloudsdk/personalize/server";

export async function middleware(request: NextRequest) {
  const response = NextResponse.next();

  // Initialize the module ->
  await init(request, response,
    {
      sitecoreEdgeContextId: process.env.SITECORE_EDGE_CONTEXT_ID,
      siteName: process.env.SITECORE_SITE_NAME,
      enableServerCookie: true
    }
  );

  console.log("Initialized the personalize/server module.");
  // <- Initialize the module

  return response;
};
```

:::