Drop-in Web Components that render inside a Shadow DOM - zero CSS conflicts, framework-agnostic, and ready in a single script tag. Works with React, Vue, Angular, or plain HTML.
If you use a bundler (Vite, Next.js, Webpack), install via npm:
npm install @returningai/widget-sdkOr skip the install and load the SDK from a CDN - see the attribute auth example below.
Every widget needs to identify the user so it can display their rewards, points, and tier status. Choose an approach based on whether you have a backend available:
<script
src="https://unpkg.com/@returningai/widget-sdk/dist/rai-widget.iife.js"
data-widget-id="YOUR_WIDGET_ID"
data-widget-type="store"
data-container="returning-ai-widget-YOUR_WIDGET_ID"
data-api-url="YOUR_API_URL"
data-widget-url="YOUR_WIDGET_URL"
data-email="user@example.com"
data-userId="USR-9a3f2b"
data-firstname="Jane"
data-lastname="Doe"
data-custom-tier="gold"
></script>Every widget accepts HTML attributes for common options:
theme - "light" or "dark" (default: "light")width / height - any CSS length valueFor the full attribute reference, see the Configuration page.
Identify users by passing data attributes directly on the widget element.
Sign users in server-side so the widget loads pre-authenticated.
React, Vue, Angular, and plain HTML examples.
Every attribute, event, and global API method.
How the Shadow DOM isolation, lazy loading, and token flow work under the hood.