Emails
Magic Link Emails
The magic link email is sent when a user signs in with the passwordless magic link flow.
The magic link email is sent when a user signs in with the passwordless magic link flow.
Template
File: packages/backend/convex/email/templates/magicLinkEmail.tsx
The email contains:
- A "Sign in to {APP_NAME}" CTA button with the magic link URL
- A fallback text link for email clients that don't support buttons
- A notice that the email can be ignored if not requested
How It's Triggered
Better Auth's magicLink plugin calls sendMagicLink during the magic link
flow. This callback is configured in auth.ts:
magicLink({
sendMagicLink: async ({ email, url }) => {
const html = await renderMagicLinkEmail({ appName, url });
const text = renderMagicLinkText({ appName, url });
await sendEmail(requireRunMutationCtx(ctx), {
to: email,
subject: "Your sign-in link",
html,
text,
from: env.RESEND_AUTH_FROM_EMAIL,
});
},
}),Exports
| Function | Returns |
|---|---|
MagicLinkEmail({ appName, url }) | React component |
renderMagicLinkEmail({ appName, url }) | HTML string (via @react-email/render) |
renderMagicLinkText({ appName, url }) | Plain text fallback |
Customization
To customize the magic link email:
- Edit
magicLinkEmail.tsx - Update the preview text, button label, and body copy
- Keep the product name parameterized with
appName - Adjust the inline styles for your brand
Next Reads
- Customizing Email Templates — general template customization guide.