whatisgithub

What is better-auth-referral?

marinedotsh/better-auth-referral — explained in plain English

Analysis updated 2026-05-18

68TypeScriptAudience · developerComplexity · 2/5LicenseSetup · easy

In one sentence

A plugin for Better Auth that adds ready made user referral tracking, including referral codes, signup attribution, and referral stats.

Mindmap

mindmap
  root((better-auth-referral))
    What it does
      Generates referral codes
      Tracks who referred whom
      Referral stats endpoint
    Tech stack
      TypeScript
      Better Auth
      Zod
    Use cases
      Refer a friend feature
      Reward automation
      Referral dashboard
    Audience
      Developers
    Setup
      Install package
      Add server plugin
      Run DB migration

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Add a refer a friend feature to an app without building the tracking system yourself.

USE CASE 2

Reward users automatically when someone they invited signs up successfully.

USE CASE 3

Show users a dashboard of how many people they have referred and when.

USE CASE 4

Attribute signups to a referral code during both email and OAuth signup flows.

What is it built with?

TypeScriptBetter AuthZod

How does it compare?

marinedotsh/better-auth-referralvoid5tar/curiodiendh/zca-bridge
Stars686869
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasymoderatemoderate
Complexity2/53/54/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 30min

Requires an existing Better Auth setup plus a database migration step.

So what is it?

This project is a plugin that adds a referral system to apps already using Better Auth, a login and account library. Instead of building your own referral tracking from scratch, you install this plugin and it handles generating referral codes, recording who invited whom, and giving you the stats to show users how many people they have brought in. Every user automatically gets a unique eight character referral code. When a new person signs up and includes that code, either through a normal email signup or through signing in with a provider like GitHub, the plugin checks that the code is valid, lets the normal signup happen, then records the connection between the person who invited and the person who joined, and creates a fresh referral code for the new user too. You can also set an optional function that runs after a successful referred signup, useful for things like giving the referrer a reward or sending a notification. If someone signs up without a code, everything works exactly as before. Once set up, any signed in user can fetch their own referral code along with simple stats such as how many people joined today and how many joined overall. There is also an endpoint to list everyone a given user has referred, with support for paging through longer lists and an option to partially hide referred users' email addresses for privacy. Setting it up means installing the package and its two required companion libraries, adding a server side plugin to your Better Auth configuration, adding a matching client side plugin, and then running your normal Better Auth database setup steps so two new tables for referral codes and referrals get created. The referral code that gets checked during signup can be sent under a different header name if you prefer, and the whole thing is released under the MIT license.

Copy-paste prompts

Prompt 1
Show me how to install and wire up this Better Auth referral plugin on both the server and client.
Prompt 2
Explain how referral codes are validated and attached to a new user during signup.
Prompt 3
Help me write an afterSuccessfulSignUp callback that grants credits to the referring user.
Prompt 4
Walk me through the database tables this plugin adds and what each field means.
Prompt 5
Show me how to list a signed in user's referrals with pagination.

Frequently asked questions

What is better-auth-referral?

A plugin for Better Auth that adds ready made user referral tracking, including referral codes, signup attribution, and referral stats.

What language is better-auth-referral written in?

Mainly TypeScript. The stack also includes TypeScript, Better Auth, Zod.

How hard is better-auth-referral to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is better-auth-referral for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.