Editor API

Note: This API is not intended for use in site development or when coding in Blocks.

The Editor API enables code running within a Wix editor (for example in a settings panel) to interact with other parts of the editor. Using the API, you can access the properties of a widget on the editor canvas, retrieve data about the editor environment, and more.

Setup

To use the Editor API, install the @wix/editor package using npm or Yarn:

Copy
npm install @wix/editor

or

Copy
yarn add @wix/editor

Wix-hosted apps

To use the Editor API in Wix-hosted apps, import one of the editor submodules in your code and call it's methods directly. For example:

Copy
import { widget } from "@wix/editor"; async function getWidgetProp(propName) { const response = await widget.getProp(propName); }

Self-hosted apps

To use the Editor API in self-hosted apps, first create a Wix Client using one of the editor submodules. For example:

Copy
import { editor } from "@wix/editor"; import { createClient } from "@wix/sdk"; const client = createClient({ host: editor.host(), auth: editor.auth(), modules: { widget, }, });

Then, use the client to call the submodule's methods. For example:

Copy
async function getWidgetProp(propName) { const response = await client.widget.getProp(propName); }
Did this help?