Overview
Resend is a modern transactional email API built for developers. It's simple to use, has great deliverability, and works perfectly for sending transactional emails like welcome emails, password resets, and notifications.
Account Setup
- Go to resend.com and sign up for an account
- Verify your email address
- You'll start with a free tier that includes 3,000 emails/month and unlimited domains
Get API Key
- In your Resend dashboard, go to "API Keys"
- Click "Create API Key"
- Name it (e.g., "Production" or "Development")
- Select permissions (for sending emails, you only need "Sending access")
- Click "Add"
- Important: Copy the API key immediately - you won't be able to see it again after closing the dialog
- This is your
RESEND_API_KEY
Domain Setup (Optional but Recommended)
While you can use Resend's test domain initially, setting up your own domain improves deliverability.
Step 1: Add Domain
- Go to "Domains" in your Resend dashboard
- Click "Add Domain"
- Enter your domain (e.g.,
mg.yourdomain.com- using a subdomain is recommended) - Click "Add"
Step 2: Add DNS Records Resend will show you the DNS records to add. You need to add:
- SPF Record:
v=spf1 include:resend.com ~all - DKIM Records: Multiple CNAME records (Resend will provide exact values)
- DMARC Record (Optional):
v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com
Step 3: Verify Domain
- Add the DNS records in your domain's DNS provider (Cloudflare, Namecheap, etc.)
- Wait for DNS propagation (can take up to 24 hours, usually much faster)
- Click "Verify" in Resend dashboard
- Once verified, you can send emails from addresses like
noreply@mg.yourdomain.com
Environment Variables
Add this variable to your .env.local file:
# Resend RESEND_API_KEY="re_xxxxxxxxxxxxx"
For Domain Setup: If you've set up a custom domain, you'll also need to specify the "From" email address in your email sending code. For example:
from: "noreply@mg.yourdomain.com"
Without Domain Setup: You can use Resend's test domain:
from: "onboarding@resend.dev"
Note: Emails from the test domain may have delivery limitations.
Testing
- Add
RESEND_API_KEYto your.env.local - Restart your dev server:
npm run dev - Trigger an email (e.g., sign up a user, reset password)
- Check your email inbox
- In Resend dashboard → "Logs", you can see email delivery status
Test Email Script: You can test sending emails directly:
import { Resend } from 'resend'; const resend = new Resend(process.env.RESEND_API_KEY); await resend.emails.send({ from: 'onboarding@resend.dev', to: 'your-email@example.com', subject: 'Hello World', html: '<p>This is a test email!</p>', });
Troubleshooting:
- If emails don't arrive, check the "Logs" in Resend dashboard for error messages
- Verify your API key is correct
- For production, ensure domain is verified
- Check spam folder if using test domain