Headless Try-On Architecture: Hydrogen, Next.js & Framer with Style Swap AI
Style Swap AI is purpose-built for headless Shopify storefronts: HMAC-verified App Proxy calls, typed DOM events, and Storefront Cart API bundles—without sacrificing Core Web Vitals or shopper privacy.
Customize `StyleSwapTryOn.tsx` Property Controls & Preview Live on a Framer Canvas
From Casual Mirror Selfies to 10-Second Dubai Luxury Lookbook Reels
Cast across a cosmopolitan UAE lineup (Emirati/Arab, Afro-Arab, South Asian, Mediterranean & East Asian models) with automatic modest-luxury restyling, 100mm macro fabric close-ups, and Sweet Pants SS25–inspired 3×3 Editorial Bento Lookbook Grids.
Dusty Slate-Blue Brushed Mohair Cardigan & Ivory Palazzo Trousers
Restyled from a cropped mirror selfie into a full-length Dubai modest-luxury studio look with mother-of-pearl buttons & lettuce-edge cuffs.



Executive Summary: Unlock Headless Try-On Without Platform Constraints
Style Swap AI decouples try-on from the Shopify theme, so fully custom Hydrogen, Next.js, and Framer storefronts can deliver 8–12 second AI outfit previews with zero photo storage. This reference architecture covers the HMAC-verified App Proxy, the three custom DOM events, and multi-SKU bundle checkout via the Storefront Cart API.
- Signed App Proxy routes at /apps/try-on/* keep inference and shopper photos server-side; your storefront ships only a lightweight launcher, so LCP stays clean and CLS is zero.
- Typed DOM events—seed-try-on:open, seed-try-on:add-to-cart, seed-try-on:complete-look-add—let any Hydrogen, Next.js, or Framer component open the modal and mutate cart state. Full embed & dev events unlock on the Runway Plan ($49.99/mo).
- Complete the Look layers up to 3 garments (top + bottom + outerwear) from custom.pair_with metafields or the Shopify Product Recommendations API, then posts every SKU in a single cart mutation.
- privacyZeroPhotoStorage is on by default: EXIF stripped client-side (maxDim 1400px), TLS 1.3 transport, volatile-RAM processing—built for GDPR, UAE PDPL, Saudi PDPL, and luxury shoppers.
Style Swap AI vs. Legacy Theme-Only Try-On & Static Lookbooks for Headless
| Requirement | Style Swap AI (`seed-try-on`) | Legacy Theme-Only Try-On Widgets | Static Lookbook / Manual Styling Baseline |
|---|---|---|---|
| Headless integration (Hydrogen, Next.js, Framer) | ✓ Signed App Proxy + typed DOM events; zero theme dependency | ✕ Locked to Online Store 2.0 theme blocks; breaks on headless | Lookbooks must be rebuilt per framework and per campaign |
| Multi-garment outfit try-on (up to 3 pieces) | ✓ Layered inference driven by custom.pair_with metafields or Product Recommendations API | ✕ Single garment only; no cross-sell or bundle logic | Static shoots can't adapt to shopper-built combinations |
| Shopper privacy (zero photo storage) | ✓ Client-side EXIF stripping, TLS 1.3, volatile-RAM processing (default on) | ✕ Selfies often persisted in merchant databases—GDPR/PDPL exposure | No shopper photos, but zero personalization |
| Performance & CLS on headless pages | ✓ Fixed-position pill, reserved dimensions, lazy-loaded inference—zero CLS | ✕ Theme widgets frequently inject render-blocking scripts | No runtime cost, but no interactive try-on either |
| Cart integration (Storefront Cart API) | ✓ seed-try-on:add-to-cart / complete-look-add payloads map to one multi-line cartLinesAdd | ✕ Manual cart form overrides; no multi-SKU bundle | Single-product adds only |
| Social story generation (9:16) | ✓ Client-side canvas compositor exports 1080x1920 cards for WhatsApp & Instagram via Web Share API | ✕ No story export; requires third-party design tools | Campaign imagery must be manually resized per placement |
| Lead capture & ROI attribution | ✓ Server-side Klaviyo 'Tried On Product' event + orders/paid webhook revenue attribution (Runway Plan and above) | ✕ Client-only workarounds; no closed-loop revenue attribution | No try-on data exists to attribute |
HMAC-Verified App Proxy & Zero-CLS Floating Pill
Style Swap AI exposes a signed App Proxy at /apps/try-on/* on your shop's domain. Every request is HMAC-SHA256-verified against your app proxy secret, so only your storefront can invoke the Seedream 5.0 Pro inference engine. On the client you ship only a lightweight launcher: a fixed-position floating pill with reserved dimensions (zero CLS) that lazy-loads the try-on module on first interaction—your LCP and INP budgets stay intact.
- Hydrogen: render the pill from a client component in root.tsx. Next.js App Router: load the launcher via next/script with the afterInteractive strategy in app/layout.tsx and keep listeners inside 'use client' components.
- Framer: paste the same snippet into a custom code block or fire seed-try-on:open from a code override—the proxy is domain-agnostic, so there is no per-framework build.
- Pass productHandle, variantId, and optional pair_with context in the event detail to pre-stage a 3-piece outfit before the modal opens.
- privacyZeroPhotoStorage is true by default: EXIF is stripped and the selfie compressed to maxDim 1400px in the browser before anything leaves the device.
// Hydrogen / Next.js client component: open the try-on modal
const handleTryOn = (productHandle, variantId) => {
window.dispatchEvent(new CustomEvent('seed-try-on:open', {
detail: { productHandle, variantId, mode: 'quick' }
}));
};
// Framer: same event from a code override — the proxy is domain-agnostic
const openTryOn = () => {
window.dispatchEvent(new CustomEvent('seed-try-on:open', {
detail: { productHandle: '{{product.handle}}' }
}));
};React & Framer Integration with seed-try-on DOM Events
All communication between the try-on engine and your UI runs over three typed CustomEvents on window—seed-try-on:open, seed-try-on:add-to-cart, and seed-try-on:complete-look-add. Because the contract is event-based, it works identically in Hydrogen client components, Next.js 'use client' components, and Framer code overrides: no SDK, no prop drilling, no hydration mismatch. Listen for the two cart events to update state, fire analytics, and post the bundle.
- Register listeners once in a useEffect with a cleanup function; seed-try-on:add-to-cart delivers variant ID and quantity payloads ready for your existing cart mutation.
- seed-try-on:complete-look-add carries up to 3 variant IDs—map it to a single cartLinesAdd (Storefront Cart API) so the whole outfit lands in one checkout and one AOV data point.
- Reposition or relabel the pill with data attributes; it is position: fixed with reserved dimensions, so tuning it never touches layout.
- Full embed controls and dev events unlock on the Runway Plan ($49.99/mo); every plan starts with a 7-day free trial including up to 50 try-on credits.
// Any 'use client' component (Next.js) or Hydrogen client component
useEffect(() => {
const onAddToCart = (e) => cartLinesAdd(e.detail); // { variantId, quantity }
const onCompleteLook = (e) => cartLinesAdd({ lines: e.detail.items }); // up to 3 SKUs
window.addEventListener('seed-try-on:add-to-cart', onAddToCart);
window.addEventListener('seed-try-on:complete-look-add', onCompleteLook);
return () => {
window.removeEventListener('seed-try-on:add-to-cart', onAddToCart);
window.removeEventListener('seed-try-on:complete-look-add', onCompleteLook);
};
}, []);Multi-Garment Outfit Try-On with Storefront Cart API Bundles
Complete the Look is the highest-leverage merchandising surface on a headless build. Style Swap AI reads custom.pair_with metafields (a JSON list of variant IDs) on each product, falls back to DOM cross-sell detection or the Shopify Product Recommendations API, and layers top + bottom + outerwear in a single inference pass. When the shopper accepts, seed-try-on:complete-look-add hands your cart mutation every SKU at once.
- Merchandising: set custom.pair_with on hero SKUs to steer shoppers toward high-margin layers—blazer over slip dress, abaya over loungewear—and the AI renders exactly the combinations you curate.
- Long-tail catalog? Skip metafields and let the Product Recommendations API fallback rank visually compatible pieces automatically.
- Checkout: map the event payload to one cartLinesAdd mutation with multiple merchandise lines so the bundle posts a single checkout—no sequential adds, no dropped items.
- Measure: segment the Klaviyo 'Tried On Product' event by look_type = complete_look to compare bundle AOV against single-garment try-ons.

Zero-Photo Storage, 2K Inference & Klaviyo Attribution
Headless shoppers expect app-grade privacy and speed. privacyZeroPhotoStorage (on by default) compresses and strips EXIF in the browser (maxDim 1400px), transmits over TLS 1.3, and processes the selfie in volatile RAM only—nothing is written to disk, your database, or Shopify Admin. Quick Mode returns 1K previews in ~8–10 seconds; Studio Mode renders 2K high-definition output, with Priority 2K generation on the Unlimited Fashion Plan ($199.99/mo).
- Compliance-ready for GDPR, UAE PDPL, and Saudi PDPL: no selfie is ever persisted or merchant-visible. Say so on the PDP—it converts privacy-sensitive and modest-fashion shoppers.
- Protect Core Web Vitals: the launcher is a few KB and the inference module lazy-loads on the first seed-try-on:open, so LCP and INP are untouched until a shopper opts in.
- Klaviyo sync (Runway Plan, $49.99/mo and above) fires a server-side 'Tried On Product' event—build abandoned-try-on flows and segment by look_type or atmosphere remix.
- The orders/paid webhook attributes revenue and AOV to each try-on session, so you can reconcile ROI against your plan's included credits and overage rate ($0.10–$0.16 per try-on by tier).
// Server-side Klaviyo event fired by Style Swap AI (Runway Plan and above)
{
"event": "Tried On Product",
"customer_properties": { "$email": "shopper@example.com" },
"properties": {
"product_id": 123456789,
"variant_id": 987654321,
"look_type": "complete_look",
"try_on_mode": "quick",
"storefront": "hydrogen"
}
}Common Founder & Technical Questions: Hydrogen & Next.js Headless
How do I verify the HMAC signature on the App Proxy in a Hydrogen or Next.js storefront?
Shopify appends a signature query parameter to every proxied request. Recompute the HMAC-SHA256 of the sorted query string (excluding the signature) with your app proxy secret and compare using a constant-time check. Style Swap AI ships a Node.js reference implementation that drops into Hydrogen server utilities and Next.js route handlers.
Can I use Style Swap AI with Next.js App Router without any Shopify theme files?
Yes—nothing touches your theme. Add the launcher script to app/layout.tsx with the afterInteractive strategy, keep event listeners inside 'use client' components, and wire seed-try-on:add-to-cart to your existing cart mutation. The floating pill and all try-on logic load from the App Proxy.
Does the Complete the Look bundle work with Shopify's Storefront Cart API?
Yes. When a shopper accepts a 3-piece look, seed-try-on:complete-look-add fires with an array of variant IDs and quantities. Map it to a single cartLinesAdd (or cartCreate) mutation with multiple merchandise lines—one checkout, all three garments, one clean AOV data point.
How does PrivacyZeroPhotoStorage comply with GDPR and UAE PDPL?
The selfie is compressed and stripped of EXIF metadata client-side (max dimension 1400px), sent over TLS 1.3, and processed in volatile RAM only. It is never written to disk, a merchant database, or Shopify Admin, and the memory is wiped after the response—satisfying GDPR, UAE PDPL, and Saudi PDPL requirements out of the box.
What is the try-on latency on headless, and does it hurt CLS?
Quick Mode returns a 1K image in ~8–10 seconds; Studio Mode renders 2K high-definition output with priority generation on the Unlimited Fashion Plan ($199.99/mo). The pill is position: fixed with reserved dimensions—zero cumulative layout shift—and the AI bundle lazy-loads only when a shopper starts a try-on.
Which plan do I need for headless embeds, dev events, and Klaviyo?
All plans include a 7-day free trial with up to 50 try-on credits. Trend ($19.99/mo, 100 try-ons/mo, $0.16 per overage try-on) covers core try-on; Runway ($49.99/mo, 350 try-ons/mo, $0.14 overage) unlocks full embed & dev events plus Klaviyo sync—the headless sweet spot; Unlimited Fashion ($199.99/mo, 2,000 try-ons/mo, $0.10 overage) adds Priority 2K generation, unlimited shares, and a dedicated CSM.





