Skip to content

fix: to support @react-email/render exports across versions in templates#863

Open
Shubhdeep12 wants to merge 4 commits intoresend:canaryfrom
Shubhdeep12:fix/templates-renderasync
Open

fix: to support @react-email/render exports across versions in templates#863
Shubhdeep12 wants to merge 4 commits intoresend:canaryfrom
Shubhdeep12:fix/templates-renderasync

Conversation

@Shubhdeep12
Copy link
Contributor

@Shubhdeep12 Shubhdeep12 commented Mar 2, 2026

  • @react-email/render dropped renderAsync in v2.0.0.

Summary by cubic

Adds a shared render helper that works with @react-email/render v1 and v2 by preferring render and falling back to renderAsync. Uses it in Templates and Emails with clearer errors.

  • Bug Fixes
    • Add render helper that selects render or renderAsync and throws actionable errors.
    • Use helper in Templates and Emails; remove dynamic imports and cached renderer.
    • Add tests for helper behavior; update template tests to mock render.

Written for commit b05636e. Summary will update on new commits.

@Shubhdeep12 Shubhdeep12 requested a review from a team as a code owner March 2, 2026 15:54
@Shubhdeep12 Shubhdeep12 changed the title fix: toupport @react-email/render exports across versions in templates fix: to support @react-email/render exports across versions in templates Mar 2, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 2, 2026

Open in StackBlitz

npm i https://pkg.pr.new/resend@863

commit: 38eec3a

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

throw new Error(
'Failed to render React component. Make sure to install `@react-email/render`',
);
const mod = await import('@react-email/render');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should use

export async function render(node: React.ReactNode) {
let render: typeof import('@react-email/render').render;
try {
({ render } = await import('@react-email/render'));
} catch {
throw new Error(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, i thought earlier, since it's a peer dep, we wanted to give support for renderAsync.

thanks for the review, made the changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's valid, but it should be done in that render function and reused

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i removed it in the last commit, lemme add the support of renderAsync back
and to render.ts that the right place

@Shubhdeep12 Shubhdeep12 requested a review from gabrielmfern March 6, 2026 01:38
payload.html = await this.renderAsync(
payload.react as React.ReactElement,
);
payload.html = await render(payload.react as React.ReactElement);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this cast is required, is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah we can remove it, especially as we are narrowing the scope here with ReactElement.
lemme remove it and from other places as well.

@Shubhdeep12 Shubhdeep12 requested a review from gabrielmfern March 6, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants