1. @sitecore-cloudsdk/events/server

init (deprecated)

Version:
Warning

Deprecated. Use the core package to initialize the Cloud SDK and its packages. See also install and initialize the Cloud SDK.

Type

Function

Import path

@sitecore-cloudsdk/events/server

Initializes the server module of the Cloud SDK events package.

Important

Run init before running other functions in the module.

Signature

Parameters

Name

Type

Description

request

Request

Required.

The HTTP request.

response

Response

Required.

The HTTP response.

settings

ServerSettings

Required.

Details about your SitecoreAI instance and cookie settings.

ServerSettings properties

Return value

Returns a promise. The promise resolves with an object that handles the module functionality.

Examples

Next.js

Here's an example middleware.ts script showing how to initialize the module:

import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
import { init } from "@sitecore-cloudsdk/events/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 events/server module.");
  // <- Initialize the module

  return response;
};
If you have suggestions for improving this article, let us know!