kriasoft/react-starter-kit · error · Error

Resend API error: ${result.error.message || result.error.nam

Error message

Resend API error: ${result.error.message || result.error.name || "Unknown error"}

What it means

Resend's SDK does not throw on API failures; it returns { data, error }. sendEmail checks result.error after resend.emails.send() and converts it into a thrown Error whose message is Resend's own error message or name. This is the provider rejecting the request after the request reached Resend (or the SDK failed to build it).

Source

Thrown at apps/api/lib/email.ts:65

  if (!env.RESEND_EMAIL_FROM) {
    throw new Error("RESEND_EMAIL_FROM environment variable is required");
  }

  // A fresh client per send: the Workers runtime reuses an isolate across
  // requests, and a module-level client would outlive the env it was built from.
  const resend = new Resend(env.RESEND_API_KEY);

  try {
    const result = await resend.emails.send({
      from: options.from || env.RESEND_EMAIL_FROM,
      to: options.to,
      subject: options.subject,
      html: options.html,
      text: options.text,
    });

    if (result.error) {
      throw new Error(
        `Resend API error: ${result.error.message || result.error.name || "Unknown error"}`,
      );
    }

    return result;
  } catch (error) {
    throw new Error(
      `Failed to send email: ${error instanceof Error ? error.message : "Unknown error"}`,
      { cause: error },
    );
  }
}

/**
 * Send email verification message.
 *
 * @param env Environment variables
 * @param options User and verification URL (should be time-limited, signed token)

View on GitHub (pinned to 0aa7603435)

Solutions

  1. Read the message after the prefix — it states the concrete Resend failure (e.g. 'You can only send testing emails to your own email address')
  2. Verify the sending domain in the Resend dashboard and set RESEND_EMAIL_FROM to an address on that domain
  3. Confirm RESEND_API_KEY is a valid, non-revoked full-access key for the account that owns the domain
  4. Check Resend status page / rate limits if the message indicates a 4xx throttling or 5xx issue and retry with backoff

Example fix

// before
from: 'onboarding@resend.dev' // works only for your own account's email
// after
// verify your domain in Resend, then set RESEND_EMAIL_FROM
from: 'noreply@notifications.yourdomain.com'
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight: check config before calling
if (!env.RESEND_API_KEY) throw new Error('RESEND_API_KEY missing');
const fromDomain = env.RESEND_EMAIL_FROM.split('@')[1];
if (!fromDomain || fromDomain === 'resend.dev') {
  console.warn('Sending from an unverified domain — Resend will likely reject');
}

Type guard

function isResendApiError(error: unknown): error is Error & { message: string } {
  return error instanceof Error && error.message.startsWith('Resend API error:');
}

Try / catch

try {
  await sendEmail(env, options);
} catch (error) {
  const msg = error instanceof Error ? error.message : String(error);
  if (msg.includes('Resend API error:')) {
    const detail = msg.split('Resend API error:')[1]?.trim();
    // 4xx config/auth problems are not retryable; log detail and alert
    console.error('Resend rejected the send:', detail);
    return { ok: false, retryable: false };
  }
  throw error;
}

Prevention

When it happens

Trigger: Calling sendEmail (via sendVerificationEmail, sendPasswordReset, sendOTP) when Resend rejects: invalid/revoked RESEND_API_KEY, unverified 'from' domain, recipient on suppression/bounce list, payload too large, or rate limit exceeded.

Common situations: Testing against localhost with a real API key but an unverified sending domain (onboarding.validate_from not satisfied), using onboarding@resend.dev as from while sending to arbitrary addresses, key rotated or deleted in the Resend dashboard, or 429s during bulk sends.

Related errors


AI-assisted analysis of kriasoft/react-starter-kit@0aa7603435 (2026-08-31). Data as JSON: /api/errors/ef596f608eb529a0. Report an issue: GitHub.