Email Love
Generate API key

SDK documentation

Email Love’s drag-and-drop email editor and the engine under it, open source under the BSD 3-Clause license. Put the editor in your own app. People build emails from a design system’s components, and your app gets email-ready HTML.

GitHub · @email-love/editor · @email-love/core · Help center · Live demo

Overview

It’s the editor and engine inside Email Love Builder. There are two packages:

PackageWhat it is
@email-love/editorThe drag-and-drop email editor, for React. mountEmailLoveEditor puts it in an app without React. It renders with MJML in the browser, the same way it renders on export.
@email-love/coreThe engine. It renders an email from a design system and a document, checks it, and imports MJML or HTML. Node or the browser, no React.

Both come with the Ultimate Email Design System built in: 217 components and four starter emails. It’s also free on Figma.

Install

The editor. React 18 is your app’s own:

npm install @email-love/editor react react-dom

Just the engine:

npm install @email-love/core

Quick start

Import the editor and its stylesheet. The element around it needs a height.

import EmailLoveEditor from '@email-love/editor'
import '@email-love/editor/style.css'

<div style={{ height: 720 }}>
  <EmailLoveEditor
    email={{ open: async () => savedDocument, save: async document => saveSomewhere(document) }}
    images={{ upload: async file => ({ url: await uploadSomewhere(file) }) }}
    onOpen={async session => console.log(await session.getHTML())}
  />
</div>

Without React

mountEmailLoveEditor takes the element and the same options.

import { mountEmailLoveEditor } from '@email-love/editor'

const editor = mountEmailLoveEditor(document.getElementById('editor'), { email, images })
const session = await editor.ready
const html = await session.getHTML()

Vite

The renderer runs in a worker file that ships beside index.js. Bundlers copy it for you. With Vite, also leave the package out of its development pre-bundling, or the worker isn’t found while developing:

// vite.config.js
export default { plugins: [react()], optimizeDeps: { exclude: ['@email-love/editor'] } }

Your app keeps the data

The editor has no server and sends nothing anywhere. Your app decides where emails and pictures go.

OptionWhat it does
email.open()Returns the saved document, or nothing.
email.save(document)Keeps it. Throw to have it tried again 1, 3 and 8 seconds later. Throw an error with retry: false not to.
email.startFromThe document for an email with nothing saved yet. It isn’t saved until it’s changed.
images.upload(file)Returns { url, alt } or the address. It must be https. images.types and images.maxBytes limit the file.
autosaveAfterMilliseconds after a change (2000). null to save only when asked.
designSystem{ tokens, components }. Leave it out for the Ultimate Email Design System.
componentsYour own components, added to the design system’s.
modulesThe component keys people can add.
assetBaseWhere you serve the starter’s pictures and the carousel, accordion and social icons. Default https://app.emaillove.com.
readOnly, onChange, onErrorRead-only mode, every change, and errors.

All the options: Options and session in the help center.

The session

onOpen(session), or await editor.ready without React, gives you save(), close(), getJSON(), upload(file), and getHTML(), getMJML() and getText(), which return promises.

session.subscribe(({ status, error }) => …) reports loading, load-failed, saved, unsaved, saving and save-failed.

Design systems

A design system is { tokens, components }. Tokens hold the colors, fonts, text styles, buttons, layout, logos and social icons. Each component has a key, a version, an MJML template and the fields a person can edit. A document lists blocks, each naming a component and holding its own values.

Add your own components with the editor’s components option, or with addComponents(designSystem, components) from @email-love/core/components. A component that can’t be used is left out, with a reason. Give your keys a prefix of your own.

The formats: FORMAT.md on GitHub, and Design systems and your own components in the help center.

Core engine

Render an email without the editor, in Node or the browser:

import { renderEmail } from '@email-love/core'
import { starterDesignSystem, starterEmails } from '@email-love/core/starter'

const designSystem = starterDesignSystem()
const [welcome] = starterEmails()

const { ok, html, errors } = await renderEmail(designSystem, welcome.document)
ImportWhat’s in it
@email-love/corerenderEmail(designSystem, document, options) returns { ok, html, mjml, errors, warnings }. Also cleanDocument, createDesignSystem, documentOps and applyDocumentOps.
@email-love/core/starterThe Ultimate Email Design System and its four emails.
@email-love/core/componentsaddComponents: your own components, checked.
@email-love/core/formatcheckDesignSystem: what’s wrong with a design system, in words.
@email-love/core/editingA headless editor: insert, move, duplicate and remove sections, set fields, undo and redo.
@email-love/core/previewrenderPreview: the marked-up preview an editor’s canvas draws.
@email-love/core/importimportMjml(mjml) and importHtml(html, designSystem).
@email-love/core/plain-textplainTextOf(html): the plain-text part, with links and merge tags kept.

More: Core engine in the help center.

The SDK and the Builder

Test emails, live co-editing, AI, accounts and export to email platforms are in the hosted Email Love Builder, not the SDK. You can add them to your own app: the session gives you the HTML, MJML and plain text, and onChange gives you every change. See Email Love SDK for hosted plans, and Pricing for the Builder.

License

BSD 3-Clause, Copyright Email Love LLC. Each package lists the third-party code it includes. The Email Love name and logo aren’t covered by the license. Issues and pull requests are welcome on GitHub. Common questions: SDK FAQ.

Questions? hello@emaillove.com