Skip to content

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

Draft
bukinoshita wants to merge 2 commits intomainfrom
fix/react-email-props-3ebf
Draft

feat: add --react-email-props support for prop-driven templates#232
bukinoshita wants to merge 2 commits 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.

  • 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>
@bukinoshita
Copy link
Copy Markdown
Member Author

@cursor fix conflict

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 14, 2026

The PR description was edited by cubic (auto-generated), and the title is fine. No need to update anything - the conflict is resolved and pushed.

Resolved the merge conflicts with main. The upstream changes included:

  • Empty path validation and directory detection in buildReactEmailHtml
  • Mutual exclusivity checks for --html/--html-file and --text/--text-file in broadcasts commands
  • --dry-run support in broadcasts create
  • Refactored body assignment to ternary expressions (replacing imperative let/reassign)
  • outputError now uses console.error instead of console.log

I merged all upstream changes with the prop-forwarding feature, updated the test spies from console.log to console.error, and verified everything passes: 800 tests green, lint clean, typecheck clean.

Open in Web Open in Cursor 

Integrate upstream changes:
- Empty path validation in buildReactEmailHtml
- Directory detection in buildReactEmailHtml
- --html/--html-file and --text/--text-file mutual exclusivity checks
- --dry-run support in broadcasts create
- Refactored body assignment to ternary expressions
- outputError now uses console.error (updated tests accordingly)

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