# React Installation

> Add the Editor42 WYSIWYG HTML editor to a React app with @editor42/editor42-react, a drop-in replacement for @tinymce/tinymce-react. No API key.

Source: https://editor42.com/docs/install/react  
Section: Installation > Integrations > React  
Every page of editor42.com has a Markdown copy at its URL + `.md` (`index.md` after a URL that ends in `/`); all of them are in one file: https://editor42.com/llms-full.txt

`@editor42/editor42-react` is a thin wrapper around Editor42 that makes it a React component. There is no account, no sign-up and no key of any kind.

## Install

```sh
npm install @editor42/editor42-react
```

or for Yarn users:

```sh
yarn add @editor42/editor42-react
```

React 16.7 and newer are supported, up to React 19.

## Basic Setup

```jsx
import { Editor } from '@editor42/editor42-react';

export default function App() {
  return (
    <Editor
      initialValue="<p>Hello from Editor42</p>"
      init={{ height: 400 }}
    />
  );
}
```

With no extra props the editor script is loaded from `https://cdn.editor42.com` on the `latest` channel. That pointer only ever moves for security and bug-fix releases, because the Editor42 major version is fixed forever.

## Reading and Writing the Content

Pass `value` and `onEditorChange` to control the editor from your own state:

```jsx
import { useState } from 'react';
import { Editor } from '@editor42/editor42-react';

export default function App() {
  const [content, setContent] = useState('<p>Hello from Editor42</p>');

  return (
    <Editor
      value={content}
      onEditorChange={(newContent) => setContent(newContent)}
      init={{ height: 400, plugins: 'lists link', toolbar: 'bold italic | bullist link' }}
    />
  );
}
```

Use `initialValue` instead when you only need a starting point and will read the content later.

## Self-Hosting

Point the component at your own copy of the script, using the full file URL:

```jsx
<Editor editor42ScriptSrc="/js/editor42/editor42.min.js" />
```

An array is accepted for loading the editor plus separate bundles, and array items may set `integrity` and `crossOrigin` for CSP-hardened deployments. Passing an empty array opts out of script loading entirely, for pages that load the editor themselves.

## Pinning a Version

```jsx
<Editor channel="42.0.1" />
```

`channel` accepts `latest`, a `latest-N` alias, or an exact version.

## Editor Options

Everything else is an Editor42 option, passed through `init`:

```jsx
<Editor init={{ height: 400, menubar: false, plugins: 'lists link' }} />
```

See the [Configuration Options](https://editor42.com/api/configuration) for the full list.

## Migrating from @tinymce/tinymce-react

```sh
npm uninstall @tinymce/tinymce-react
npm install @editor42/editor42-react
```

Change the import to `@editor42/editor42-react` and you are done. Prop, event and component names are unchanged, and the old `tinymceScriptSrc` and `cloudChannel` props keep working as deprecated aliases of `editor42ScriptSrc` and `channel`.

All API-key and licence-key handling has been removed. The corresponding props are still accepted so existing code compiles, but they do nothing: no key is read, stored or sent anywhere, and no request ever reaches a vendor cloud.

The component also drives a stock TinyMCE if that is what is already loaded on the page, which keeps the switch reversible.

See the [migration guide](https://editor42.com/docs/migration/from-tinymce) for the editor side of the move.

## Live Demo

See it running, with its full source: the [React demo](https://editor42.com/examples/react).

## Links

- NPM: [`@editor42/editor42-react`](https://www.npmjs.com/package/@editor42/editor42-react)
- GitHub: [editor42com/editor42-react](https://github.com/editor42com/editor42-react)
