Skip to main content
The History extension (also known as UndoRedo) provides undo and redo functionality for your editor. It tracks changes and allows users to step backward and forward through their edit history.
If you’re using the @tiptap/extension-collaboration package, do not use this extension. The Collaboration extension includes its own history implementation that’s designed to work in collaborative environments.

Installation

The History extension is included in the @tiptap/extensions package and is also part of the StarterKit.

Basic Usage

Included in StarterKit

The History extension is included by default when using StarterKit:

Standalone Usage

Custom Configuration

Configuration Options

number
The amount of history events that are collected before the oldest events are discarded. This prevents the history from growing indefinitely.Default: 100
number
The delay in milliseconds between changes after which a new history group should be started. Changes that occur within this delay are grouped together as a single undo/redo step.Default: 500

Commands

command
Undo recent changes.Keyboard shortcuts: Cmd/Ctrl + Z, Cmd/Ctrl + я (Russian layout)
command
Reapply reverted changes.Keyboard shortcuts:
  • Cmd/Ctrl + Shift + Z
  • Cmd/Ctrl + Y
  • Cmd/Ctrl + Shift + я (Russian layout)

Keyboard Shortcuts

Advanced Examples

Custom Undo/Redo Buttons

React Component with Undo/Redo

Shorter History Depth for Memory Efficiency

Faster Grouping for Rapid Edits

Disable History in StarterKit

If you want to use the Collaboration extension instead:

Check if Undo/Redo is Available

Vue Component Example

How History Works

The History extension groups changes based on time. When you type continuously, all changes within the newGroupDelay window are grouped together as a single undo step. This creates a natural editing experience:
  • Typing continuously: All text entered within 500ms is one undo step
  • Pausing then typing: Creates a new undo step
  • Each formatting change: Usually a separate undo step
  • Large operations: Typically a single undo step

Source Code

View the source code on GitHub: