Render
Render Email Craft components to HTML email
Install
Install the package from your command line
console
pnpm install email-craft
pnpm install email-craft
console
bun install email-craft
bun install email-craft
console
npm install email-craft
npm install email-craft
console
yarn install email-craft
yarn install email-craft
Usage
jsx
import { render } from 'email-craft';
import { BatmanTemplate } from './emails/Batman';
const html = await render(<BatmanTemplate firstName="Bruce" lastName="Wayne" />);
import { render } from 'email-craft';
import { BatmanTemplate } from './emails/Batman';
const html = await render(<BatmanTemplate firstName="Bruce" lastName="Wayne" />);
Method Options
ts
export interface Options {
minify?: boolean;
plainText?: boolean | PlainTextOptions;
pretty?: boolean;
}
export interface Options {
minify?: boolean;
plainText?: boolean | PlainTextOptions;
pretty?: boolean;
}
Options
ts
minify?: boolean;
minify?: boolean;
Minify the HTML for rendered templates
ts
plainText?: boolean | PlainTextOptions;
plainText?: boolean | PlainTextOptions;
If true
or an object
, renders the target email(s) to plain text. If the need to modify how the target is rendered to plain text, an object
representing html-to-text
options should be used.
ts
pretty?: boolean;
pretty?: boolean;
Beautify the HTML output for each target email
Debugging
The rendered HTML can often be difficult to trace or match back to the JSX source template. To make things easier, users can enable a debugging flag which will output email-craft-specific data-type
attributes in the HTML. To enable this, set an environment variable like so: DEBUG=email-craft:elements
.
Users may also wish to pass the { minify: false }
option to the render
method.