Replies: 6 comments 3 replies
-
I also am trying to do this. I have AWS Lambda using node.js and so getting a jsx error following the AWS SES example. |
Beta Was this translation helpful? Give feedback.
-
Hey @giopetris 👋 Should be able to do it like this: import EmailComponent from "path/to/component";
import { render } from "@react-email/render";
const html = render(EmailComponent({prop1: 'value'})) |
Beta Was this translation helpful? Give feedback.
-
Hey @zachgoll 👋 , this didnt work for me using using ts + nextjs, got the error
Can you advice? thanks |
Beta Was this translation helpful? Give feedback.
-
I'm not sure you can use EmailComponent directly. You need to use: React.createElement(EmailComponent, .... I'm using a library called htm which replaces JSX and saves the verbosity of React.createElement. Here is my sample: `const React = require('react') const Email = ({ url }) => { const emailHtml = render(html |
Beta Was this translation helpful? Give feedback.
-
We have an example with Next.js + React Email + Resend here. Let me know if that helps you. |
Beta Was this translation helpful? Give feedback.
-
Using import { Text } from '@react-email/text';
export type EmailProps = { content: string };
export const Email: React.FC<EmailProps> = ({ content }) => {
return <Text>{content}</Text>;
}; Now in a next.js API route: const props = { content: "Prop passed to component in Node.js" };
const emailElement = React.createElement(Email, props);
const html = render(emailElement, {}); Now html has the value |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
How can I render a template through Node and also passing props to the template?
Beta Was this translation helpful? Give feedback.
All reactions