Creator
Email

Resend

Setting up Resend as your email provider.

Setup

  1. Create an account at resend.com
  2. Add and verify your domain in the Resend dashboard
  3. Create an API key
  4. Set environment variables:
NEXT_PUBLIC_EMAIL_SERVICE="resend"
NEXT_RESEND_API_KEY="re_..."
NEXT_RESEND_FROM_EMAIL="noreply@yourdomain.com"

Testing

During development, Resend allows sending emails only from onboarding@resend.dev. Set:

NEXT_RESEND_FROM_EMAIL="onboarding@resend.dev"

Switch to your verified domain email before going to production.

How it works

The Resend provider in lib/services/email-service.ts:

function createResendProvider(): EmailProvider {
  const fromEmail = process.env.NEXT_RESEND_FROM_EMAIL || "onboarding@resend.dev";

  return {
    async send({ to, subject, html, text, replyTo }) {
      const { Resend } = await import("resend");
      const resend = new Resend(process.env.NEXT_RESEND_API_KEY);

      const { data, error } = await resend.emails.send({
        from: `${APP_NAME} <${fromEmail}>`,
        to: [to],
        subject,
        html,
        text,
        ...(replyTo && { replyTo: [replyTo] }),
      });

      if (error) throw new Error(error.message);
      return { success: true, messageId: data?.id };
    },
  };
}

The Resend SDK is dynamically imported so it doesn't add to the bundle when Mailgun is used instead.

On this page

We use cookies to ensure you get the best experience on our website. For more information on how we use cookies, please see our cookie policy.