# Create an editor {#use-editor}

Source: [Create an editor | Yurich React editor API reference · Yurich](https://leeyujoo.com/yurich/api/use-editor/)

Package: [`yurich`](https://www.npmjs.com/package/yurich)

Package version: `0.1.2`

```ts
declare function useEditor(options: EditorOptions): EditorInstance;

type EditorOptions = {
  extensions: Extension[];
  initialValue?: string;
  onChange?: (html: string) => void;
  onChangeJSON?: (json: DocumentJSON) => void;
  sanitize?: boolean;
  historyLimit?: number;
};
```

`extensions` is required. `initialValue` is the starting HTML and is read once. The default `historyLimit` is 100 undo steps. `sanitize` defaults to `true` and controls HTML from `getHTML()` and `onChange`.

`onChange` returns HTML and `onChangeJSON` returns structured data. Changes are reported at most once per animation frame. Replacing the document with `{ history: false }` can notify even if the HTML is unchanged.
