Vue integration
Embed the hosted MailLayers editor in Vue 3
Use the lightweight Vue SDK to mount the hosted MailLayers editor in an iframe with typed props, lifecycle events, exposed reload methods, and deterministic unmount cleanup.
Published on npm
Version 0.1.0 · Install from npm or review the source on GitHub.
npm install @maillayers/vue-email-editorProduction integration
Content, assets, security, and lifecycle
A useful embedded email editor is more than a mounted component. Plan the persistence and trust boundaries before connecting it to customer data.
Editor data methods
Use getHtml() for a sendable snapshot and getJson() for structured editor state. Call reload() only when staged content or configuration should start a new iframe handshake; use ready, load, change, save, and status callbacks for normal updates.
Assets
Implement upload, list, and delete handlers against storage owned by your application. Validate file type and size on the server, authorize each tenant-scoped object, return HTTPS URLs, and treat delete as an authenticated operation.
API keys and allowed domains
Use a browser SDK key only from an exact configured origin. Keep privileged secrets on your server, issue scoped embed tokens after authenticating the user, and do not treat iframe messages as trusted until origin and payload validation pass.
Multiple instances
Give each mounted editor stable state and separate callbacks. Avoid reusing one imperative ref across instances, and unmount inactive editors when tabs or routes no longer need them so listeners and iframe resources are released.
Performance
Reserve editor height to prevent layout shift, defer mounting until the authoring UI is needed, and show a stable loading fallback. Avoid remounting the iframe for ordinary form-state changes; prefer events and staged reloads.
Troubleshooting
If the editor does not become ready, verify the allowed origin, browser key, embed-token lifetime, editor URL, and Content Security Policy. For missing saves, inspect callback errors and confirm the host persistence request succeeds independently of the iframe.
Integration
Vue props and events map to the hosted iframe bridge
- 01
Pass apiKey, embedToken, and initialHtml through props. Content props are staged reactively and applied when reload() starts a new handshake.
- 02
Listen for change, save, ready, load, statusChange, and authError events without allowing a host-listener exception to break the editor lifecycle.
- 03
Use the component ref for reload when staged initial content or configuration should begin a new handshake. onBeforeUnmount tears down the iframe bridge.
Relevant capabilities
What this integration actually supports
Product boundary: MailLayers is the hosted editing surface, not an authentication provider, asset store, approval engine, ESP, or email delivery service. Imports are SSR-safe, but mounting requires the browser.
Related integration guides
Engineering articles
Read implementation notes about editor security, persistence, asset workflows, and framework-specific patterns.
Browse the MailLayers blogFAQ
Questions specific to this integration
Which Vue version is supported?
Vue 3.4 and later. The package uses the Composition API and requires vue >=3.4.0 as a peer dependency.
Can Nuxt import the package?
The package import is SSR-safe, but the editor component must mount on the client.
How do I persist editor content?
Handle the change event for draft HTML and the save event when you need a committed snapshot for your sending workflow.
Continue with the verified integration guide
Review licensing, allowed domains, events, assets, SSR boundaries, and troubleshooting before production use.