Documentation navigation

Email Render

@markrelay/email-render turns the JSON produced by the email editor into HTML that renders correctly in real email clients — table-based layout, preheader support — or into plain text. It runs anywhere JavaScript runs: Node, Cloudflare Workers, or the browser.

Render HTML

import { render } from "@markrelay/email-render";

const html = await render(doc, {
  preview: "Your January invoice is ready",  // inbox preview text
});

The renderer automatically reads the validated theme snapshot fromdoc.theme, so preview and delivery do not need a separate theme lookup.

Variables

import { Markrelay } from "@markrelay/email-render";

const markrelay = new Markrelay(doc);
markrelay.setVariableValue("firstName", "Carol");
const html = await markrelay.render();
// unset variables fall back to their declared fallback text

Plain text

// Full-fidelity (async, runs the React pipeline):
const text = await render(doc, { plainText: true });

// Cheap synchronous projection — snippets, text alternatives:
import { toPlainText } from "@markrelay/email-render";
const text = toPlainText(doc);

Everything else

  • renderReact(doc) from @markrelay/email-render/react-code exports the document as React Email JSX source — take a design out of MarkRelay and into a react-email codebase.
  • Theme system for fonts, colors, and spacing; per-document preview text; deterministic output suitable for snapshot testing.
  • Battle-tested in production: the self-hosted app renders every campaign email with it, inside a Cloudflare Worker.

Available to Source License customers as workspace packages — see pricing.