useReferrals hook provides methods to create and redeem referral codes as part of a referral program.
Parameters
string
required
The ID of your referral program.
UseQueryOptions
Optional TanStack Query options to customize caching and refetching behavior.
Returns
data
The referral code response. The hook starts with enabled: false, so call refetch() to create/fetch the code.
redeemCode()
Redeems a referral code for the current customer.
string
required
The referral code to redeem.
isLoading
Boolean indicating whether a referral code is being created/fetched.
error
Any error that occurred.
refetch()
Creates or fetches the referral code for the configured programId.