Skip to main content

Overview

The useEditor hook is the primary way to create and manage a Tiptap editor instance in React applications. It handles the editor lifecycle, including creation, updates, and cleanup.

Type Signature

Parameters

UseEditorOptions
required
Configuration options for the editor instance. Extends Partial<EditorOptions> from @tiptap/core.
DependencyList
default:"[]"
Optional React dependency array. When dependencies change, the editor instance will be destroyed and recreated.

Return Value

Returns an Editor instance or null. The return value can be null when:
  • The editor has not been initialized yet
  • immediatelyRender is set to false and the editor hasn’t mounted
  • Server-side rendering is detected

Usage Examples

Basic Usage

With Event Handlers

With Dependencies

Server-Side Rendering

Controlled Editor

Important Notes

When using server-side rendering (SSR) with frameworks like Next.js, you must set immediatelyRender: false to avoid hydration mismatches. In development mode, Tiptap will throw an error if SSR is detected without this option.
The shouldRerenderOnTransaction option is legacy behavior. For better performance, leave it as false (default) and use the useEditorState hook for reactive state updates instead.
Use the deps array sparingly. Only include dependencies when you actually need to recreate the editor instance. For most use cases, updating editor options or content through commands is more efficient.