shellscape / jsx-email

Build emails with a delightful DX
https://jsx.email
MIT License
961 stars 31 forks source link

Unable to render in a next.js server action #40

Closed yannxaver closed 10 months ago

yannxaver commented 10 months ago

Expected Behavior

Should be able to render in a server action.

Actual Behavior

You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.
Learn more: https://nextjs.org/docs/getting-started/react-essentials

The error was caused by importing '@jsx-email/render/dist/es/index.js' in './app/action.ts'.

Additional Information

This is related to https://github.com/resendlabs/react-email/issues/871 https://github.com/vercel/next.js/issues/43810 (probably includes the fix)

It has been fixed in react-email already because I was able to render in a server action using their package before.

shellscape commented 10 months ago

https://github.com/shellscape/jsx-email/pull/36 will resolve this.

shellscape commented 10 months ago

Please try the latest version of render. The all package is on a delay.

yannxaver commented 10 months ago

Looks good. (https://stackblitz.com/edit/stackblitz-starters-f4gt7r?file=package.json)

So the solution for now would be to install all components individually and to not use the all package? When do you roughly expect it to be updated?

tbh, it was unexpected that the all package exports render as well. In the docs it sounds like it just exports the components.

shellscape commented 10 months ago

thought about changing that too, but went with it as it is to make it easy for people to switch from react-render

shellscape commented 10 months ago

all v2.1.0 published

Please give this a test and let us know how it works out

yannxaver commented 10 months ago

No more error message (https://stackblitz.com/edit/stackblitz-starters-83gr6n?file=app%2Faction.ts)

The rendering output also looks good.

Do you plan to publish releases here with change logs? I would subscribe to them.

shellscape commented 10 months ago

Do you plan to publish releases here with change logs? I would subscribe to them.

possibly in the future, but for now we're just tagging and updating the changelog.