initLivePreview
Initializes Live Preview session in the Experience Manager.
The function is tracking DOM mutations. Whenever a new element with the data-brx-id attribute is added, it will be connected to the Experience Manager.
Signature
declare function initLivePreview(
props: Props
): () => any;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
props | Required | Props | Parameter object which can be used with this method. Refer to its type definition to learn about possible properties. |
Returns
A callback which should be used to terminate the Live Preview session (e.g. within the clean-up callback of the useEffect hook in React or within the onBeforeUnmount lifecycle hook in Vue). It calls the destroy() function from the Bloomreach SPA SDK.
Examples
Initializing Live Preview session.
import { sdk } from '~/sdk.config.ts';
const destroy = sdk.bloomreachContent.utils.initLivePreview({ page });
@example
Listening to Container Items updates and accessing the updated page JSON
object.