Export HTML
ExportExport HTML
Email-safe, CSS-inlined HTML, the default export.
ts
ref.current.editor.exportHtml((data) => data.html);
// server: renderDesign(design, { fullDocument: true }) // from email-craft-sdkCSS is inlined (via juice) with media queries preserved, tested across major clients. See the export overview.
What the callback gets
html, the full document.design, the JSON to store and reopen withloadDesign.chunks.body(the<body>element) andchunks.css(the text of the style tags), for code written for Unlayer.exportId, a new id for each call, andtagwhen you passed one.
Call it without a callback to get a promise. The options take mergeTags (values put into the HTML), timeoutMs, tag and onError. Without onError, a failed export is thrown so it shows in the console.
ts
const { html, design } = await ref.current.editor.exportHtml({
mergeTags: { first_name: "Asha" },
timeoutMs: 15000
});Server options
renderDesign inlines CSS unless you pass inlineCss: false. If the inliner cannot parse a stylesheet, the email still renders, with its styles left in the head. fullDocument is false by default (you get the styles and body markup only), and minify is off by default.
The output follows the builder: in page, document and popup mode exportHtml returns that builder's HTML, see Page Builder.