Export designs

Getting started

Export designs

Turn a design into whatever your pipeline needs, HTML, plain text, AMP, or a ZIP bundle.

tsx
ref.current.editor.exportHtml((data) => data.html);       // email-safe HTML + design
ref.current.editor.exportPlainText((data) => data.text);  // text/plain part
ref.current.editor.exportAmp((data) => data.amp);         // AMP for Email
ref.current.editor.exportZip((data) => data.zip);         // HTML + MJML + AMP + text + JSON

For a document or popup the same exportHtml returns the right output, it's builder-aware. Server-side, render with email-craft-sdk (renderDesign, renderMjml, renderDocument, renderPopupHtml), see Rendering & export.

Image and PDF export run server-side (headless). Surfacing them as in-editor callbacks is on the roadmap.

Callback or promise

Every export takes a callback, as in Unlayer. Called without one, it returns a promise of the same data, which rejects if the export fails.

ts
const { html, design } = await editor.exportHtml();

editor.exportHtml((data) => save(data), {
  tag: currentDesignId,   // echoed back as data.tag
  timeoutMs: 30000,       // wait longer for a large design
  onError: (err) => console.error(err),
});

Each result also carries an exportId. Use tag to match a slow export to the design it was asked for, in case the user opened another design meanwhile. Without onError, a failed export is thrown so it shows in the console. In the browser, exportImage and exportPdf answer { design, url: null, error }.

What the ZIP holds

exportZip and the server's renderEmailZip(design, options) build index.html, email.mjml, email.amp.html, email.txt, design.json and a README.txt. On the server, set includeMjml, includeAmp, includePlainText or includeJson to false to leave a file out (each defaults to true). emailZipFilename(design) makes a file name from the design title.