Learn how to create an embedded referral dashboard with Dub for your users to join your partner program without leaving your app.
Embedded referral dashboards require an Advanced
plan subscription or higher.
With Dub Partners, you can build an embedded referral dashboard that lives directly inside your application in just a few lines of code.This way, your users can automatically enroll in your partner program without needing to leave your app and sign up on a third-party platform.
In this guide, we’ll walk you through the steps to get started with Dub’s embedded referral dashboard feature.
First, you need to create a server API route that generates a public token, which will be used by the embedded referral dashboard to fetch real-time conversions and earnings data from the client-side.
If you’re using our server-side SDKs, you can generate an embed token using the dub.embedTokens.referrals method.
Copy
Ask AI
const { publicToken } = await dub.embedTokens.referrals({ tenantId: user.id, // the user's ID within your application partner: { name: user.name, // the user's name email: user.email, // the user's email image: user.image, // the user's image/avatar tenantId: user.id, // the user's ID within your application groupId: "grp_xxxxxx", // optional: the partner's group ID on Dub (https://d.to/groups) },});
If you’re not using our server-side SDKs, you can generate an embed token using our REST API instead (via the POST /tokens/embed/referrals endpoint).
JavaScript
Copy
Ask AI
const response = await fetch("https://api.dub.co/tokens/embed/referrals", { method: "POST", body: JSON.stringify({ tenantId: user.id, // the user's ID within your application partner: { name: user.name, // the user's name email: user.email, // the user's email image: user.image, // the user's image/avatar tenantId: user.id, // the user's ID within your application groupId: "grp_xxxxxx", // optional: the partner's group ID on Dub (https://d.to/groups) }, }),});const data = await response.json();const { publicToken } = data;
Refer to the full API reference to learn more about the properties you can pass to the POST /tokens/embed/referrals endpoint.