Before you start
- A
clientIdissued by SPREEAI for your approved environment. - A garment that has completed ingestion, belongs to your account and is available for try-on.
- A product page you can edit and a container with a unique HTML ID.
1. Install
Terminal
npm install @spreeai/web-sdk@3.0.0The stylesheet is part of the package and must be included in your bundle.
2. Add a container
HTML
<div id="spreeai-try-on"></div>3. Initialize and render
TypeScript
import { init } from "@spreeai/web-sdk";
import "@spreeai/web-sdk/dist/web-sdk.css";
// Add <div id="spreeai-try-on"></div> to your product page.
const sdk = await init({ clientId: "YOUR_ISSUED_CLIENT_ID" });
if (sdk) {
await sdk.renderTryOnButton({
elementId: "spreeai-try-on",
garments: [{ garmentId: "YOUR_READY_GARMENT_ID" }],
});
} else {
// Keep the normal product and purchase journey available.
console.warn("SPREEAI could not initialize.");
}init() can return null. Check the result before rendering, and initialize once per page rather than for each button.
4. Check the result
- Load the product page. A valid, available garment renders a try-on button.
- Open the fitting room and confirm the intended garment and color.
- Close and reopen it. Check the experience on a phone and a desktop.
- Try an unavailable garment in your test environment. Confirm your normal product and checkout path remains usable.
Where to go next
Data
Map products & variants
Use SPREEAI garment IDs and check readiness before rendering.
CheckoutConnect cart & events
Enable add-to-cart and implement your storefront handler.
FitAdd sizing guidance
Enable supported recommendations and optional size display.
OptionsBrowse the API
Review the full verified option and callback surface.