Skip to Content
πŸš€ Finally launched β€” the long-awaited @incenta/sdk is live on npm. Get it β†’
DocsUI Bundles

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=β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  1. Browser loads widgets.js, which registers Custom Elements (<referral-share>, <referral-status>, etc.)
  2. HTML parser encounters your widget tag β†’ connectedCallback() fires
  3. Widget reads attributes (app-id, user-id, primary-color, etc.)
  4. Widget fetches user-specific data from Incenta API
  5. Widget renders interactive UI inside the tag

Lifecycle events

EventWhenWhat happens
Element parsedDOM readyconnectedCallback() fires
Attributes changedRuntimeattributeChangedCallback re-renders
Script loadedAfter fetchCustom Elements register globally
User context setVia user-id attrWidget 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:

AttributeTypeDescription
app-idstringYour Incenta app ID
user-idstringThe end-user viewing the widget

Optional attributes:

AttributeDefaultDescription
api-urlhttps://incenta.devAPI base URL
primary-color#3b82f6Theme color
border-radius8pxWidget corner radius
font-familysystemFont 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

  1. One script per page β€” include widgets.js once regardless of how many widgets you use
  2. Set user-id dynamically β€” widgets without a user context show instructions instead of data
  3. Style via attributes β€” use primary-color, border-radius, and font-family for basic theming
  4. Custom CSS β€” each widget renders inside a Shadow DOM (or scoped container) to avoid conflicts with your site’s styles
  5. Async loading β€” use async on the script tag so it doesn’t block page render
Last updated on