Skip to main content
Better Auth is a framework-agnostic authentication library for TypeScript. It relies on transactional email for password resets, email verification, magic links, and one-time codes, all of which you can deliver with Resend.

Prerequisites

Before you start, you’ll need:

Install the Resend SDK

Add your API key to the environment:
.env
The hook examples below call void resend.emails.send(...) instead of awaiting it, as Better Auth recommends, so the response time doesn’t reveal whether an account exists. On serverless platforms, wrap the send in waitUntil (or your platform’s equivalent) so the function doesn’t terminate before the email is sent.

Send password reset and verification emails

Better Auth calls your sendResetPassword and sendVerificationEmail hooks when a user requests a reset or needs to confirm their address. Send the email with Resend inside each hook.
auth.ts
Set the from address to match your verified domain.
If you use the magic link plugin, send the sign-in link through the sendMagicLink hook.
auth.ts
Set the from address to match your verified domain.

Send one-time codes (optional)

The email OTP plugin sends a one-time password (OTP), a numeric code, instead of a link. The type argument tells you which flow triggered the request so you can tailor the subject line.
auth.ts
Set the from address to match your verified domain.

Customize email templates

For richer, reusable emails, author your templates with React Email and pass the rendered component to Resend’s react field, or reference a Resend template by id.
auth.ts
Set the from address to match your verified domain.

Debugging email delivery

When a flow doesn’t behave as expected, check both sides:
  • Better Auth logs show the hook invocation and any errors thrown while sending.
  • Resend Logs show the delivery side: accepted, delivered, opened, bounced.
Together, you get end-to-end visibility across the entire delivery chain.