minimal example to reproduce react-email html export problem: need an unused React import line
import { Button } from "@react-email/components";
// import * as React from "react"; <-- errors if this line is omitted
export default function Email() {
return (
<Button href="https://example.com" style={{ color: "#61dafb" }}>
Click me
</Button>
);
}if omitted:
❯ npx email export
✔ Preparing files...
✖ failed when rendering test.cjs
ReferenceError: React is not defined
at Email (/Users/max/repos/react-email-html-export-bug-repro/out/test.cjs:35506:3)
at react-stack-bottom-frame (/Users/max/repos/react-email-html-export-bug-repro/out/test.cjs:24826:18)
at renderWithHooks (/Users/max/repos/react-email-html-export-bug-repro/out/test.cjs:21700:24)
at renderElement (/Users/max/repos/react-email-html-export-bug-repro/out/test.cjs:21960:25)
at retryNode (/Users/max/repos/react-email-html-export-bug-repro/out/test.cjs:22568:43)
at renderNodeDestructive (/Users/max/repos/react-email-html-export-bug-repro/out/test.cjs:22528:270)
at renderNode2 (/Users/max/repos/react-email-html-export-bug-repro/out/test.cjs:22868:20)
at renderElement (/Users/max/repos/react-email-html-export-bug-repro/out/test.cjs:22238:25)
at retryNode (/Users/max/repos/react-email-html-export-bug-repro/out/test.cjs:22568:43)
at performWork (/Users/max/repos/react-email-html-export-bug-repro/out/test.cjs:23169:19)This line is absent from many react-email examples, so I did not realize it was required for email exports to work! for example (as of 6/19/25):
- the getting started example on the readme
- components like html, head, button, ...
It is shown in the manual setup getting started example, which is how I solved the bug.
I assume that it's not needed for non-export configs. If this is the case, and it's a requirement specific to exporting emails, it'd be a very helpful addition to the export documentation