Skip to content

Methods

Lifecycle and UI

await widget.init(config)

Initializes the widget and mounts an iframe into the given container.

await widget.destroy()

Destroys the widget, removes listeners and iframe, and resets internal state.

await widget.destroy();

widget.isReady()

Returns whether the widget is initialized and ready.

if (widget.isReady()) {
  console.log("Widget active");
}

widget.show() / widget.hide()

Toggles iframe visibility.

widget.hide();
widget.show();

Data and communication

widget.updateUserCart(cart)

Pushes latest cart state to widget runtime.

widget.updateUserCart({
  cardId: "cart-001",
  items: [
    { productId: "p1", variantId: "v1", quantity: 1 },
    { productId: "p2", variantId: "v2", quantity: 2 },
  ],
});

Events API

widget.on(event, handler)

Registers an event listener.

widget.off(event, handler)

Removes a previously registered listener.