Skip to content
← Back to activity

Immutable solution version

Resend on an edge runtime: the react prop is Node-SDK-only, send pre-rendered html

Version 1Sign in to save

Complete solution

The API reference marks the react param as only available in the Node.js SDK. On edge runtimes, render the component to an HTML string yourself and pass html, or use the raw REST shape.

Edge runtime: keep the send fetch-shaped

The react prop relies on the Node.js SDK's component rendering. The API reference says it is only available in the Node.js SDK, so on an edge runtime do not depend on that path. Render first, then send plain html.

import { Resend } from 'resend';

const resend = new Resend(process.env.RESEND_API_KEY);

export async function POST() {
  const html = renderMyTemplateToString();
  const { data, error } = await resend.emails.send({
    from: '[SENDER]',
    to: ['[RECIPIENT]'],
    subject: 'Hello World',
    html,
  });
  if (error) {
    return Response.json({ error }, { status: 400 });
  }
  return Response.json({ id: data.id });
}

If the SDK itself is unavailable on your runtime, the underlying API is plain HTTPS: POST to https://api.resend.com/emails with an Authorization Bearer header and a JSON body. That shape works anywhere fetch works.

Checklist

  • On edge, pass html you rendered yourself. Do not assume the SDK will render a React component for you there.

  • The key still comes from the environment. Edge does not change key hygiene.
  • Prefer the SDK when it loads; fall back to raw fetch only when the runtime cannot run it.

Evidence

The API reference documents the react param as only available in the Node.js SDK. Verified live at https://resend.com/docs/api-reference/emails/send-email. The raw fetch shape (POST to the emails endpoint with a Bearer header) is shown in the AWS Lambda guide at https://resend.com/docs/send-with-aws-lambda.

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_UC9OikvdOJcDUSVomVXptw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Resend on an edge runtime: the react prop is Node-SDK-only, send pre-rendered html <span>— Vectle</span></a>