Skip to main content
The Souldi widget is a lightweight JavaScript snippet that adds an AI-powered “Try On” button to any product page. Souldi handles authentication, photo uploads, and generation behind the scenes — you just drop in the script and point it at a garment. This guide takes you from zero to a working try-on button in three steps.
1

Install the widget

Add the widget to your store via npm or a CDN script tag.
The CDN (UMD) build exposes a global VirtualTryOn object on window. If you use a bundler such as Vite or webpack, import the ESM build at dist/widget.mjs instead.
2

Initialize the widget

Call VirtualTryOn.init(options) once per page load to configure the widget with your publishable key. Calling init() a second time is ignored.
Use your publishable key (pk_live_...) here — never your secret key. The publishable key is safe in client-side code because it only works from the domains you’ve whitelisted in your dashboard.
3

Add a Try-On button

Call VirtualTryOn.createButton(options) once per product or garment. The button renders into a container element you provide.
In "oc" (outfit combinator) mode, the garment is layered onto the user’s previous completed try-on result — so the customer needs to have finished a try-on earlier in the session before an outfit-combinator button can generate.

Events and callbacks

The four callbacks you pass to init() let you hook your own UI and analytics into the try-on lifecycle. The widget stays lightweight and lets your page own the experience.
If you set targetImageId, the widget already swaps that <img> for you on success — use onGenerationSuccess for everything else, like analytics or a “save to favorites” action.

Full example

A complete, copy-paste product page with init, a button, and callbacks wired up:
That’s it. When a customer clicks Try On, Souldi handles verification, the photo upload, and AI generation — and the result appears right on your product page.

Next steps

Customization

Match the widget to your brand with theme modes, accent colors, fonts, and more.

Widget Overview

Learn how the widget works and how it keeps customer photos private.