Prompt for your AI assistant

Paste into Cursor, Claude Code, Codex, or GitHub Copilot:

I am integrating Dragble in my React app. First check the Dragble docs at https://www.dragble.com/docs/quickstart/react.
1. Run npm install dragble-react-editor.
2. Add an EmailEditor component with editorRef, onReady, and exportHtml().
3. Container needs an explicit height (e.g. style={{ height: "100vh" }}).

React Quickstart

Get a drag-and-drop email editor running in React in under 2 minutes using the official dragble-react-editor package.

Prerequisites

You need an editorKey from the Dragble Dashboard. This authenticates your editor instance.

Install the package

bash
npm install dragble-react-editor
bash
yarn add dragble-react-editor
bash
pnpm add dragble-react-editor

The Dragble SDK is loaded automatically from the CDN — no script tag required.

Add the editor component

plaintext

import {
  DragbleEditor,
  type DragbleEditorRef,
  type DesignJson,
  type DragbleSDK,
} from "dragble-react-editor";

export default function EmailEditor() {
  const editorRef = useRef<DragbleEditorRef>(null);

  const handleReady = (editor: DragbleSDK) => {
    console.log("Editor is ready", editor);
  };

  const handleChange = (data: { design: DesignJson; type: string }) => {
    console.log("Design changed:", data.design);
  };

  const handleExportHtml = async () => {
    const html = await editorRef.current?.editor?.exportHtml();
    console.log("Exported HTML:", html);
  };

  return (
    <div style={{ height: "100vh", display: "flex", flexDirection: "column" }}>
      <div style={{ padding: "8px" }}>
        <button onClick={handleExportHtml}>Export HTML</button>
      </div>
      <DragbleEditor
        ref={editorRef}
        editorKey="YOUR_EDITOR_KEY"
        editorMode="email"
        minHeight="600px"
        onReady={handleReady}
        onChange={handleChange}
        onError={(error) => console.error("Editor error:", error)}
      />
    </div>
  );
}
Replace placeholder

Replace YOUR_EDITOR_KEY with the editor key from your Dragble Dashboard.

You should see a drag-and-drop email editor with a toolbar on the right, content blocks on the left, and a canvas in the center.

Export HTML

The SDK methods are available on the ref. All exports are Promise-based:

tsx
const handleExportHtml = async () => {
  const html = await editorRef.current?.editor?.exportHtml();
  if (html) {
    // Send to your backend, preview, or download
    console.log(html);
  }
};

Save and load designs

To persist work and reload it later, use exportJson / loadDesign:

tsx
// Save
const design = await editorRef.current?.editor?.exportJson();
await fetch("/api/designs", {
  method: "POST",
  body: JSON.stringify(design),
  headers: { "Content-Type": "application/json" },
});

// Load a previously saved design
editorRef.current?.editor?.loadDesign(savedDesignJson);

Hook alternative

For a slightly more compact setup, the package also exports a useDragbleEditor hook:

tsx

function MyEditor() {
  const { ref, editor, isReady } = useDragbleEditor();

  return (
    <>
      <button
        onClick={async () => console.log(await editor?.exportHtml())}
        disabled={!isReady}
      >
        Export
      </button>
      <DragbleEditor ref={ref} editorKey="YOUR_EDITOR_KEY" />
    </>
  );
}

Next steps