Referral Rewards
1 variant
A compact referral card with a copyable invite link, a reward track that unlocks tiers as friends join, and a live list of invited friends.
Invite tracker
referral-rewards.tsxNew friends slide in at the top while the progress fill eases toward the next tier, and each tier pops with a small burst as it unlocks. Earned credit and counts roll as they change.
Invite friends
Get $10 in credit for every friend who joins.
Rewards3 of 10
- 1: A $10 credit, unlocked
- 3: A $25 bonus, unlocked
- 5: A free month, locked
- 10: A free year, locked
2 more for a free month
Friends4
- Joined
Rafael Costa
Joined 2h ago
- Invited
Clara Webb
Invited yesterday
- Rewarded
Elise Varga
Joined Nov 9
- Rewarded
Owen Price
Joined Nov 4
TSXcomponents/previews/premium/referral-rewards-preview.tsx
"use client";
import { useInView, useReducedMotion } from "motion/react";
import { useCallback, useEffect, useRef, useState } from "react";
import {
DEFAULT_REFERRAL_FRIENDS,
type ReferralFriend,
ReferralRewards,
SAMPLE_REFERRAL_ARRIVALS,
} from "@/components/premium/referral-rewards";
const STEP_MS = 2600;
type DemoStep =
| { type: "arrive" }
| { type: "join"; id: string }
| { type: "reward"; id: string }
| { type: "hold" };
// Friends trickle in until every tier unlocks, then the demo starts over.
const SCRIPT: DemoStep[] = [
{ type: "arrive" },
{ type: "reward", id: "rafa" },
{ type: "arrive" },
{ type: "join", id: "clara" },
{ type: "reward", id: "zola" },
{ type: "arrive" },
{ type: "arrive" },
{ type: "reward", id: "milo" },
{ type: "arrive" },
{ type: "arrive" },
{ type: "hold" },
{ type: "hold" },
];
function applyStep(
friends: ReferralFriend[],
step: DemoStep,
arrival: ReferralFriend | undefined,
) {
if (step.type === "arrive")
return arrival ? [{ ...arrival }, ...friends] : friends;
if (step.type === "hold") return friends;
return friends.map((friend) =>
friend.id !== step.id
? friend
: step.type === "join"
? { ...friend, status: "joined" as const, meta: "Joined just now" }
: { ...friend, status: "rewarded" as const },
);
}
export function ReferralRewardsPreview() {
const reduce = useReducedMotion();
const ref = useRef<HTMLDivElement>(null);
const inView = useInView(ref, { amount: 0.4 });
const [friends, setFriends] = useState(DEFAULT_REFERRAL_FRIENDS);
const [step, setStep] = useState(0);
const [arrivals, setArrivals] = useState(0);
const [paused, setPaused] = useState(false);
const running = inView && !reduce && !paused;
useEffect(() => {
if (!running) return;
const id = window.setTimeout(() => {
if (step >= SCRIPT.length) {
setFriends(DEFAULT_REFERRAL_FRIENDS);
setArrivals(0);
setStep(0);
return;
}
const current = SCRIPT[step];
setFriends((list) =>
applyStep(list, current, SAMPLE_REFERRAL_ARRIVALS[arrivals]),
);
if (current.type === "arrive") setArrivals((n) => n + 1);
setStep((n) => n + 1);
}, STEP_MS);
return () => window.clearTimeout(id);
}, [running, step, arrivals]);
const invite = useCallback(
(email: string) =>
new Promise<void>((resolve) => {
window.setTimeout(() => {
setFriends((list) => [
{
id: `invite-${email}-${Date.now()}`,
name: email,
status: "invited",
meta: "Invited just now",
},
...list,
]);
resolve();
}, 900);
}),
[],
);
return (
<div ref={ref} className="flex w-full justify-center px-4 py-10">
<ReferralRewards
friends={friends}
onInvite={invite}
onRemind={() => {}}
onControlsActiveChange={setPaused}
/>
</div>
);
}
Source code is locked
Get access to install premium components and view the full source.
Open dashboardInstall
$ bunx --bun shadcn add @beui-pro/referral-rewards