DocsAPI ReferenceComponents<Editor>

<Editor>

Render the React Editor editor.

import { Editor, outlinePlugin } from "@reacteditor/core";
 
const config = {
  components: {},
};
 
const initialData = {
  content: [],
  root: {},
};
 
// blocksPlugin is auto-injected; outlinePlugin must be passed explicitly
// to enable the Outline panel.
const plugins = [outlinePlugin()];
 
export function Editor() {
  return <Editor config={config} data={initialData} plugins={plugins} />;
}

Props

ParamExampleTypeStatus
configconfig: { components: {} }ConfigRequired
datadata: {}DataRequired
dnddnd: {}DndConfig-
childrenchildren: <Editor.Preview />ReactNode-
fieldTransformsfieldTransforms: {text: () => <div />}FieldTransforms-
headerPathheaderPath: "/my-page"String-
headerTitleheaderTitle: "My Page"String-
heightheight: "100%"String | Number-
iframeiframe: {}IframeConfig-
initialHistoryinitialHistory: {}InitialHistory-
metadatametadata: {}Object-
onAction()onAction: (action, appState, prevAppState) => {}Function-
onChange()onChange: (data) => {}Function-
onPublish()onPublish: async (data) => {}Function-
overridesoverrides: { header: () => <div /> }OverridesExperimental
permissionspermissions: {}Permissions[]-
pluginsplugins: [myPlugin]Plugin[]Experimental
routesroutes: ["/", "/about"]String[]-
currentRoutecurrentRoute: "/about"String-
onRouteChange()onRouteChange: (path) => {}Function-
uiui: {leftSideBarVisible: false}AppState.ui-
viewportsviewports: [{ width: 1440 }]Viewport[]-
_experimentalFullScreenCanvas_experimentalFullScreenCanvas: trueBooleanExperimental

Required props

config

An object describing the available components, fields and more. See the Config docs for a full reference.

export function Editor() {
  return (
    <Editor
      config={{
        components: {
          HeadingBlock: {
            fields: {
              children: {
                type: "text",
              },
            },
            render: ({ children }) => {
              return <h1>{children}</h1>;
            },
          },
        },
      }}
      // ...
    />
  );
}

data

The initial data to render. Cannot be changed once <Editor> has been mounted. See the Data docs for a full reference.

export function Editor() {
  return (
    <Editor
      data={{
        content: [
          {
            props: { children: "Hello, world", id: "id" },
            type: "HeadingBlock",
          },
        ],
        root: {},
      }}
      // ...
    />
  );
}

Optional props

children

Render custom nodes to create compositional interfaces.

export function Editor() {
  return (
    <Editor /*...*/>
      <Editor.Preview />
    </Editor>
  );
}

dnd

Configure drag-and-drop behavior.

dnd params

ParamExampleTypeStatus
disableAutoScrolldisableAutoScroll: trueboolean-
disableAutoScroll

Disable auto-scroll when the user drags an item near the edge of the preview area.

fieldTransforms

Specify transforms to modify field values before being passed to the editor canvas. Implements the Field Transforms API.

export function Editor() {
  return (
    <Editor
      fieldTransforms={{
        text: ({ value }) => <div>{value}</div>, // Wrap all text field values in a div
      }}
      // ...
    />
  );
}

headerPath

Set a path to show after the header title

export function Editor() {
  return (
    <Editor
      headerPath="/my-page"
      // ...
    />
  );
}

headerTitle

Set the title shown in the header

export function Editor() {
  return (
    <Editor
      headerTitle="My page"
      // ...
    />
  );
}

height

Modify the height of the React Editor editor when using the standard layout. Defaults to 100dvh.

export function Editor() {
  return (
    <Editor
      height="100%"
      // ...
    />
  );
}

iframe

Configure the iframe behaviour.

export function Editor() {
  return (
    <Editor
      iframe={{ enabled: false }}
      // ...
    />
  );
}

iframe params

ParamExampleTypeStatus
enabledenabled: falseboolean-
waitForStyleswaitForStyles: falseboolean-
enabled

Render the React Editor preview within iframe. Defaults to true.

Disabling iframes will also disable viewports.

waitForStyles

Defer rendering of the React Editor preview until the iframe styles have loaded, showing a spinner. Defaults to true.

initialHistory

Sets the undo/redo React Editor history state when using the useEditor history API.

const historyState = {
  data: {
    root: {
      props: { title: "My History" },
    },
  },
};
 
export function Editor() {
  return (
    <Editor
      initialHistory={{
        histories: [{ state: historyState }],
        index: 0,
      }}
      // ...
    />
  );
}

initialHistory params

ParamExampleTypeStatus
historieshistories: []History[]Required
indexindex: 2NumberRequired
appendDataappendData: falseBoolean-
histories

An array of histories to reset the React Editor state history state to.

index

The index of the histories to set the user to.

appendData

Append the React Editor data prop onto the end of histories. Defaults to true.

When false, the React Editor data prop will be ignored but you must specify at least one item in the histories array.

onAction(action, appState, prevAppState)

Callback that triggers when React Editor dispatches an action, like insert or set. Use this to track changes, perform side effects, or sync with external systems.

Receives three arguments:

  1. action: The action that was dispatched
  2. appState: The new AppState after the action was applied
  3. prevAppState: The previous AppState before the action was applied
