Resend Email
Resend is the developer-first email API for transactional emails. Welcome emails, password resets, purchase confirmations, and more. It's already in your dependencies; just add your API key and start sending.
Last updated: 2026-03-29
Get Your API Key
Sign up at resend.com, add your sending domain (or use the sandbox for testing), and copy your API key into your .env file.
# .env
RESEND_API_KEY=re_your_api_key_hereSend Your First Email
Create an Astro API route that uses the Resend SDK to send emails. Keep all email logic server-side so your API key is never exposed to the browser.
// src/pages/api/send-email.ts
import type { APIRoute } from 'astro';
import { Resend } from 'resend';
const resend = new Resend(import.meta.env.RESEND_API_KEY);
export const POST: APIRoute = async ({ request }) => {
const { to, subject, html } = await request.json();
const { data, error } = await resend.emails.send({
from: 'Flux Theme <[email protected]>',
to,
subject,
html,
});
if (error) return new Response(JSON.stringify({ error }), { status: 500 });
return new Response(JSON.stringify({ data }), { status: 200 });
};Send a Welcome Email on Signup
Hook into your Supabase auth flow to fire a welcome email whenever a new user registers. Call your /api/send-email route from the signup handler.
// After successful supabase.auth.signUp()
if (data.user) {
await fetch('/api/send-email', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
to: data.user.email,
subject: 'Welcome to Flux Theme',
html: '<h1>You are in!</h1><p>Thanks for joining. Start building.</p>',
}),
});
}