Perfect for: Transactional emails, authentication flows, notifications, and professional email delivery.
Resend Account Setup
1
Create Resend Account
- Go to resend.com and create an account
- Verify your email address
- Add your domain for production use
2
Get API Key
- Navigate to the API Keys section
- Create a new API key
- Copy the API key for environment configuration
3
Configure Environment
Add the required environment variables to your
.env.local:# Resend Configuration
RESEND_API_KEY="re_your_api_key_here"
EMAIL_FROM="noreply@yourdomain.com"
# For development, you can use the default
EMAIL_FROM="onboarding@resend.dev"Email Service Configuration
The boilerplate provides a configured email service insrc/services/email-service.ts:
Core Email Service
// From src/services/email-service.ts
import { Resend } from 'resend'
import { env } from '@/env'
const resend = new Resend(env.RESEND_API_KEY)
export const sendEmailService = async (
payload: CreateEmailOptions,
options?: CreateEmailRequestOptions
) => {
if (env.NODE_ENV === 'development') {
payload.subject = `[DEV] ${payload.subject}`
}
const { error } = await resend.emails.send(
{
...payload,
from: env.EMAIL_FROM ?? 'onboarding@resend.dev',
},
options
)
if (error) {
console.error(error)
throw error
}
}Development Mode: In development, all email subjects are automatically prefixed with
[DEV] to distinguish them from production emails.Simple Email Function
For basic text emails, use thesendSimpleEmailService:
// From src/services/email-service.ts
export const sendSimpleEmailService = async ({
to,
subject,
text,
}: {
to: string
subject: string
text: string
}) => {
await sendEmailService({
to,
subject,
text,
from: env.EMAIL_FROM ?? 'onboarding@resend.dev',
})
}Available Email Functions
The boilerplate includes 13 specialized email functions:// Magic link authentication
sendMagicLinkEmailService({ email, url })
// Email verification
sendVerificationEmailService({ email, url })
// Password reset
sendResetPasswordLinkEmailService({ email, url })
// OTP codes
sendOTPEmailService({ email, otp, otpLink })
// Email change verification
sendEmailChangeEmailVerificationService({ email, url })Environment Variables
Required: Make sure these environment variables are set in your deployment environment.
# Required
RESEND_API_KEY="your-resend-api-key"
# Recommended (defaults to onboarding@resend.dev)
EMAIL_FROM="noreply@yourdomain.com"
# Used in email templates
NEXT_PUBLIC_APP_URL="https://yourdomain.com"Error Handling
The email service includes built-in error handling:// From src/services/email-service.ts
const { error } = await resend.emails.send(emailData)
if (error) {
console.error(error)
throw error
}Testing Email Delivery
1
Development Testing
- All emails in development are prefixed with
[DEV] - Check your console for email sending logs
- Use Resend dashboard to monitor delivery
2
Domain Verification
- For production, verify your domain in Resend
- Update
EMAIL_FROMto use your verified domain - Test with your production domain
3
Monitor Delivery
- Use Resend dashboard for delivery analytics
- Monitor bounce rates and delivery success
- Check spam folder if emails aren't received
Resend configured! Your application can now send professional transactional emails with reliable delivery and excellent analytics.