export function Editor() {
  return (
    <Editor
      onAction={(action, appState, prevAppState) => {
        if (action.type === "insert") {
          console.log("New component was inserted", appState);
        }
      }}
      // ...
    />
  );
}

metadata

An object containing additional data provided to each component’s render and resolveData functions.

export function Editor() {
  return (
    <Editor
      metadata={{ title: "Hello, world" }}
      config={{
        HeadingBlock: {
          render: ({ editor }) => {
            return <h1>{editor.metadata.title}</h1>; // "Hello, world"
          },
        },
      }}
      // ...
    />
  );
}

onChange(data)

Callback that triggers when the user makes a change.

Receives a single Data arg.

export function Editor() {
  return (
    <Editor
      onChange={(data) => {
        console.log("React Editor data was updated", data);
      }}
      // ...
    />
  );
}

onPublish(data)

Callback that triggers when the user hits the “Publish” button. Use this to save the React Editor data to your database.

Receives a single Data arg.

export function Editor() {
  return (
    <Editor
      onPublish={async (data) => {
        await fetch("/my-api", {
          method: "post",
          body: JSON.stringify({ data }),
        });
      }}
      // ...
    />
  );
}

overrides

An Overrides object defining custom render methods for various parts of the React Editor UI.

export function Editor() {
  return (
    <Editor
      overrides={{
        header: () => <div />,
      }}
      // ...
    />
  );
}

permissions

Set the global permissions for the React Editor instance to toggle React Editor functionality.

export function Editor() {
  return (
    <Editor
      permissions={{
        delete: false, // Prevent deletion of all components
      }}
      // ...
    />
  );
}

plugins

An array of plugins to enhance React Editor’s behaviour. See the Plugin API reference.

The blocksPlugin (Components panel) is auto-injected by the editor shell. The outlinePlugin (Outline panel) is not — pass it in the array to enable that panel. The fields panel is also auto-added unless you supply a plugin named "fields".

import { Editor, outlinePlugin } from "@reacteditor/core";
import createTailwindCdnPlugin from "@reacteditor/plugin-tailwind-cdn";
 
const tailwindCdn = createTailwindCdnPlugin();
 
const plugins = [outlinePlugin(), tailwindCdn];
 
export function Editor() {
  return (
    <Editor
      plugins={plugins}
      // ...
    />
  );
}

routes

A list of route keys to expose in the editor’s page switcher. When routes and currentRoute are provided, the editor renders a dropdown alongside the header that lets the user move between pages.

Pair with onRouteChange to control navigation. Most apps don’t set this directly — <App> wires it up automatically based on the keys in its pages map.

export function Editor() {
  return (
    <Editor
      routes={["/", "/about"]}
      currentRoute="/"
      onRouteChange={(next) => {
        // navigate your router to `next`
      }}
      // ...
    />
  );
}

currentRoute

The route key currently being edited. Used together with routes to highlight the active entry in the editor’s page switcher.

onRouteChange(path)

Callback fired when the user picks a different route from the page switcher. Receives the destination route key. Use it to navigate your router to the new page; the editor itself doesn’t perform navigation.

export function Editor() {
  return (
    <Editor
      onRouteChange={(path) => {
        router.push(path);
      }}
      // ...
    />
  );
}

ui

Set the initial application UI state. See AppState.ui.

export function Editor() {
  return (
    <Editor
      // Hide the left side bar by default
      ui={{ leftSideBarVisible: false }}
      // ...
    />
  );
}

viewports

Configure the viewports available to the user, rendered as an iframe. React Editor will select the most appropriate initial viewport based on the user’s window size, unless otherwise specified via the ui prop.

export function Editor() {
  return (
    <Editor
      viewports={[
        {
          width: 1440,
        },
      ]}
      // ...
    />
  );
}

Viewport params

ParamExampleTypeStatus
widthwidth: 1440number | "100%"Required
heightheight: 968number | "auto"-
iconicon: "Monitor""Smartphone" | "Tablet" | "Monitor" | ReactNode-
labellabel: "iPhone"string-
width

The width of the viewport.

height

An optional height for the viewport. Defaults to auto, which will fit to the window.

label

An optional label for the viewport. This is used for browser tooltip.

icon

The icon to show in the viewport switcher. Can be:

  • "Smartphone"
  • "Tablet"
  • "Monitor"
  • ReactNode

React Editor uses Lucide icons. You can use lucide-react to choose a similar icon, if desired.

Default viewports

By default, React Editor exposes small, medium and large viewports based on common viewport sizes.

[
  {
    "width": 360,
    "height": "auto",
    "icon": "Smartphone",
    "label": "Small"
  },
  {
    "width": 768,
    "height": "auto",
    "icon": "Tablet",
    "label": "Medium"
  },
  {
    "width": 1280,
    "height": "auto",
    "icon": "Monitor",
    "label": "Large"
  },
  {
    "width": "100%",
    "height": "auto",
    "icon": "FullWidth",
    "label": "Full-width"
  }
]

_experimentalFullScreenCanvas

Use a full-screen mode for the React Editor canvas, with a floating viewport switcher. This param is experimental.

export function Editor() {
  return (
    <Editor
      _experimentalFullScreenCanvas
      // ...
    />
  );
}