Skip to main content

Using callbacks

You can use the SDK to receive callbacks on user actions such as:

  • Asset changed
  • Body changed
  • Avatar exported

Use /v1/sessions/new API request to get a link and pass it to sdk.init(...) function. You don't need to create an <iframe> element on your page. Rather than that, you need to pass a DOM element, that SDK will use as parent for everything it initializes.

const scene = await sdk.init(container, {
url: '<URL_RETURNED_BY_AVATURN_API>',
iframeClassName: '<CSS_CLASS_NAME_FOR_IFRAME>',
disableUi: false,
});

That's it. Now you can use .on() callbacks to perform custom actions on user clicks.

Playground

Try clicking on assets and see logs on the screen.

Edit web_sdk-example