---
title: "Add try-on to your website and app · Ateliq docs"
description: "Add Ateliq's try-on to Shopify, Shopify Hydrogen, Next.js and other headless stores, WooCommerce, any website, React apps, Python backends and iOS or Android…"
canonical: https://ateliq.co/docs/try-on/
last-updated: 2026-12-04
---

Documentation menu

Integrations and API // 01 23:00

# Add try-on to your website and app

Add Ateliq's try-on to Shopify, Shopify Hydrogen, Next.js and other headless stores, WooCommerce, any website, React apps, Python backends and iOS or Android apps. One line of script, or the ateliq package on npm and PyPI.

Ateliq's try-on lets shoppers see your pieces on themselves before they buy, on your own website or in your own app. They tap **Try it on**, see the piece on them, and add it to your bag. Your own cart and checkout do the selling.

Pick your route:

| Your store | What to do | Developer needed? |
| Shopify theme | [Paste one line in theme.liquid](#route-a-paste-one-line-no-developer-needed) | No |
| Shopify theme built with a bundler, Hydrogen, headless Shopify | [npm: ateliq/tryon](#route-b-npm-for-developer-teams) | Yes |
| Next.js or another React storefront | [Next.js and headless stores](#next-js-and-headless-stores) | Yes |
| WooCommerce | [One line, plus a short PHP snippet](#woocommerce) | A little |
| Any other site (custom, Magento, a site builder) | [One line, plus your own cart call](#any-other-website) | A little |
| iOS, Android, React Native or Flutter app | [A web view](#ios-and-android-apps) | Yes |
| Python backend (Django, Flask, FastAPI) | [PyPI: ateliq](#python-backends) | Yes |

## What the shopper sees

- On a product page whose piece can be tried on, a **Try it on** button under your add to cart button. Pieces that can't be tried on get no button.
- On your home page, a floating **Try on** button (you can turn it off).
- On a phone, the try-on opens full screen. On a laptop, it opens in a window over your page.
- Jewellery is tried on live in the camera view, at its real size. For clothing, the shopper takes or uploads a photo and gets a photo of herself wearing the piece, made by AI. An AI stylist can suggest what goes with it.
- **Add to bag** puts the piece in your own cart, in the size or length she chose. She closes the try-on and carries on shopping.

## What you need from Ateliq

- **Your Ateliq address.** We give it to you when we set up your store, for example https://try.yourbrand.com . Every example on this page writes it as https://YOUR-ATELIQ-ADDRESS ; put yours in its place.
- **Your domains added.** Tell us every address that will show the try-on, such as https://yourbrand.com and https://www.yourbrand.com , and any preview or staging address. The try-on only opens on addresses we have added.
- **Your catalogue connected.** On Shopify, a custom app in your admin with read access to products, inventory and orders. On other platforms, a product sheet (a Google Sheet or CSV link) with your SKUs, names, prices and photos. We make each piece ready for try-on from its product photos.

Write to [pb@ateliq.co](mailto:pb@ateliq.co) to get started.

## Shopify

There are two routes. Both give the same try-on, the same **Try it on** button and the same order counts.

**Note:** An Ateliq app for the Shopify App Store is coming. Until it is listed, use Route A or Route B.

### Route A: paste one line (no developer needed)

- In your Shopify admin, go to **Online Store > Themes**.
- Next to your current theme, click the **...** button, then **Edit code**.
- In the **Layout** folder, open theme.liquid .
- Find </body> near the end, and paste the line below just above it.
- Click **Save**, then open one of your product pages to see the **Try it on** button.

```

```

That is all. Add to bag uses your theme's own cart ( /cart/add.js ), and the try-on visit is kept on the cart and order so you can count orders that came through try-on. To leave the floating button off your home page, add data-home-button="off" to the line.

### Route B: npm, for developer teams

If your team builds the theme with a bundler (Vite, webpack, esbuild), runs Hydrogen, or runs its own storefront on Shopify, install the ateliq package:

```
npm install ateliq
```

ateliq/tryon loads your store's try-on once and gives you a typed handle. It has no dependencies, and it is safe to import during server rendering: nothing happens until you call it in the browser.

**A theme built with a bundler.** In your theme's JavaScript entry:

```
import { loadTryOn } from 'ateliq/tryon';

loadTryOn({ host: 'https://YOUR-ATELIQ-ADDRESS', platform: 'shopify' });
```

With platform: 'shopify' and no add handler, it works exactly like Route A: buttons on product pages, and Add to bag through /cart/add.js with the try-on visit on the cart line and the cart.

**Hydrogen.** Use your own cart through an add handler, with the try-on visit as a cart line attribute. This example is for Hydrogen on React Router 7:

```
import { useFetcher } from 'react-router';
import { CartForm } from '@shopify/hydrogen';
import { useTryOn } from 'ateliq/react';
import { shopifyVariantGid } from 'ateliq/tryon';

export function TryOnButton({ handle }: { handle: string }) {
 const fetcher = useFetcher();
 const { ready, open } = useTryOn({
 host: 'https://YOUR-ATELIQ-ADDRESS',
 platform: 'custom',
 homeButton: false,
 onAdd: ({ variantId, quantity, session }) =>
 fetcher.submit(
 {
 [CartForm.INPUT_NAME]: JSON.stringify({
 action: CartForm.ACTIONS.LinesAdd,
 inputs: {
 lines: [{
 merchandiseId: shopifyVariantGid(variantId!),
 quantity,
 attributes: [{ key: '_ateliq_session', value: session }],
 }],
 },
 }),
 },
 { method: 'POST', action: '/cart' },
 ),
 });
 return open({ handle })}>Try it on ;
}
```

Hydrogen sets a Content-Security-Policy. Add your Ateliq address to it, or the try-on can't load (see [Content-Security-Policy](#content-security-policy)).

**Headless Shopify with your own cart API.** Follow [Next.js and headless stores](#next-js-and-headless-stores). When your cart calls the Storefront API, keep the try-on visit as the cart line attribute _ateliq_session (in cartLinesAdd ) or the cart attribute ateliq_session (in cartAttributesUpdate ). Either one on the order counts it as a try-on order.

## Next.js and headless stores

On a headless store, Ateliq can't find your cart by itself, so you pass it an add handler. Use platform: 'custom' , and turn the home page button off: on a single-page app it would stay on screen after the shopper leaves the home page.

**1. Load the try-on once, in your root layout.** A client component, here with the React hook from the same package (React is your own; the package doesn't install it):

```
// app/ateliq-try-on.tsx
'use client';

import { useEffect } from 'react';
import { usePathname } from 'next/navigation';
import { useTryOn } from 'ateliq/react';

export function AteliqTryOn() {
 const pathname = usePathname();
 const { ready, scan } = useTryOn({
 host: process.env.NEXT_PUBLIC_ATELIQ_HOST!, // https://YOUR-ATELIQ-ADDRESS
 platform: 'custom',
 homeButton: false,
 // Add to bag: your own cart. Throw (or reject) and the try-on shows your short message to the shopper.
 onAdd: async ({ variantId, sku, quantity, session }) => {
 const res = await fetch('/api/cart', {
 method: 'POST',
 headers: { 'content-type': 'application/json' },
 body: JSON.stringify({ variantId, sku, quantity, attributes: { ateliq_session: session } }),
 });
 if (!res.ok) throw new Error('Could not add to bag');
 },
 });

 // wire Try it on buttons that arrive with a client-side route change
 useEffect(() => { if (ready) scan(); }, [ready, pathname, scan]);
 return null;
}
```

```
// app/layout.tsx
import { AteliqTryOn } from './ateliq-try-on';

export default function RootLayout({ children }: { children: React.ReactNode }) {
 return (
 
 
 {children}
 
 
 
 );
}
```

variantId is the Shopify variant id as digits; shopifyVariantGid(variantId) from ateliq/tryon turns it into the Storefront API's gid://shopify/ProductVariant/... . Keep session on the order (see [Order attribution](#order-attribution)).

**2. Put a button on product pages.** Either of these, in any component, server or client:

```
{/* an empty slot: Ateliq puts its own Try it on button here, only if this piece can be tried on */}
 

{/* or your own button: it always shows, and opens the try-on for this piece */}
 See it on you
```

data-ateliq-sku takes a SKU from your catalogue (a Shopify product handle works too). The script wires these when it loads, and scan() wires the ones that arrive later; a wired element is never wired twice. Give the element a key that changes with the product, so moving from one product page to another makes a new element instead of reusing the old one with the old piece.

In a client component you can also open it from code: const { open } = useTryOn({...}) and open({ sku }) .

**Without the npm package.** The one-line route works in Next.js too:

```
import Script from 'next/script';


```

With data-platform="custom" , Add to bag needs your cart: call window.Ateliq.on('add', ({ variantId, sku, quantity, session }) => ...) once the script has loaded, returning a promise. The npm package does this for you, with types and a way to remove the handler.

### The ateliq/tryon API

| Call | What it does |
| loadTryOn(options) | Loads the try-on on the page (once) and resolves to a handle. Browser only. |
| handle.open({ sku }) , handle.open({ handle }) , handle.open() | Opens on a piece, or on the store's pieces |
| handle.close() | Closes it |
| handle.scan(root?) | Wires data-ateliq-sku elements added after the page loaded |
| handle.on('add', fn) | Your cart. fn gets { variantId, sku, quantity, session } ; return a promise. If it throws or rejects, the shopper sees the error's message when it is short (under 120 characters), such as "Sold out in this size". Returns a function that removes the handler. |
| handle.on('event', fn) | { name, sku } for tryon_open , piece_tried , photo_made and add_to_bag , for your analytics |
| handle.on('close', fn) | The shopper closed the try-on |
| handle.dispose() | Removes every handler added through this handle |
| useTryOn(options) (from ateliq/react ) | The same in a React hook: { ready, error, open, close, scan } |
| embedSnippet(host, options) , tryOnUrl(host, sku) , shopifyVariantGid(id) | Helpers that also work on a server: the script tag, the app page, a Storefront API id |

Options: host (your Ateliq address), platform ( 'shopify' , 'woocommerce' or 'custom' ; left out, it is found from the page), homeButton (default true ), autoButton ( false leaves the WooCommerce product button off), nonce , timeoutMs (default 15 seconds), and onAdd , onEvent , onClose .

Setting an add handler replaces the Shopify or WooCommerce cart, so keep it for the life of the page. If loadTryOn fails, it rejects with a TryOnError whose code says why: bad_host , load_failed , timeout and so on. Full reference: the [package README](https://www.npmjs.com/package/ateliq).

## WooCommerce

**Step 1.** Add this line to every page, in your theme's footer or with a header and footer scripts plugin:

```

```

**Step 2.** To keep the try-on visit on the order, add this to your child theme's functions.php , or with a code snippets plugin:

```
add_filter('woocommerce_add_cart_item_data', function ($data) {
 if (!empty($_POST['ateliq_session'])) $data['ateliq_session'] = sanitize_text_field(wp_unslash($_POST['ateliq_session']));
 return $data;
});
add_action('woocommerce_checkout_create_order_line_item', function ($item, $key, $values) {
 if (!empty($values['ateliq_session'])) $item->add_meta_data('_ateliq_session', $values['ateliq_session'], true);
}, 10, 3);
```

Product pages get **Try it on** under the add to cart form, matched by the product's SKU (or its id). Add to bag uses WooCommerce's own cart and refreshes the mini cart.

## Any other website

Add the script, then put buttons where you want them and tell it how to add to your cart:

```


 
 See it on you 

 




 
 // your cart: called on Add to bag; return a promise (rejected means "didn't go in the bag")
 Ateliq.on("add", ({ variantId, sku, quantity, session }) =>
 fetch("/api/cart", { method: "POST", headers: { "content-type": "application/json" },
 body: JSON.stringify({ sku, quantity, attributes: { ateliq_session: session } }) }));
 Ateliq.on("event", ({ name, sku }) => window.dataLayer?.push({ event: "ateliq_" + name, sku }));

```

Ateliq.open({ sku }) opens it from your own code, Ateliq.close() closes it, and Ateliq.scan() wires buttons added to the page later.

## iOS and Android apps

Open the try-on full screen in a web view at:

```
https://YOUR-ATELIQ-ADDRESS/w?handle=
```

/w with no handle opens on the store's pieces. The web view needs the camera, inline video, and a message handler; the try-on finds your app's handler by itself. It sends the same messages as on a website: add (with variantId , sku , quantity and session ), close , and event . Answer an add by calling window.ateliqReceive({ type: 'added' }) , or { type: 'add_failed', error: 'Sold out in this size' } , so the shopper sees the result.

### iOS (Swift, WKWebView)

In Info.plist , add NSCameraUsageDescription (for example "Try pieces on with your camera") and NSMicrophoneUsageDescription (for the stylist's voice).

```
final class TryOnViewController: UIViewController, WKScriptMessageHandler, WKUIDelegate {
 var webView: WKWebView!
 override func viewDidLoad() {
 super.viewDidLoad()
 let config = WKWebViewConfiguration()
 config.allowsInlineMediaPlayback = true
 config.mediaTypesRequiringUserActionForPlayback = []
 config.userContentController.add(self, name: "ateliq") // window.webkit.messageHandlers.ateliq
 webView = WKWebView(frame: view.bounds, configuration: config)
 webView.uiDelegate = self
 view.addSubview(webView)
 webView.load(URLRequest(url: URL(string: "https://YOUR-ATELIQ-ADDRESS/w?handle=TS-CH-18")!))
 }
 // iOS 15+: let the try-on use the camera without a second prompt
 func webView(_ webView: WKWebView, requestMediaCapturePermissionFor origin: WKSecurityOrigin,
 initiatedByFrame frame: WKFrameInfo, type: WKMediaCaptureType,
 decisionHandler: @escaping (WKPermissionDecision) -> Void) { decisionHandler(.grant) }
 func userContentController(_ c: WKUserContentController, didReceive m: WKScriptMessage) {
 guard let msg = m.body as? [String: Any], let type = msg["type"] as? String else { return }
 switch type {
 case "add":
 Cart.shared.add(sku: msg["sku"] as? String, variantId: msg["variantId"] as? String,
 quantity: msg["quantity"] as? Int ?? 1, ateliqSession: msg["session"] as? String) { ok in
 self.webView.evaluateJavaScript("window.ateliqReceive({type:'\(ok ? "added" : "add_failed")'})")
 }
 case "close": dismiss(animated: true)
 default: break // "event": send to your analytics
 }
 }
}
```

### Android (Kotlin, WebView)

In AndroidManifest.xml , add <uses-permission android:name="android.permission.CAMERA"/> and RECORD_AUDIO , and ask for the camera at runtime before you open the screen.

```
webView.settings.javaScriptEnabled = true
webView.settings.mediaPlaybackRequiresUserGesture = false
webView.webChromeClient = object : WebChromeClient() {
 override fun onPermissionRequest(request: PermissionRequest) {
 request.grant(request.resources) // camera (and microphone for the stylist's voice), already granted to the app
 }
}
webView.addJavascriptInterface(object {
 @JavascriptInterface fun postMessage(json: String) {
 val msg = JSONObject(json)
 when (msg.getString("type")) {
 "add" -> cart.add(msg.optString("sku"), msg.optString("variantId"), msg.optInt("quantity", 1), msg.optString("session")) { ok ->
 webView.post { webView.evaluateJavascript("window.ateliqReceive({type:'${if (ok) "added" else "add_failed"}'})", null) } }
 "close" -> runOnUiThread { finish() }
 }
 }
}, "AteliqAndroid")
webView.loadUrl("https://YOUR-ATELIQ-ADDRESS/w?handle=TS-CH-18")
```

### React Native and Flutter

React Native ( react-native-webview ): set allowsInlineMediaPlayback , mediaPlaybackRequiresUserAction={false} and mediaCapturePermissionGrantType="grant" , read messages in onMessage ( JSON.parse(e.nativeEvent.data) ), and answer with injectJavaScript("window.ateliqReceive({type:'added'}); true;") . On Android, grant the camera to the app first with PermissionsAndroid.request .

Flutter ( flutter_inappwebview ): set mediaPlaybackRequiresUserGesture: false and allowsInlineMediaPlayback: true , grant in onPermissionRequest , add a JavaScript handler named ateliq , and answer with evaluateJavascript(source: "window.ateliqReceive({type:'added'})") .

To build the address in code, tryOnUrl(host, sku) from ateliq/tryon (JavaScript) and tryon_url(host, sku) from ateliq.tryon (Python) do it for you.

## Python backends

The ateliq package on PyPI has helpers for a Python backend. They make no network calls and need nothing but Python 3.9 or later.

```
pip install ateliq
```

```
from ateliq.tryon import embed_snippet, tryon_url, order_session

# the script tag, for your page template (render it unescaped)
ATELIQ_TAG = embed_snippet("https://YOUR-ATELIQ-ADDRESS", "custom", home_button=False)

# the try-on page, for your app's web view
url = tryon_url("https://YOUR-ATELIQ-ADDRESS", "TS-CH-18")

# in your orders webhook: was this order made through try-on?
session = order_session(order_json) # "s-..." or None
```

order_session reads a Shopify order (webhook or REST: note_attributes and line properties ; GraphQL: customAttributes ) and a WooCommerce order (webhook or REST: line item meta_data ). order_sessions gives every visit on the order. WOOCOMMERCE_PHP holds the WooCommerce snippet above, and shopify_variant_gid(id) builds a Storefront API id.

## Order attribution

Every Add to bag from the try-on carries session , the try-on visit. Keep it on the order, and you can count the orders and revenue that came through try-on.

| Platform | Where the visit is kept | Who keeps it |
| Shopify theme (Route A, or platform: 'shopify' ) | Line property _ateliq_session and cart attribute ateliq_session | Ateliq, automatically |
| Hydrogen or headless Shopify | Cart line attribute _ateliq_session or cart attribute ateliq_session | Your add handler |
| WooCommerce | Line item meta _ateliq_session | The PHP snippet |
| Any other site, or an app | Wherever your cart keeps it, as ateliq_session | Your add handler |

On Shopify, Ateliq's monthly report counts these orders for you, from the orders it can read in your store. Elsewhere, the visit is on your own orders for your own reports; order_session in the Python package reads it for you.

## Privacy

- The try-on explains what happens first, and uses the camera only when the shopper chooses to start it.
- Camera video is processed on the shopper's own device to place the pieces. It is not recorded or sent.
- A photo is sent only when she asks for a try-on photo, and only to make that photo. The photo is deleted 30 minutes later.
- Her visit (the pieces she tried, the sizes she gave, the chat with the stylist) is forgotten 3 hours after it started.
- The try-on never asks for her name, phone number, email or address. The visit id on her bag is the only thing it puts in your shop.
- If your store has the live AI stylist (a voice call), the call is not recorded, but its words are written down by the speech service. The full list below says how long each thing is kept.
- The full list for your store, including the outside services it uses, is at https://YOUR-ATELIQ-ADDRESS/privacy?surface=web , linked from the try-on itself. See also [Privacy](https://ateliq.co/docs/privacy/).

## Content-Security-Policy

If your site sends a Content-Security-Policy (Hydrogen does by default, and many Next.js sites do), add your Ateliq address to:

| Directive | Why |
| script-src | To load embed.js (pass nonce to loadTryOn if your policy uses nonces) |
| connect-src | To check which pieces can be tried on |
| frame-src | To open the try-on window |
| style-src | embed.js adds a small style element for its button and window, so inline styles must be allowed |

If your site sends a Permissions-Policy header, it must allow the camera (and the microphone, for the stylist's voice) for your Ateliq address.

## Troubleshooting

| What you see | Why, and what to do |
| No **Try it on** button anywhere | Your domain isn't added yet. Your browser's console says [ateliq] this storefront origin is not in WEB_ORIGINS . Send us the exact address, with and without www . |
| No button on one product | That piece isn't in your Ateliq catalogue, or isn't ready for try-on yet, or its SKU doesn't match. Check the SKU (or Shopify handle) is the same in both. |
| The try-on window opens but stays blank | The address isn't added (see above), or your Content-Security-Policy blocks the frame. |
| The camera doesn't start | The shopper said no to the camera, or your Permissions-Policy header blocks it, or (in an app) the app has no camera permission. |
| Add to bag says it didn't go in the bag | Your add handler threw or rejected (a short error message is shown to the shopper as it is), or the piece has no variant id in your catalogue. On a custom site, an add handler is needed. |
| Added, but the cart icon doesn't change | Ateliq sends cart:refresh and cart:updated events on document after adding. Hook your cart drawer to them, or refresh it in your add handler. |
| A floating button stays on every page of a single-page app | Turn it off with homeButton: false or data-home-button="off" . |
| Buttons stop working after moving between pages | Call scan() after each route change, and give each button a key that changes with the product. |
| loadTryOn rejects with load_failed | Check the Ateliq address, and your Content-Security-Policy script-src . |

## Remove it

- **Shopify Route A, WooCommerce or any site:** delete the embed.js line (and, on WooCommerce, the PHP snippet). The buttons go at once.
- **npm:** remove the loadTryOn or useTryOn call, and npm uninstall ateliq .
- **Apps:** remove the screen that opens the web view.
- Tell us, and we remove your domains, so the try-on can't open on your site again. Orders already placed keep their ateliq_session value; it is a random visit id and identifies no one.

## Also

- [ateliq on npm](https://www.npmjs.com/package/ateliq): ateliq/tryon , ateliq/react , and the [JavaScript SDK](https://ateliq.co/docs/sdk/) for the Ateliq API.
- ateliq on PyPI: the try-on helpers above, and the Python SDK for the Ateliq API.
- [Ateliq CLI](https://ateliq.co/docs/cli/): npx ateliq tryon YOUR-ATELIQ-ADDRESS prints your line and your app address.
- In-store try-on on the Ateliq Mirror and Counter: [Try-on and See it for real](https://ateliq.co/docs/in-store/try-on/).

**Evaluating Ateliq?** See it on your own catalogue in a 30-minute walkthrough, or open our demo store now.

[Book a walkthrough](https://cal.id/nagent/product-walkthrough?duration=30)[Try the live demo](https://ateliq.co/#live-demo)

Something missing or unclear? Write to [pb@ateliq.co](mailto:pb@ateliq.co) and we will answer and fix this page. Last reviewed 4 December 2026.

On this page
- [What the shopper sees](#what-the-shopper-sees)
- [What you need from Ateliq](#what-you-need-from-ateliq)
- [Shopify](#shopify)
- [Route A: paste one line (no developer needed)](#route-a-paste-one-line-no-developer-needed)
- [Route B: npm, for developer teams](#route-b-npm-for-developer-teams)
- [Next.js and headless stores](#next-js-and-headless-stores)
- [The ateliq/tryon API](#the-ateliq-tryon-api)
- [WooCommerce](#woocommerce)
- [Any other website](#any-other-website)
- [iOS and Android apps](#ios-and-android-apps)
- [iOS (Swift, WKWebView)](#ios-swift-wkwebview)
- [Android (Kotlin, WebView)](#android-kotlin-webview)
- [React Native and Flutter](#react-native-and-flutter)
- [Python backends](#python-backends)
- [Order attribution](#order-attribution)
- [Privacy](#privacy)
- [Content-Security-Policy](#content-security-policy)
- [Troubleshooting](#troubleshooting)
- [Remove it](#remove-it)
- [Also](#also)
