Referrals
The SDK supports referral program integration — fetching referral codes/stats and tracking new referrals.Service Methods
Referral functionality is available through theLoyaltyService (not wrapped in a dedicated hook).
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
LoyaltyService (not wrapped in a dedicated hook).
const { loyalty } = useStackfront();
// Get referral code and stats
const referral = await loyalty.getReferral(customerId);
// { referralCode: string; totalReferrals: number; rewardsEarned: number; shareUrl: string }
// Track a new referral
await loyalty.trackReferral({
referralCode: 'REF123',
referredCustomerId: 'gid://shopify/Customer/456',
orderId: 'gid://shopify/Order/789',
});
import { useLoyalty } from 'react-native-stackfront-sdk';
function ReferralRewards({ customerId }: { customerId: string }) {
const { account } = useLoyalty(customerId);
const [referral, setReferral] = useState<ReferralSdkResponse | null>(null);
useEffect(() => {
const { loyalty } = useStackfront();
// Access service directly for referral data
loyalty.getReferral(customerId).then(setReferral);
}, [customerId]);
if (!referral) return null;
return (
<View>
<Text>Your referral code: {referral.referralCode}</Text>
<Text>Total referrals: {referral.totalReferrals}</Text>
<Text>Rewards earned: {referral.rewardsEarned}</Text>
<ShareButton url={referral.shareUrl} />
</View>
);
}
{
referralCode: string;
totalReferrals: number;
rewardsEarned: number;
shareUrl: string;
}