Appearance
NPM Package Integration
The Getting Started guide embeds the editor with a plain <script> tag. In a project built around a bundler or a component framework, the official NPM packages do the same job with proper TypeScript types and lifecycle handling. The editor script is loaded for you, and in React and Vue the editor mounts and tears down together with the component that holds it.
Create your API token first
The packages wrap the editor, not the authorization. The editor still needs the Public API key from Step 1 in Getting Started.
Let your coding agent do it recommended
The fastest way to integrate is to hand the job to your AI coding agent. The official topol-editors-integration skill teaches it the current package API for both editors.
1. Install the skills in the project that will embed the editor:
claude
/plugin marketplace add TOPOL-io/skills
/plugin install topol-editors@topolbash
npx skills@latest add TOPOL-io/skillsThe skills are plain markdown in TOPOL-io/skills, so you can read what the agent will do before it runs, or point any other agent at the files directly.
2. Ask for the integration, in your own words:
text
Add a Topol landing page editor screen to this appThe agent picks the package for your framework, installs it with your package manager, mounts the editor in a sized container, wires onSave and onEditorError, reads the API key from your environment configuration, and runs your type-check and build.
3. Finish what only you can decide: where saved pages are stored, adding your domain to the token's allowed domains, and opening the page once to see the editor load.
4. Add nonce authentication. It is the setup we recommend before real users open the editor: ask the agent to "add Topol nonce authentication", or follow Nonce Authentication yourself.
Install it yourself
| Package | Framework |
|---|---|
@topol.io/editor | Plain JavaScript or TypeScript |
@topol.io/editor-react | React |
@topol.io/editor-vue | Vue 3 |
Landing Page Editor support ships in v1 of these packages:
bash
npm install @topol.io/editorbash
npm install @topol.io/editor-reactbash
npm install @topol.io/editor-vueThe @topol.io/editor-svelte package does not include the Landing Page Editor yet.
All packages take the same configuration as the script-tag integration: options go under config, callbacks are top-level properties. Everything documented in Editor Options applies unchanged.
JavaScript / TypeScript
@topol.io/editor exports a LandingPageEditor object with an async init() method. It loads the editor script, creates an instance, and resolves with it. The resolved instance is the same one the global LandingPageEditor() factory returns:
typescript
import { LandingPageEditor } from "@topol.io/editor";
const editor = await LandingPageEditor.init({
config: {
authorize: {
apiKey: "YOUR_API_KEY", // Public API key from your Topol account
entityId: "user-123", // Any unique ID for your user
},
},
onSave({ json, html }) {
// `json` is the template definition, `html` the rendered page
console.log("Saved landing page:", json, html);
},
onInit() {
console.log("Landing Page Editor is ready");
},
});
// Render the editor into a container element
editor.render("#landing-page-editor");
// Optionally load a template
editor.load(templateJson);
// Clean up when the editor is no longer needed
editor.destroy();One difference from the script-tag integration:
init()is asynchronous. It resolves once the editor script has loaded, and rejects if loading fails.
Call destroy() when navigating away from the page that hosts the editor; it removes the editor and cleans up its resources.
The container element works the same as in the script-tag setup, and still needs an explicit width and height:
html
<div id="landing-page-editor" style="width: 100%; height: 100vh;"></div>React
@topol.io/editor-react exports a LandingPageEditor component. It renders its own container, initializes the editor on mount, and destroys it on unmount. Callbacks are passed as props, and programmatic control (load, save) goes through a ref:
tsx
import { useRef } from "react";
import {
LandingPageEditor,
type ILandingPageEditorRef,
type IReactLandingPageOptions,
} from "@topol.io/editor-react";
const options: IReactLandingPageOptions = {
authorize: {
apiKey: "YOUR_API_KEY",
entityId: "user-123",
},
};
export default function PageBuilder({ template }: { template: unknown }) {
const editorRef = useRef<ILandingPageEditorRef>(null);
return (
<LandingPageEditor
ref={editorRef}
options={options}
onSave={({ json, html }) => {
console.log("Saved landing page:", json, html);
}}
onInit={() => {
// The editor is ready: load the first template here
editorRef.current?.load(template);
}}
/>
);
}Notes:
- The
optionsprop takes the contents ofconfigdirectly (the component wraps it for you). - The component renders its own container,
100%wide and100vhtall by default, with no fixedid. PassclassNameorstyleto size it differently. - The ref exposes
load(template),save()andgetEditor(), which returns the editor instance for its other methods.load()andsave()return Promises; unmounting the component destroys the editor. onReadyreceives the instance once the iframe has rendered, andloaderUrlpoints the component at a preview or local build.- A Promise returned from
onSave,onSaveAndCloseoronEditorCloseis awaited. Passing agetNonceprop turns on nonce authentication. - Load the first template from
onInit, notonLoaded.onLoadedfires after everyload(), so loading from it starts a loop. - Every editor callback is available as a prop:
onSave,onSaveAndClose,onLoaded,onInit,onEditorClose,onPreview,onAlert,onEditorError, and the rest of the callback set. Each receives the same single payload object as in the script-tag integration.
Vue
@topol.io/editor-vue exports a LandingPageEditor component for Vue 3. Configuration goes into the options prop, callbacks arrive as events, and load, save and getEditor are exposed on the template ref:
vue
<script setup lang="ts">
import { ref } from "vue";
import {
LandingPageEditor,
type IVueLandingPageOptions,
} from "@topol.io/editor-vue";
const options: IVueLandingPageOptions = {
authorize: {
apiKey: "YOUR_API_KEY",
entityId: "user-123",
},
};
const editorRef = ref<InstanceType<typeof LandingPageEditor> | null>(null);
const handleSave = ({ json, html }: { json: unknown; html: unknown }) => {
console.log("Saved landing page:", json, html);
};
// The editor is ready: load the first template here
const handleInit = () => {
editorRef.value?.load(myTemplate);
};
</script>
<template>
<LandingPageEditor
ref="editorRef"
:options="options"
@on-save="handleSave"
@on-init="handleInit"
/>
</template>Notes:
- Events carry the same single payload object as the callbacks:
@on-savereceives{ json, html },@on-alertreceives{ notification }, and so on. - Event names follow Vue conventions:
onSavebecomes@on-save,onInitbecomes@on-init, and so on. - Event listeners cannot return a value to the editor. Pass handlers the editor must wait for, such as an async
onSave, andgetNoncefor nonce authentication, as functions through thecallbacksprop (ILandingPageCallbacks). @readyreceives the editor instance once the iframe has rendered.classandstylefall through to the container, which is100%wide and100vhtall by default.- Load the first template from
@on-init, not@on-loaded.onLoadedfires after everyload(), so loading from it starts a loop. - The component destroys the editor automatically before it unmounts.
TypeScript support
All three packages are written in TypeScript and export the Landing Page Editor types:
typescript
import type {
ILandingPageOptions, // full init() argument: { config, ...callbacks }
ILandingPageConfig, // the contents of `config`
ILandingPageCallbacks, // just the callback signatures
ILandingPageEditorInstance, // render / load / save / destroy
ILandingPageSavePayload, // what onSave receives
} from "@topol.io/editor";The framework packages re-export these, plus their own component types (IReactLandingPageOptions, ILandingPageEditorRef and ILandingPageEditorProps in React; IVueLandingPageOptions in Vue).
Next steps
- Configure the editor with Editor Options
- Control it programmatically with the instance methods
- Upgrading from the 0.x packages: NPM Packages: Upgrading to v1 lists everything that changed for the Email Editor. The Landing Page Editor is new in v1, so there is nothing to migrate.
- The Landing Page Editor lives in the same packages as a named export next to
EmailEditor, so one install covers both editors.
INFO
Running into trouble while integrating the NPM package? Contact our support team here and we'll help you get it working.
