Skip to content

feat: add --react-email-props support for prop-driven templates#232

Draft
bukinoshita wants to merge 1 commit intomainfrom
fix/react-email-props-3ebf
Draft

feat: add --react-email-props support for prop-driven templates#232
bukinoshita wants to merge 1 commit intomainfrom
fix/react-email-props-3ebf

Conversation

@bukinoshita
Copy link
Copy Markdown
Member

@bukinoshita bukinoshita commented Apr 9, 2026

Summary by cubic

Enables prop-driven React Email templates by passing props through the renderer and adding CLI flags to supply them. Fixes BU-611 where templates rendered with empty props, causing missing content or crashes.

  • New Features

    • renderReactEmail(cjsPath, props?) and buildReactEmailHtml(path, opts, props?) now accept a props object and forward it to the component.
    • New --react-email-props <json> and --react-email-props-file <path> flags on: emails send, emails batch, templates create, templates update, broadcasts create, broadcasts update.
    • Added parseReactEmailProps to parse/validate inline JSON or file-based props.
    • Tests added for parsing and prop forwarding.
  • Bug Fixes

    • Removed hardcoded {} in the React Email rendering pipeline; props are now correctly passed to components.
    • Validation: props flags require --react-email, are mutually exclusive, and must parse to a JSON object (not array/null/primitive).

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

The React Email rendering pipeline previously hardcoded an empty props
object when instantiating components, causing prop-driven templates to
either render blank content or throw at render time.

Changes:
- renderReactEmail now accepts an optional props parameter and forwards
  it to reactEmailCreateReactElement instead of hardcoding {}
- buildReactEmailHtml accepts an optional props parameter and threads
  it through to renderReactEmail
- New parseReactEmailProps utility parses props from --react-email-props
  (inline JSON) or --react-email-props-file (JSON file path)
- All 6 commands that support --react-email now also accept
  --react-email-props and --react-email-props-file:
  emails send, emails batch, templates create, templates update,
  broadcasts create, broadcasts update
- Added validation: props flags require --react-email, and the two
  props flags are mutually exclusive
- Added tests for parseReactEmailProps and prop forwarding in commands

Resolves BU-611

Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
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