1. @sitecore-cloudsdk/core/browser

getGuestId

Version:

Type

Function

Import path

@sitecore-cloudsdk/core/browser

Returns a promise that resolves to the guest ID. Used for testing and debugging purposes.

Signature

export async function getGuestId(): Promise<string>

Return value

Returns a promise.

Examples

Example 29. Running the getGuestId function

Next.js

Here's an example of how to use the getGuestId function to log the guest ID to the console:

"use client"; // Used only in Next.js App Router
import { useEffect } from "react";
import { getGuestId } from "@sitecore-cloudsdk/core/browser";

async function getId() {
  const guestId = await getGuestId();
  console.log("guest ID:", guestId);
}

export default function Component(){
  useEffect(() => {
    getId();
  }, [])

  return (<></>);
};


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