Complete guide: Nothing → Sending beautiful emails in 15 minutes
Clone or download the templates:
# Option A: Copy all templates cp -r /path/to/email-templates/emails /your-project/ # Option B: Copy just one template cp /path/to/email-templates/emails/01-welcome.tsx /your-project/emails/
cd /your-project npm install resend react-email @react-email/components react
What these do:
resend - Sends the emails (free tier available)react-email - Converts React → HTML emails@react-email/components - Email-safe componentsreact - Required for JSXre_)Add to your .env file:
RESEND_API_KEY=re_your_key_here
Create send-email.ts:
import { Resend } from 'resend';
import { WelcomeEmail } from './emails/01-welcome';
const resend = new Resend(process.env.RESEND_API_KEY);
async function sendWelcomeEmail() {
const { data, error } = await resend.emails.send({
from: 'onboarding@resend.dev', // Use this for testing
to: 'your-email@example.com', // YOUR email here!
subject: 'Welcome to My App!',
react: WelcomeEmail({
userName: 'Test User',
productName: 'My App',
loginUrl: 'https://example.com/login'
})
});
if (error) {
console.error('Failed to send:', error);
return;
}
console.log('Email sent!', data);
}
sendWelcomeEmail();
Run it:
npx tsx send-email.ts # Or: npx ts-node send-email.ts # Or: tsc send-email.ts && node send-email.js
Example: Next.js API route
// app/api/send-welcome/route.ts
import { Resend } from 'resend';
import { WelcomeEmail } from '@/emails/01-welcome';
const resend = new Resend(process.env.RESEND_API_KEY);
export async function POST(request: Request) {
const { email, name } = await request.json();
const { data, error } = await resend.emails.send({
from: 'hello@yourdomain.com',
to: email,
subject: 'Welcome!',
react: WelcomeEmail({ userName: name })
});
if (error) {
return Response.json({ error }, { status: 500 });
}
return Response.json({ success: true });
}
Example: Signup flow
async function handleSignup(email: string, name: string) {
// 1. Create user
const user = await db.users.create({ email, name });
// 2. Send welcome email
await resend.emails.send({
from: 'hello@yourdomain.com',
to: email,
subject: 'Welcome!',
react: WelcomeEmail({ userName: name })
});
return { success: true, user };
}
You can now send beautiful, professional emails in minutes.
← Back to Template Gallery"Module not found: Can't resolve 'react'"
npm install react
"RESEND_API_KEY is not defined"
• Check .env file exists
• Load env vars: import 'dotenv/config'
• Or with Next.js, it's automatic
"from address not verified"
For testing: Use onboarding@resend.dev
For production: Add your domain in Resend dashboard
npm run dev in the email-templates directory. Opens preview server at localhost:3000.