---
title: "useEditor"
sidebarTitle: "useEditor"
description: "Hook for creating and managing an editor instance."
icon: "code"
hidden: true
---
## Import
```tsx
import { useEditor } from '@react-email/editor/core';
```
## Parameters
Initial editor content. Accepts TipTap JSON or an HTML string.
Ignored when collaboration extensions are detected (the collab provider manages content).
Additional extensions to load. `StarterKit` is always included automatically,
so you only need to pass extra extensions (e.g., `EmailTheming`, custom nodes).
Called on every content change. The `transaction` object provides metadata about the change.
Custom paste handler. Return `true` to prevent default paste behavior.
Called when an image is pasted or dropped. Use this to upload the image and insert
the resulting URL.
Called once when the editor has finished initializing.
Toggle read-only mode. When `false`, the editor content cannot be modified.
Any additional [TipTap `UseEditorOptions`](https://tiptap.dev/docs/editor/api/editor#settings)
are also accepted and forwarded to the underlying TipTap editor.
## Return value
The TipTap editor instance. `null` until the editor is mounted.
Whether the document is visually empty (only contains an empty paragraph).
Excludes `globalContent` nodes from the calculation.
The effective extensions array, including `StarterKit` and `UndoRedo` (unless collaborative).
Content validation error, if the provided content is invalid for the current schema.
When set, the editor is automatically made read-only.
Whether collaboration extensions (Liveblocks, Y.js) were detected in the extensions array.
## Collaboration support
When collaboration extensions are detected (`liveblocksExtension` or `collaboration`), the
hook automatically:
- Ignores the `content` parameter (content is managed by the collab provider)
- Excludes the `UndoRedo` extension (collab extensions handle their own history)
## Example
Use `useEditor` directly when you need more control than `EditorProvider` offers:
```tsx
import { useEditor } from '@react-email/editor/core';
export function MyEditor() {
const { editor, isEditorEmpty, contentError } = useEditor({
content: { type: 'doc', content: [] },
onUpdate: (editor) => {
console.log('Content changed:', editor.getJSON());
},
onReady: (editor) => {
console.log('Editor ready');
},
});
if (contentError) {
return
Error: {contentError.message}
;
}
if (!editor) {
return Loading...
;
}
return (
el && editor.setOptions({ element: el })} />
{isEditorEmpty &&
Start typing...
}
);
}
```
For most use cases, `EditorProvider` from `@tiptap/react` is simpler.
Use `useEditor` when you need direct access to the editor instance before rendering,
or when integrating with complex state management.