Magic Link allows users to login without passwords. They enter their email, receive a link, click it, and they're logged in automatically.
Perfect for: Improving user experience, reducing password fatigue, and increasing conversion rates.
# Add magic link to available auth methods
NEXT_PUBLIC_AUTH_METHODS="credential,magiclink"
# Email service required
RESEND_API_KEY="re_your_resend_api_key"
EMAIL_FROM="noreply@yourdomain.com"Magic link button automatically appears on your login page at /[locale]/login.
On the login page, user clicks "Se connecter avec un lien magique" instead of entering password.
User enters their email in the magic link form.
User receives an email with a secure login link (expires in 15 minutes).
User clicks the link → automatically logged in and redirected to dashboard.
For new users: If the email doesn't exist, a new account is automatically created during the magic link process.
Built-in protections:
The boilerplate includes a pre-built magic link email:
Email content:
Customization:
The magic link feature uses Better Auth's magicLink plugin:
// In src/lib/better-auth/auth.ts
magicLink({
sendMagicLink: async ({email, url}) => {
// Finds or creates user
let user = await getUserByEmailDao(email)
if (!user) {
await initializeRegisterUserDataService(email, true)
user = await getUserByEmailDao(email)
}
// Sends email via notification service
await createTypedNotificationService({
userId: user.id,
type: NotificationTypeConst.magic_link,
metadata: { url, email }
})
},
})The magic link system automatically creates accounts for new email addresses. Make sure this behavior fits your application's requirements.
Magic link emails not arriving?
RESEND_API_KEY is correctly setEMAIL_FROM domain is verified in Resend"Link expired" error?
Button not showing on login page?
NEXT_PUBLIC_AUTH_METHODS includes "magiclink"RESEND_API_KEY is configuredWorking perfectly? Users can now login without passwords, improving security and user experience!