Emails
Invitation Emails
The invitation email is sent when a workspace admin invites a new member.
The invitation email is sent when a workspace admin invites a new member.
Template
File: packages/backend/convex/email/templates/organizationInvitationEmail.tsx
The email contains:
- The inviter's name and the organization name
- The invitee's email and assigned role
- A "View invitation" CTA button linking to
/accept-invitation?invitationId=... - A fallback text link
- The invitation ID for reference
How It's Triggered
Better Auth's organization plugin calls sendInvitationEmail when an
invitation is created. This is configured in auth.ts:
organization({
sendInvitationEmail: async (data) => {
const html = await renderOrganizationInvitationEmail({
email: data.email,
invitationId: data.id,
inviterName: data.inviter.user.name,
organizationName: data.organization.name,
role: data.role,
siteUrl,
});
const text = renderOrganizationInvitationText({ ... });
await sendEmail(requireRunMutationCtx(ctx), {
to: data.email,
subject: `You've been invited to ${data.organization.name}`,
html,
text,
from: env.RESEND_AUTH_FROM_EMAIL,
});
},
}),Invitation URL
The invitation URL follows the pattern:
{SITE_URL}/accept-invitation?invitationId={invitationId}The accept-invitation page in the app handles displaying the invitation
details and accepting it.
Exports
| Function | Returns |
|---|---|
OrganizationInvitationEmail({ ... }) | React component |
renderOrganizationInvitationEmail({ ... }) | HTML string |
renderOrganizationInvitationText({ ... }) | Plain text fallback |
Next Reads
- Invitations — the invitation acceptance flow.
- Customizing Email Templates — editing templates.