🚀 BlockNote AI is here! Access the early preview.
BlockNote Docs/React/Overview

Overview

BlockNote provides a powerful React integration that makes it easy to add rich text editing capabilities to your applications. The React bindings offer a declarative API that integrates seamlessly with React's component model and state management patterns.

Key Components

The React integration centers around two main pieces:

  • useCreateBlockNote - A React hook that creates and manages editor instances
  • BlockNoteView - A component that renders the editor with a complete UI

Quick Start

Here's a minimal example of how to integrate BlockNote into a React component:

import React from "react";
import { useCreateBlockNote } from "@blocknote/react";
import { BlockNoteView } from "@blocknote/mantine";
// Or, you can use ariakit, shadcn, etc.

function MyEditor() {
  const editor = useCreateBlockNote();

  return <BlockNoteView editor={editor} />;
}

This gives you a fully functional editor with:

  • Text editing and formatting
  • Block types (paragraphs, headings, lists, etc.)
  • Toolbar for formatting options
  • Side menu for block operations

BlockNoteView

The <BlockNoteView> component is used to render the editor. It also provides a number of props for editor specific events.

Props

PropTypeDefault
editor
BlockNoteEditor
-
theme?
"light" | "dark"
-
editable?
boolean
true
onSelectionChange?
(() => void)
-
onChange?
(editor: BlockNoteEditor) => void
-
renderEditor?
boolean
true
children?
ReactNode
-
ref?
Ref<HTMLDivElement>
-
formattingToolbar?
boolean
-
linkToolbar?
boolean
-
slashMenu?
boolean
-
sideMenu?
boolean
-
filePanel?
boolean
-
tableHandles?
boolean
-
emojiPicker?
boolean
-
comments?
boolean
-

Hooks

useCreateBlockNote

The useCreateBlockNote hook is used to create a new BlockNoteEditor instance.

declare function (
  ?: ,
  ?: React.,
): ;

useEditorChange

The useEditorChange hook is used to listen for changes to the editor.

declare function (
  : (
    : ,
    : {
      /**
       * Returns the blocks that were inserted, updated, or deleted by the change that occurred.
       */
      (): ;
    },
  ) => void,
  ?: ,
): ;

useEditorSelectionChange

The useEditorSelectionChange hook is used to listen for changes to the editor selection.

declare function (
  /**
   * Callback that runs when the editor's selection changes.
   */
  : () => void,
  ?: ,
): ;

Next Steps

Now that you have a basic editor working, you can explore:

The editor is now ready to use! Start typing and explore the various block types and formatting options available in the toolbar.