Documentation Get started
JavaScript quickstart
Mount an editor and export your first email as HTML.
On this page
1. Get your editor key
In the dashboard, create or select an editor and copy its public key. Allow your application’s origin, including the scheme and port: for example, https://app.example.com.
2. Install the SDK
npm install @weavour/editor3. Add a container
Give the container an explicit height. Mount after the element exists.
<div id="email-editor" style="height: 700px"></div>4. Mount and export
Replace the key and IDs with your own. Pass organizationId when users share an organization’s library; omit it for a personal library. Run this code in the browser.
import { mount } from '@weavour/editor';
try {
const editor = mount('#email-editor', {
editorKey: 'YOUR_PUBLIC_EDITOR_KEY',
userId: 'user-123',
organizationId: 'organization-456',
locale: 'en',
onError(error) {
console.error(error);
},
});
await editor.ready;
const { html, text, subject, preheader } = await editor.exportHTML();
// Pass these fields to your application's delivery workflow.
} catch (error) {
console.error('The editor could not load or export:', error);
}Without a bundler
Use the versioned browser script to access Weavour.mount().
<div id="email-editor" style="height: 700px"></div>
<script src="https://weavour.com/editor/sdk/0.1.12/editor.js"></script>
<script>
async function openEditor() {
const editor = Weavour.mount('#email-editor', {
editorKey: 'YOUR_PUBLIC_EDITOR_KEY',
userId: 'user-123',
onError: console.error,
});
await editor.ready;
return editor;
}
openEditor().catch(console.error);
</script>