Blazier Wishlist exposes a small, stable surface for themes and agencies: a JavaScript API on window.Blazier, DOM events on document, a few markup hooks, and CSS custom properties. Everything on this page is part of the public contract; anything not listed here (including Blazier._) is internal and may change.

The storefront script is loaded by the Blazier Wishlist app embed, so the embed must be on for any of this to work.

Waiting for the API

The script loads with defer, so window.Blazier may not exist yet when your code runs. Check for it, and otherwise wait for the blazier:ready event:

function withBlazier(fn) {
  if (window.Blazier) fn(window.Blazier)
  else document.addEventListener('blazier:ready', () => fn(window.Blazier), { once: true })
}

withBlazier((Blazier) => {
  console.log('Saved items:', Blazier.count())
})

JavaScript API

Product and variant IDs can be numbers, numeric strings, or Shopify GIDs such as gid://shopify/Product/123.

Method Returns Description
Blazier.add(item) boolean Saves an item. Returns true if the item was saved, or false if it was already in the list, the shopper must log in first, or the list picker opened instead.
Blazier.remove(item) boolean Removes an item from every list, or only from item.listId if given. Returns true if anything was removed.
Blazier.toggle(item) boolean Removes the item if it’s saved, otherwise saves it. Returns true if the item is now saved.
Blazier.has(productId, variantId?) boolean Whether the product (or that variant) is in any list.
Blazier.open(listId?) Promise<void> Opens the wishlist drawer, optionally on a specific list. Loads the drawer code on first use.
Blazier.count() number The number of distinct saved items across all lists.
Blazier.on(event, callback) void Subscribes to an event (names without the blazier: prefix, for example 'add'). The callback receives the event detail.
Blazier.off(event, callback) void Removes a subscription added with on.

The item argument is an object:

{
  productId: string | number      // required
  variantId?: string | number     // optional; omit to save the product
  listId?: string                 // optional; defaults to the shopper's default list
}

Calls update the screen immediately. Saving to the server happens in the background, and if the server rejects a change (for example because a limit was reached), it’s rolled back and a limit event fires.

Example: a custom save button

<button type="button" class="my-save" data-product-id="{{ product.id }}">Save</button>

<script>
  document.addEventListener('click', (e) => {
    const btn = e.target.closest('.my-save')
    if (!btn || !window.Blazier) return
    const saved = window.Blazier.toggle({ productId: btn.dataset.productId })
    btn.setAttribute('aria-pressed', String(saved))
  })
</script>

DOM events

Every event is a CustomEvent dispatched on document. Read the payload from event.detail.

Event detail When
blazier:ready { count } The API is available on window.Blazier.
blazier:add { productId, variantId, listId } An item was saved.
blazier:remove { productId, variantId } An item was removed.
blazier:change { count } The saved items changed; count is the new Blazier.count().
blazier:limit { code, productId?, variantId? } The server refused a change. code is limit_reached (the store’s monthly limit), list_cap (too many lists) or item_cap (list is full).
blazier:cart { variantIds } Saved items were added to the cart from the drawer or wishlist page. Use it to refresh a cart drawer or count.
document.addEventListener('blazier:cart', (event) => {
  // Refresh your theme's cart count or cart drawer here.
  console.log('Added to cart:', event.detail.variantIds)
})

Markup hooks

Markup Effect
<blz-heart product-id="…" variant-id="…"></blz-heart> A heart button. variant-id is optional.
<blz-button product-id="…" variant-id="…"></blz-button> An “Add to wishlist” button with a label. It follows the selected variant in the page’s product form unless it has the fixed attribute.
Any element with data-blz-open Opens the wishlist drawer when clicked.
Any element with data-blz-count Its text is kept set to the saved item count, and it’s hidden while the count is zero.

Both elements get a saved attribute while the item is saved, and their inner <button> gets aria-pressed="true". Style them with blz-heart[saved] or [aria-pressed="true"].

<a href="/apps/blazier/wishlist" data-blz-open>
  Wishlist <span data-blz-count hidden></span>
</a>

CSS custom properties

All Blazier styles use low specificity (:where() and element selectors), so your theme’s rules win. Set these properties on :root, a section, or a single element.

Hearts and buttons

Property Default Controls
--blz-accent currentColor Icon and button color. Also set by the embed’s Accent color.
--blz-heart 36px Heart size.
--blz-heart-bg translucent white Heart background.
--blz-icon 20px Icon size inside hearts and buttons.
--blz-btn-h 44px Minimum button height.
--blz-btn-pad 0.6em 1em Button padding.
--blz-radius 4px Button corner radius.
--blz-fb-x 8px Card heart (added automatically) distance from the image’s right edge.
--blz-fb-y 8px Card heart distance from the image’s top edge.

Drawer, dialogs and wishlist page

These apply inside .blz-root (drawer and dialogs) and #blazier-page (wishlist and shared-list pages).

Property Default Controls
--blz-accent #111 Primary buttons, focus rings, active tabs.
--blz-on-accent #fff Text on accent backgrounds.
--blz-bg #fff Panel background.
--blz-fg #111 Text color.
--blz-muted #6b6b6b Secondary text.
--blz-line #e5e5e5 Borders and dividers.
--blz-radius 6px Corner radius.
--blz-gap 12px Base spacing.
--blz-w 420px Drawer width.
--blz-z 2147483000 Stacking order of the drawer and dialogs.
--blz-font inherit Font shorthand.
:root {
  --blz-accent: #0f766e;
  --blz-heart: 32px;
}
.blz-root,
#blazier-page {
  --blz-radius: 0;
  --blz-w: 380px;
}

Stability

The methods, events, markup hooks and custom properties on this page are a stable contract. New ones may be added; existing ones won’t be removed or changed incompatibly without notice in the changelog.

Questions or requests? Email support@blazier.app.