Developers
Put Miradava on your site
Give your clients a virtual try-on on your own booking page, salon site or storefront. One script tag, no build step, no framework required. Photos are never stored.
1 · Floating button
Adds a “Try a new cut” button to the corner of every page. Clicking it opens the try-on in a modal. When a booking URL is set, a “Book this cut” button sends the client there with the chosen style filled in.
<script src="https://your-miradava-host/widget.js" async
data-button-text="Try a new cut"
data-accent="#d4a24c"
data-book-url="https://your-shop.com/book?style={style}&color={color}"></script>2 · Inline embed
Renders the studio inside your page. It resizes itself to fit its content, so it never scrolls inside a box.
<div data-miradava
data-styles="low-taper-fade,mid-fade,afro,twists"
data-accent="#d4a24c"></div>
<script src="https://your-miradava-host/widget.js" async data-button="false"></script><!-- Any element can open the try-on, optionally pre-selecting a cut -->
<button data-miradava-open="french-crop">Preview the French Crop</button>Options
Set these as data-* attributes on the script tag (site-wide defaults) or on an inline element, or pass them as camelCase keys to Miradava.open() / Miradava.mount().
| Attribute | What it does |
|---|---|
| data-styles | Comma-separated style ids to offer (default: all). |
| data-style / data-color | Style and colour pre-selected when the studio opens. |
| data-accent | Brand colour as hex, e.g. #d4a24c. Tints buttons and highlights. |
| data-brand | Name shown in the studio header instead of Miradava. |
| data-book-url | Booking link. {style} and {color} are replaced with the chosen ids. |
| data-cta | Label for the booking button (default “Book this cut”). |
| data-button-text | Floating button label (script tag only). |
| data-position | left or right — floating button corner (script tag only). |
| data-button | false to hide the floating button and use only the API / inline embeds. |
| data-return-image | true to include the rendered image (data URL) in render events. |
| data-height | Initial height in px for inline embeds (they auto-resize after load). |
JavaScript API & events
Listen with Miradava.on(event, fn) or window “miradava:<event>” events. Events: ready, photo, select, render, book, open, close, error. render includes the image only when return-image is on — the client's face is never sent to your page otherwise.
<script>
window.addEventListener("miradava:render", (e) => {
analytics.track("Hairstyle previewed", e.detail); // { styleId, colorId }
});
Miradava.on("book", ({ styleId, colorId }) => openBooking(styleId, colorId));
Miradava.open({ style: "mid-fade", color: "jet-black" });
</script>Plain iframe
No JavaScript at all: point an iframe at /embed. Every option above works as a query parameter.
<iframe
src="https://your-miradava-host/embed?styles=buzz-cut,crew-cut&accent=d4a24c&brand=Fresh%20Cuts"
allow="camera; web-share"
style="width:100%;height:820px;border:0;border-radius:16px"></iframe>REST API
Build your own UI. The catalogue is public. Render calls cost AI credits, so browsers can only call them from origins listed in the server's ALLOWED_ORIGINS; requests are also rate-limited per IP.
// 1. Catalogue (public, CORS *)
const { styles, colors } = await fetch("https://your-miradava-host/api/styles").then((r) => r.json());
// 2. Render (server-to-server, or from an origin in ALLOWED_ORIGINS)
const res = await fetch("https://your-miradava-host/api/hairstyle", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ image: "data:image/jpeg;base64,…", styleId: "mid-fade", colorId: "natural" }),
});
// → text/event-stream: image_generation.partial_image … image_generation.completed
// each event's data is JSON with a base64 PNG in "b64_json"Style & colour ids
low-taper-fademid-fadehigh-skin-fadeburst-fadebuzz-cutcrew-cutfrench-croptextured-quiffslick-backcurtainsman-bunafrowavestwistsbox-braidscornrowsknotless-braidsnaturaljet-blackdark-browncaramelplatinumsilverNeed camera access inside the widget? Your site must be served over HTTPS.