Email/Integrations
Resend Integration
How the Resend email service is integrated for sending transactional emails.
Resend Integration
This document explains how the Resend email service is integrated for sending transactional emails.
Configuration
-
Provider Selection: Set
NEXT_PUBLIC_EMAIL_PROVIDERto"resend"in root.env. -
API Key: The
RESEND_API_KEYenvironment variable must contain a valid API key obtained from your Resend account.
How it Works
When NEXT_PUBLIC_EMAIL_PROVIDER is set to "resend", the core email router calls packages/email/src/send-email-resend.ts.
This logic:
- Uses the official
resendSDK. - Checks if
RESEND_API_KEYis configured (isResendConfigured). - Takes a payload (
EmailPayload) containingto,subject,from, and eitherreact(a React Email component) ortext. - Renders React components to HTML using
@react-email/render. - Handles both single recipient sends (
resend.emails.send) and batch sends (resend.batch.send) iftois an array. - Includes error handling and logging for API responses.
Usage Examples
When Resend is configured as the provider, it's used by the core sendEmail function for actions like:
- Sending email verification links.
- Sending password reset links.
- Sending email change confirmations (if enabled).
Considerations
- Pricing and Limits: Resend offers various plans including a free tier with limitations. Refer to the official Resend Pricing for details.
- Daily Sending Limit: Be aware of potential sending limits, especially on the free tier. See the General Email Configuration for discussion and mitigation strategies.
- Domains: Configure sending domains within your Resend account dashboard.
- Data Retention: Check your Resend plan for details on email log retention periods.