Skip to content

feat(render): pass render options to rendered component #2417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: canary
Choose a base branch
from

Conversation

emiliosheinz
Copy link

Summary

This PR introduces the ability to pass render options directly to rendered components via a new reactEmailRenderOptions prop. This enables components to access rendering configuration and adapt their behavior based on the rendering context.

Changes

  • Added withAdditionalProps utility function to inject render options as props
  • Updated both browser and node render functions to pass options to components
  • Added comprehensive tests for all render environments (browser, node, edge)

Why this change?

Components can now access render options (like plainText, pretty, etc.) directly through props, allowing them to conditionally render content or adjust behavior based on the rendering context. This is particularly useful for components that need to adapt their output format. More details on use cases can be found here: #1926

Example Usage

function EmailTemplate({ reactEmailRenderOptions }) {
  if (reactEmailRenderOptions?.plainText) {
    return 'Plain text version';
  }
  return <div>HTML version</div>;
}

Copy link

changeset-bot bot commented Aug 11, 2025

⚠️ No Changeset found

Latest commit: 78e636a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

vercel bot commented Aug 11, 2025

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

A member of the Team first needs to authorize it.

Copy link

pkg-pr-new bot commented Aug 11, 2025

Open in StackBlitz

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

commit: 78e636a

@emiliosheinz emiliosheinz force-pushed the feat/pass-options-to-rendered-component branch from 5d1ee79 to 78e636a Compare August 13, 2025 13:24
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.

1 participant