Skip to main content

Widget Embedding

The MLM Platform provides embeddable widgets for displaying referral information and capturing leads.

Overview

Widgets are embedded using iframes with JWT-based authentication (Widget Access Tokens or WATs).

Step 1: Configure Allowed Origins

Before embedding widgets, configure allowed origins in the Admin Dashboard:
  1. Navigate to Settings > Widget Configuration
  2. Add your application’s origin(s):
    • https://yourapp.com
    • https://www.yourapp.com
    • http://localhost:3000 (for development)
  3. Click Save
Only add origins you control. Unauthorized origins will be rejected.

Step 2: Generate a Widget Access Token

Request a WAT from your backend:
Response:

Step 3: Embed the Widget

Use the token to embed the widget iframe:

React Component

Widget Types

Displays the user’s referral link with copy functionality:

Commission Stats Widget

Shows commission balance and history:

Lead Capture Widget

Form for capturing leads with referral attribution:

Content Security Policy (CSP)

If your application uses CSP, add the widget domain to frame-src:
Or in Next.js middleware:

Token Refresh

WATs expire after 1 hour. Implement token refresh:

Troubleshooting

Widget Not Loading

  1. Check origin configuration: Verify your origin is in the allowed list
  2. Check token: Ensure token is valid and not expired
  3. Check CSP: Verify frame-src allows the widget domain
  4. Check browser console: Look for CORS or CSP errors

CORS Errors

Solution: Add the widget domain to your CSP frame-src directive.

Token Expired

Solution: Implement token refresh as shown above.

Origin Not Allowed

Solution: Add your origin to the allowed origins list in the Admin Dashboard.