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/personalize/browser

Initializes the browser module of the Cloud SDK personalize package.

Important

Run init before running other functions in the module.

Signature

export async function init(
  settings: BrowserSettings
): Promise<void>

Parameters

Name

Type

Description

settings

BrowserSettings

Required.

Details about your SitecoreAI instance and cookie settings.

BrowserSettings properties

Return value

Returns a promise.

Examples

Next.js

Here's an example page.tsx script showing how to initialize the module:

"use client";
import { useEffect } from "react";
import { init } from "@sitecore-cloudsdk/personalize/browser";

export default function Home() {
  // Initialize the module ->
  useEffect(() => {
    initPersonalize();
  }, []);

  const initPersonalize = async () => {
    await init({
      sitecoreEdgeContextId: process.env.SITECORE_EDGE_CONTEXT_ID,
      siteName: process.env.SITECORE_SITE_NAME,
      enableBrowserCookie: true
    });

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

  return (<></>);
};
If you have suggestions for improving this article, let us know!