Quick Start
SylphxProvider for automatic user context and referral data fetching.import { ReferralCard } from '@sylphx/platform-sdk/react'ReferralCard
A complete referral interface that displays the user's unique referral link, referral statistics (referred count, earnings), and share buttons for social platforms. Supports multiple variants for different use cases.
import { ReferralCard } from '@sylphx/platform-sdk/react'
export function ReferralSection() {
return (
<div className="max-w-md">
<ReferralCard />
</div>
)
}Props
| Property | Type | Description |
|---|---|---|
variant | "full" | "compact"= "full" | Display variant - full shows all stats, compact is minimal |
showStats | boolean= true | Show referral statistics (count, earnings) |
showShareButtons | boolean= true | Show social share buttons |
showLeaderboard | boolean= false | Show referral leaderboard below the card |
leaderboardLimit | number= 5 | Number of users to show in leaderboard |
shareMessage | string= "Join me on {appName}!" | Custom message for social shares |
shareChannels | ShareChannel[]= ["copy", "twitter", "email"] | Which share buttons to show |
className | string | Additional CSS classes for the card container |
onShare | (channel: string) => void | Callback when user clicks a share button |
onCopy | () => void | Callback when referral link is copied |
title | string= "Invite Friends" | Custom card title |
description | string= "Share your link and earn rewards" | Custom card description |
Variants
ReferralCard supports two variants optimized for different layouts:
// Full variant - ideal for dedicated referral pages
<ReferralCard variant="full" />
// Renders:
// +------------------------------------------+
// | Invite Friends |
// | Share your link and earn rewards |
// | |
// | +------------------------------------+ |
// | | https://app.com/ref/ABC123 [Copy] |
// | +------------------------------------+ |
// | |
// | [Twitter] [Email] [WhatsApp] [SMS] |
// | |
// | +----------+ +----------+ +--------+ |
// | | 12 | | $120 | | 8 | |
// | | Referred | | Earned | | Pending| |
// | +----------+ +----------+ +--------+ |
// +------------------------------------------+With Leaderboard
Enable the leaderboard to gamify your referral program and drive competition:
import { ReferralCard } from '@sylphx/platform-sdk/react'
export function ReferralPage() {
return (
<ReferralCard
showLeaderboard={true}
leaderboardLimit={10}
/>
)
}
// Renders the card plus:
// +------------------------------------------+
// | Top Referrers This Month |
// | |
// | 1. Alice Chen 25 referrals [Crown Icon] |
// | 2. Bob Smith 18 referrals [Medal Icon] |
// | 3. Carol Davis 15 referrals [Medal Icon] |
// | 4. David Lee 12 referrals |
// | 5. Eve Wilson 8 referrals |
// | ... |
// | You: #7 with 5 referrals |
// +------------------------------------------+Share Channels
Customize which share buttons appear:
copyCopy link to clipboard
twitterShare on Twitter/X
emailShare via email
whatsappShare on WhatsApp
smsShare via SMS
nativeNative share dialog
<ReferralCard
shareChannels={['copy', 'twitter', 'whatsapp', 'email']}
shareMessage="Join me on Acme! Use my link for 20% off your first month."
onShare={(channel) => {
analytics.track('referral_shared', { channel })
}}
/>Advanced Examples
<ReferralCard
className="bg-gradient-to-br from-purple-500/10 to-pink-500/10 border-purple-500/20"
title="Earn $10 for Every Friend"
description="They get 20% off, you get $10 credit"
variant="full"
showLeaderboard={true}
/>Auto-fetching
Stats Display
The ReferralCard displays three key metrics when showStats is enabled:
Referred Count
Total number of users who signed up using this referral link
Earnings
Total rewards earned from successful referrals (credits, discounts, etc.)
Pending
Referrals awaiting conversion or verification period completion
// Show only stats without share buttons
<ReferralCard
showStats={true}
showShareButtons={false}
/>Leaderboard
The integrated leaderboard gamifies your referral program by showing top referrers:
<ReferralCard
showLeaderboard={true}
leaderboardLimit={10}
leaderboardPeriod="month" // 'week' | 'month' | 'all-time'
/>
// Leaderboard features:
// - Top 3 users get special badges (Crown, Gold Medal, Silver Medal)
// - Current user's position is highlighted
// - Shows referral count and earnings for each user
// - Respects privacy - shows display name, not full detailsLeaderboard Badges
1st Place
Gold crown icon with highlighted row
2nd Place
Silver medal icon
3rd Place
Bronze medal icon
Related Hooks
For more control, use the useReferral hook to build custom UI:
import { useReferral } from '@sylphx/platform-sdk/react'
function CustomReferralUI() {
const {
referralCode,
referralUrl,
stats,
leaderboard,
loading,
error,
copyUrl,
copied,
share,
} = useReferral()
if (loading) return <Skeleton />
if (error) return <ErrorMessage error={error} />
return (
<div>
{/* Custom referral UI */}
<input value={referralUrl} readOnly />
<button onClick={copyUrl}>
{copied ? 'Copied!' : 'Copy Link'}
</button>
<div className="stats">
<span>{stats.signups} signups</span>
<span>${stats.earned} earned</span>
</div>
<div className="share-buttons">
<button onClick={() => share('twitter')}>
Tweet
</button>
<button onClick={() => share('email')}>
Email
</button>
</div>
</div>
)
}Best Practices
Use Full Variant for Dedicated Pages
The full variant with leaderboard works best on dedicated referral pages where users are focused on sharing.
Compact for Secondary Placements
Use compact variant in sidebars, footers, or as a widget to maintain visibility without taking too much space.
Track Share Actions
Always use onShare and onCopy callbacks to track which channels drive the most referrals.
Customize Share Messages
A compelling shareMessage can significantly improve conversion rates. Include the benefit for both parties.
Ready to grow with referrals?
Learn more about configuring rewards, fraud prevention, and tracking referral performance.