36
Key Features:
Generates unique referral codes for each user.
Attribution of referrals during the email signup process.
Provides referral counts and lists of referred users.
Option to mask referred user emails for privacy.
Includes a callback function that executes after a successful referred signup, enabling custom reward logic, notifications, or other actions.
Offers endpoints to retrieve a user's referral code and dashboard statistics, as well as a list of users they have referred.
Integrates seamlessly with the Better Auth framework, requiring minimal setup.
Its now even listed in better-auth's community plugin page.
Installation:
Install the package using pnpm:
pnpm add @marinedotsh/better-auth-referral
Ensure you have the necessary peer dependencies installed:
pnpm add better-auth zod
Setup:
Integrate the server and client plugins into your Better Auth configuration to enable referral functionalities.
How it works:
Upon signup, if a valid referral code is provided via the x-referral-code header, the plugin validates the code, records the referral relationship, assigns a new referral code to the newly signed-up user, and triggers the optional afterSuccessfulSignUp callback.
Built with