Skip to main content

Loyalty Widget

The LoyaltyOS Widget (apps/widget) is an embeddable Web Component built with Lit. Add a loyalty panel to any website with a single script tag. Themes via CSS custom properties. ~45 KB gzipped.

Quick Start​

Script tag​

<script type="module" src="https://cdn.example.com/loyalty-widget.js"></script>

<loyalty-widget
api-url="https://api.example.com"
api-key="dev-key"
program-id="prog_dev"
member-id="mem_001"
token="jwt-session-token"
mode="full"
lang="en"
></loyalty-widget>

npm​

pnpm add @loyaltyos/widget
import "@loyaltyos/widget";

Attributes​

AttributeTypeDefaultDescription
api-urlstring—LoyaltyOS API base URL (required)
api-keystring—API key for authentication (required)
program-idstring—Program ID for multi-tenant scoping (required)
member-idstring—Member ID for personalization
tokenstring—JWT session token (from magic-link auth)
modestring"full"Display mode: "full" or "mini"
langstring"en"Language: "en" or "es"

Display Modes​

Full mode (mode="full")​

Shows all sub-components: points card, tier card with progress bar, top 3 rewards, badges gallery.

Mini mode (mode="mini")​

Compact single-card view with points balance, current tier name, and quick "View rewards" link.

Standalone Components​

<loyalty-points-card
api-url="https://api.example.com"
api-key="dev-key"
program-id="prog_dev"
member-id="mem_001"
token="jwt-token"
></loyalty-points-card>

<loyalty-tier-card ...></loyalty-tier-card>
<loyalty-rewards-top3 ...></loyalty-rewards-top3>
<loyalty-badges-gallery ...></loyalty-badges-gallery>

Theming​

Override CSS custom properties to match your brand:

loyalty-widget {
--loy-font-family: "Inter", sans-serif;
--loy-color-primary: #7c3aed;
--loy-color-primary-text: #ffffff;
--loy-color-surface: #ffffff;
--loy-color-text: #0f172a;
--loy-color-text-secondary: #64748b;
--loy-color-success: #16a34a;
--loy-color-warning: #ea580c;
--loy-radius-sm: 4px;
--loy-radius-md: 8px;
--loy-radius-lg: 12px;
--loy-space-sm: 8px;
--loy-space-md: 16px;
--loy-space-lg: 24px;
}

Events​

EventWhen
loyalty:readyWidget has finished loading data
loyalty:errorAPI call failed
loyalty:redeem-successReward was redeemed successfully
loyalty:wishlist-updatedWishlist state changed
document.querySelector("loyalty-widget").addEventListener("loyalty:ready", () => {
console.log("Widget is ready");
});

Build​

pnpm --filter @loyaltyos/widget build

Output in apps/widget/dist/: loyalty-widget.js (ES module) and loyalty-widget.umd.cjs (UMD fallback).

Browser Support​

All modern browsers that support Web Components (Chrome, Firefox, Safari, Edge). No polyfills needed.