UI Bundles
Embeddable widgets you drop into your website with a single <script> tag. They auto-render interactive UI for referrals, rewards, and marketplace features.
How it works
Your Website Incenta CDN
βββββββββββββββββββ ββββββββββββββββ
β <script src=".. ββββfetchβββββ widgets.js β
β /widgets.js"> βββscriptβββββ (Custom Elems)β
β β ββββββββββββββββ
β <referral-share βββconnectedCallback()βββ
β app-id="..." β βΌ
β user-id="..."β ββββββββββββββββββββ
β ></referral- ββββfetchβββββ GET /api/v1/ β
β share> βββJSONββββββ referrals?userId=β
βββββββββββββββββββ ββββββββββββββββββββ- Browser loads
widgets.js, which registers Custom Elements (<referral-share>,<referral-status>, etc.) - HTML parser encounters your widget tag β
connectedCallback()fires - Widget reads attributes (
app-id,user-id,primary-color, etc.) - Widget fetches user-specific data from Incenta API
- Widget renders interactive UI inside the tag
Lifecycle events
| Event | When | What happens |
|---|---|---|
| Element parsed | DOM ready | connectedCallback() fires |
| Attributes changed | Runtime | attributeChangedCallback re-renders |
| Script loaded | After fetch | Custom Elements register globally |
| User context set | Via user-id attr | Widget fetches that userβs data |
Referral Widgets
<referral-share>
Displays a userβs referral link with a copy button and social share buttons.
Required attributes:
| Attribute | Type | Description |
|---|---|---|
app-id | string | Your Incenta app ID |
user-id | string | The end-user viewing the widget |
Optional attributes:
| Attribute | Default | Description |
|---|---|---|
api-url | https://incenta.dev | API base URL |
primary-color | #3b82f6 | Theme color |
border-radius | 8px | Widget corner radius |
font-family | system | Font stack |
Example:
<script src="https://incenta.dev/widgets.js"></script>
<referral-share
app-id="cmq860vjz000046s0t1cpr27m"
user-id="user_abc123"
primary-color="#3b82f6"
border-radius="8px"
></referral-share><referral-status>
Shows the userβs referral count, earned rewards, and progress toward next tier.
<referral-status
app-id="cmq860vjz000046s0t1cpr27m"
user-id="user_abc123"
primary-color="#10b981"
></referral-status><referral-leaderboard>
Displays top referrers to encourage competition.
<referral-leaderboard
app-id="cmq860vjz000046s0t1cpr27m"
primary-color="#f59e0b"
limit="10"
></referral-leaderboard>Leaderboard does not require user-id (it shows global rankings).
Marketplace Widgets
Marketplace widgets let users browse and redeem rewards from business partners.
<marketplace-listings>
Browse available rewards with search and pagination.
<script src="https://incenta.dev/widgets.js"></script>
<marketplace-listings
api-url="https://incenta.dev"
primary-color="#3b82f6"
border-radius="12px"
limit="12"
></marketplace-listings><marketplace-listing-detail>
Show a single reward listing detail.
<marketplace-listing-detail
api-url="https://incenta.dev"
listing-id="lst_abc123"
primary-color="#3b82f6"
></marketplace-listing-detail><marketplace-user-redemptions>
Show a userβs redemption history.
<marketplace-user-redemptions
api-url="https://incenta.dev"
app-id="cmq860vjz000046s0t1cpr27m"
user-id="user_abc123"
primary-color="#3b82f6"
></marketplace-user-redemptions><marketplace-redeem-form>
Inline redemption form for a specific listing. Requires an API key for authentication.
<marketplace-redeem-form
api-url="https://incenta.dev"
listing-id="lst_abc123"
api-key="rk_xxxxx"
primary-color="#3b82f6"
></marketplace-redeem-form>Implementation guide
Step 1: Add the script
Place the script tag once per page, ideally in the <head> or at the start of <body>:
<script src="https://incenta.dev/widgets.js" async></script>The async attribute is safe β widgets render when the element appears in the DOM, regardless of script load timing.
Step 2: Add the widget tag
Place the widget tag wherever you want it to render:
<referral-share
app-id="YOUR_APP_ID"
user-id="THE_USER_ID"
></referral-share>Step 3: Set the user context
The user-id attribute must be set dynamically to the currently logged-in userβs ID in your app. This is typically done server-side (SSR) or via JavaScript:
Server-rendered (PHP, Rails, Laravel, etc.):
<referral-share
app-id="<%= @app_id %>"
user-id="<%= current_user.id %>"
></referral-share>Client-rendered (React, Vue, etc.):
function ReferralWidget({ userId }) {
return (
<referral-share
app-id={process.env.NEXT_PUBLIC_APP_ID}
user-id={userId}
primary-color="#3b82f6"
/>
);
}Vanilla JS:
<referral-share id="my-widget" app-id="YOUR_APP_ID"></referral-share>
<script>
const userId = localStorage.getItem('userId') || 'guest';
document.getElementById('my-widget').setAttribute('user-id', userId);
</script>What the widget renders
When the user visits a page with the widget, they see:
ββββββββββββββββββββββββββββββββββ
β π Referral Share β
β β
β Your link: https://you.com/ β
β ?ref=ABC123 β
β β
β [π Copy] [π¦] [πΌ] [βοΈ] β
β β
β π₯ 3 referrals π 2 rewards β
ββββββββββββββββββββββββββββββββββThe widget handles all the API calls, styling, and interactivity. No additional code needed.
Testing & Preview
Use the UI Bundles SimulatorΒ to preview widgets with your app ID and custom theming before deploying.
Best practices
- One script per page β include
widgets.jsonce regardless of how many widgets you use - Set
user-iddynamically β widgets without a user context show instructions instead of data - Style via attributes β use
primary-color,border-radius, andfont-familyfor basic theming - Custom CSS β each widget renders inside a Shadow DOM (or scoped container) to avoid conflicts with your siteβs styles
- Async loading β use
asyncon the script tag so it doesnβt block page render