Skip to content

Conversation

@Suhaib3100
Copy link

@Suhaib3100 Suhaib3100 commented Jan 31, 2026

Summary

Fixes React SSR escaping HTML entities that break email functionality.

Problem

React's SSR escapes special characters to HTML entities which causes:

  1. && in href attributes - breaks click tracking services (Azure Communication Services, etc.)
  2. >> in style tags - breaks CSS media queries like @media (width>=48rem)

Solution

Added a post-processing step in render() that selectively decodes HTML entities in:

  • href attribute values - decodes &&
  • <style> tag contents - decodes &gt;, &lt;, &amp;

This is a targeted fix that doesn't affect text content where entities should remain encoded.

Changes

  • Added decodeHtmlEntities utility in packages/render/src/shared/utils/
  • Applied to all render paths (node, browser, edge)
  • Added 14 tests covering href and style tag scenarios

Testing

  • ✅ All 62 tests passing
  • ✅ Build succeeds for all environments

Fixes #1767
Fixes #2841


Summary by cubic

Decode HTML entities in SSR output to fix broken email links and CSS. This prevents click tracking URLs and media queries from failing in rendered emails.

Written for commit 5026fb7. Summary will update on new commits.

React's SSR escapes special characters to HTML entities which breaks:
- URLs with query parameters (&amp;) causing issues with click tracking
- CSS media queries in style tags (&gt;) breaking Tailwind responsive utilities

This adds post-processing to decode entities in:
- href attribute values
- <style> tag contents

Fixes resend#1767
Fixes resend#2841
@changeset-bot
Copy link

changeset-bot bot commented Jan 31, 2026

🦋 Changeset detected

Latest commit: 5026fb7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@react-email/render Patch
@react-email/components Patch
@react-email/tailwind Patch
playground Patch
@react-email/preview-server Patch
react-email Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Jan 31, 2026

@Suhaib3100 is attempting to deploy a commit to the resend Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 31, 2026

Open in StackBlitz

npm i https://pkg.pr.new/resend/react-email/@react-email/render@2920

commit: 5026fb7

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.

1 issue found across 6 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/render/src/shared/utils/decode-html-entities.spec.ts">

<violation number="1" location="packages/render/src/shared/utils/decode-html-entities.spec.ts:6">
P2: Rule violated: **No `should` in tests**

Test descriptions must not include the word "should" (rule: "No `should` in tests"). Rewrite these descriptions in direct, declarative language (e.g., "decodes &amp; in href attributes").</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

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.

Incorrect display of quotes in styles and string links when exporting in react-email React Email v5 generates malformed CSS for responsive utilities

1 participant