A React email helper to get the HTML of a React email component (InkDes Mailer)
npm install @inkdes-email/get-htmlHelper function to convert Email components to text only.
``bashpnpm
pnpm add @inkdes-email/get-html
- Signature:
(EmailTemplate: any) => {html: string | null, error: Error | null}
- Description: Renders a valid React element to a static HTML string using renderToStaticMarkup. Returns { html, error: null } on success or { html: null, error } on failure. Validates input with React.isValidElement.
- Example:`tsx
import { getHtml } from "@inkdes-email/get-html";
import { Html, Head, Body, Text, Button } from "@inkdes-emailcomponents";function EmailTemplate() {
return (
Hello
)
}const { html, error } = getHtml( );
if (error) {
// handle error
} else if (html) {
// use html
}
``- Requirements:
- Node >= 18
- React 18 or 19