Leave Localhost logoLeave LocalhostDocs
Multi-tenancy

Invitations

Admins and Owners can add users to a workspace by sending an email invitation.

Admins and Owners can add users to a workspace by sending an email invitation.

Sending an Invitation

The inviteMember mutation in packages/backend/convex/members.ts handles invitation creation.

  1. User enters an email and selects a role in the dashboard.
  2. inviteMember calls the Better Auth API (createInvitation).
  3. Better Auth's organization plugin catches the creation event and triggers the sendInvitationEmail callback (configured in auth.ts).
  4. The system renders the email template and sends it via Resend.

Member Limits

Invitations are subject to the workspace's billing plan. The member.invite permission checks the workspace.members.invite capability and evaluates the memberLimitNotExceeded resource policy.

If the workspace has 10 members and the plan limit is 10, the invitation is blocked at the server level.

Accepting an Invitation

When the user clicks the link in the email, they are directed to: {SITE_URL}/accept-invitation?invitationId=...

This Next.js page:

  1. Reads the invitation details via the getInvitation query.
  2. If the user is unauthenticated, prompts them to sign up or log in.
  3. If authenticated, shows an "Accept Invitation" button.
  4. Clicking the button fires the acceptInvitation mutation.
  5. The backend accepts the invite in Better Auth and sets the new workspace as the user's active organization.

Canceling an Invitation

Admins and Owners can cancel pending invitations using the Better Auth cancel endpoint (exposed via the frontend Better Auth client).

Configuration

Invitations can be disabled globally by setting allowInvitations: false in packages/backend/convex/organizations/config.ts.

Next Reads

On this page