nextauthjs/next-auth · error · Error

Resend error: + JSON.stringify(await res.json())

Error message

Resend error: + JSON.stringify(await res.json())

What it means

The Resend email provider in Auth.js throws this error when the Resend API returns a non-OK status while sending a verification email. The response body JSON (which contains Resend's 'name' and 'message' error fields, e.g. validation_error, invalid_api_key) is serialized into the error message. It signals the send request was rejected by Resend before an email could be delivered.

Source

Thrown at packages/core/src/providers/resend.ts:31

      const { identifier: to, provider, url, theme } = params
      const { host } = new URL(url)
      const res = await fetch("https://api.resend.com/emails", {
        method: "POST",
        headers: {
          Authorization: `Bearer ${provider.apiKey}`,
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          from: provider.from,
          to,
          subject: `Sign in to ${host}`,
          html: html({ url, host, theme }),
          text: text({ url, host }),
        }),
      })

      if (!res.ok)
        throw new Error("Resend error: " + JSON.stringify(await res.json()))
    },
    options: config,
  }
}

View on GitHub (pinned to a1a16a5a77)

Solutions

  1. Verify RESEND_API_KEY is present and correct in your environment.
  2. Check the JSON body in the error message — Resend's 'name'/'message' fields state the exact rejection reason.
  3. In test mode, only send to your Resend account's own email address, or verify your sending domain in the Resend dashboard.
  4. Ensure the 'from' address uses a domain verified in Resend (DNS records added and verified).

Example fix

// before
from: "onboarding@mycompany.com" // unverified domain, test mode
// after
// In test mode, send only to your own account email:
from: "onboarding@resend.dev" // or verify mycompany.com in Resend dashboard
Defensive patterns

Strategy: validation

Validate before calling

if (!process.env.RESEND_API_KEY) throw new Error("RESEND_API_KEY is not set")
// In test mode, ensure the recipient is your Resend account's own email address.

Type guard

function isResendErrorBody(body: unknown): body is { name: string; message: string } {
  return typeof body === "object" && body !== null && "name" in body && "message" in body
}

Try / catch

try {
  await signIn("email", { email })
} catch (err) {
  const raw = (err as Error).message.replace("Resend error: ", "")
  const { name, message } = JSON.parse(raw)
  console.error(`Resend ${name}: ${message}`)
}

Prevention

When it happens

Trigger: sendVerificationRequest fetch to https://api.resend.com/emails returns res.ok === false: missing/invalid RESEND_API_KEY, 'from' address not on a verified domain in Resend, malformed 'to' address, or exceeding the test-mode restriction (only sending to the account owner's email).

Common situations: New Resend accounts in test mode can only email the owner's own address — a very common cause. Others: unverified sending domain (domain verification DNS records not added), typo'd API key, or leaving RESEND_API_KEY unset after deploying.

Related errors


AI-assisted analysis of nextauthjs/next-auth@a1a16a5a77 (2026-08-28). Data as JSON: /api/errors/f437b75989cb31fd. Report an issue: GitHub.