Getting TypeErrors and unable to access components built with @react-email/components as ReactNode #2407
Unanswered
chandrabhan-singh-1
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
MessageChannel Error in Convex Server Environment - React Email Components Not Rendering
Environment
Problem Summary
React Email components fail to render in Convex server environment with
MessageChannel is not defined
error. Components appear to not be recognized as proper ReactNodes, requiring workarounds that still don't resolve the underlying issue.Expected Behavior
Based on documentation, this should work:
Actual Behavior
Issue 1: JSX Syntax Not Recognized
Components cannot be passed as JSX to the render function. TypeScript throws errors:
'>' expected
'MyEmailTemplate' refers to a value, but is being used as a type here
Issue 2: Function Call Workaround Fails
When calling components as functions instead of JSX:
This results in:
Uncaught ReferenceError: MessageChannel is not defined
Minimal Reproduction
Email Component (
components/email/verification-email.tsx
)Server-side Usage (Convex environment)
Error Details
Uncaught ReferenceError: MessageChannel is not defined
at [internal Convex runtime]
Investigation & Attempted Solutions
1. Polyfill Attempts
2. React.createElement Approach
Root Cause Analysis
The issue appears to be that
@react-email/render
uses browser-specific APIs (MessageChannel
, potentially others) that are not available in Convex's server runtime environment. This is similar to issues that might occur in:Repository for Reproduction
Live reproduction: https://github.com/chandrabhan-singh-1/reminderrr.git
Example
.env.local
fileThe repo contains a complete setup with:
Impact
This blocks email functionality for user authentication in production applications using Convex as a backend. Currently have no working solution for sending styled emails.
Questions for Maintainers
Intended Support: Is
@react-email/render
intended to work in server-only environments like Convex?Required Polyfills: What's the complete list of browser APIs that need to be polyfilled for server-side usage?
Alternative Approaches: Is there a recommended server-only rendering method that doesn't rely on browser APIs?
Environment Detection: Would the library benefit from detecting the runtime environment and using appropriate rendering strategies?
Suggested Solutions
@react-email/render/server
that doesn't use browser APIsrenderToString
method that uses Node.js-compatible APIsWorkaround Request
If there's any temporary workaround or configuration that would allow React Email to work in Convex, that would be incredibly helpful while a proper solution is developed.
Thank you for your time and for maintaining this excellent library!
Beta Was this translation helpful? Give feedback.
All reactions