Open maccman opened 12 months ago
Hey ! I am having exactly the same issue when using edge/runtime :/
I've also found that <Tailwind />
doesn't work under the edge env.
Could you provide an example on how you patch it?
@maccman Could you please share how you pathed it? 🙏
any solutions i also have just encountered this issue
I'm also encountering this issue. @maccman could you post your solution?
I just ran into this too, was there a patch posted anywhere?
I ran into this back in July and made a Discord post about it (the Tailwind component breaking on edge) as well, but no response yet. I fiddled around with react-dom/server but I couldn't get it to work. I'm curious how @maccman worked around all of this.
I ended up pre-rendering the email component off of edge with some placeholders and grabbing the HTML, and then at runtime find-replacing the placeholders with the actual values. Horrible workaround, but it's the only way I can get the flow I need to work.
This SO answer worked for me
Here's a workaround for now for anyone that's still hitting this issue up:
Upgrade your @react-email/render
, @react-email/tailwind
, and @react-email/components
(where applicable) to the latest because @react-email/render
's latest has the renderAsync
best tuned for the latest React and performance and @react-email/tailwind
removes its use of renderToStaticMarkup
on the latest.
render
with renderAsync
Replace all occurrences of renderAsync
with just render
This should work for Next 13 and 14 alike, something that serverComponentsExternalPackages
did not.
@gabrielmfern Your answer also works if you get this error:
TypeError: (0 , _react_email_render__WEBPACK_IMPORTED_MODULE_4__.renderAsync) is not a function
at renderEmailByPath (webpack-internal:///(rsc)/./src/actions/render-email-by-path.tsx:35:94)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Page (webpack-internal:///(rsc)/./src/app/preview/[...slug]/page.tsx:37:34)
I had outdated versions of "@react-email/render" ("^0.0.7"), updated to 0.0.13 and "@react-email/components" ("0.0.14"), updated to 0.0.17
Describe the Bug
I'm getting an error "Unable to import react-dom/server in a server component" when I try to use react-email under a API route using Nextjs' edge runtime and the new
app
dir routing.Following tips from this ticket I've now patched react-email to load react-dom/server dynamically which seems to be working.
Which package is affected (leave empty if unsure)
No response
Link to the code that reproduces this issue
https://github.com/vercel/next.js/issues/43810
To Reproduce
Expected Behavior
Should work!
What's your node version? (if relevant)
No response