init(options)
Returns Promise<SpreeAISDK | null>. On success, the object exposes renderTryOnButton(options): Promise<void>. Check for null before rendering.
| Option | Type | Default | Purpose |
|---|---|---|---|
clientId | string | Required | Issued browser client identifier. |
baseApiURL | string | https://api.spreeai.com | Approved API origin. Change only for an issued environment. |
baseURL | string | https://vton.spreeai.com | Approved hosted fitting-room origin. |
partnerId is not an init option in v3. The partner is resolved from the authenticated client. No standalone sizing render method is returned.
renderTryOnButton(options)
| Option | Type | Default / requirement | Purpose |
|---|---|---|---|
elementId | string | Required | ID of the existing host element. |
garments | GarmentInput[] | Required choice | Recommended garment input. Use a non-empty array. |
garmentId | string | Deprecated alternative | Legacy single-garment input. Prefer garments. |
variant | VariantOptions | Deprecated | Legacy filter with garmentId; prefer per-item variant. |
className | string | Optional | Additional button class. |
button | { text?: string } | Optional | Button label; overridden by features.tryOnButton.text. |
features | TryOnFeatures | Optional | Button styling configuration. |
events | TryOnButtonEvents | Optional | Click and add-to-cart handlers. |
enableAddToCart | boolean | false | Display the add-to-cart functionality. Implement the handler. |
enableSizingRecommendation | boolean | false | Request sizing recommendations inside try-on. |
showSizes | boolean | false | Show supplied availableSizes. |
showPrices | boolean | false | Show supplied price. |
defaultUnits | "metric" | "imperial" | Optional | Starting unit system for profile measurements. |
GarmentInput
| Field | Type | Purpose |
|---|---|---|
garmentId | string | Required SPREEAI garment identifier. |
variant | VariantOptions | Optional color, fit, gender or style filter. |
availableSizes | string[] | Optional current display size labels. |
price | string | Optional display price, shown as supplied. |
Validation and fallback
For a single garment, eligibility and any pinned variant are checked before rendering. Multi-garment requests look for an available matching outfit. If none is found, the SDK validates and renders the first garment instead. If validation fails, no button is rendered and the reason is logged to the console.
Callbacks
| Callback | Payload |
|---|---|
onTryOnButtonClick | name: "spreeai-try-on-button-clicked" |
onAddToCartClicked | name: "spreeai-add-to-cart-clicked", garments, setIsLoading, closePopUp, onError |
Cart garments contain required id, partner_id, available and name, plus optional description and other data. Validate before mapping to your cart. See cart implementation and button styling for examples.
Not part of this surface
No documented per-view switches, standalone Compare launcher or standalone sizing method are exposed on the returned v3.0.0 SDK. features.loadingScreen has been removed. Do not infer callable methods from leftover exported types or stale comments.