Prerequisites
Before installing the plugin, ensure you have:- Better Auth v1.4.13+ installed in your project
- A configured database adapter (PostgreSQL, MySQL, SQLite, etc.)
- Node.js 16.x or higher
Install the package
Install the plugin using your preferred package manager:Peer dependencies
The plugin has the following peer dependencies that should already be installed if you’re using Better Auth:better-auth^1.4.13
@better-auth/utils^0.3.0zod^4.3.5
Database setup
After installing the plugin, you need to update your database schema to include the invite tables.Automatic migration
Better Auth can automatically generate and run migrations for plugin schemas.
- invite: Stores invitation records
- inviteUse: Tracks when and by whom invites are used
Manual schema creation
If you prefer to manage database migrations manually, here’s the schema structure: invite table:id- Primary key (string)token- Unique string for the invitationcreatedAt- Timestamp when invite was createdexpiresAt- Timestamp when invite expiresmaxUses- Number representing maximum usescreatedByUserId- Foreign key to user tableredirectToAfterUpgrade- Optional string for custom redirectshareInviterName- Boolean flagemail- Optional string for private invitesrole- String representing the role to assignnewAccount- Optional boolean for private invitesstatus- Enum: “pending”, “rejected”, “canceled”, “used”
id- Primary key (string)inviteId- Foreign key to invite tableusedAt- Timestamp when invite was usedusedByUserId- Foreign key to user table
The exact SQL syntax will vary depending on your database system. Refer to your Better Auth database adapter documentation for specific migration examples.
Verify installation
To verify the plugin is installed correctly:TypeScript support
The plugin is written in TypeScript and includes type definitions. No additional setup is required for TypeScript projects.Next steps
Now that the plugin is installed, you’re ready to configure it:Quick start
Configure the plugin and create your first invite