---
title: "Undo/Redo extension"
description: "Undo and redo changes in your Tiptap Editor with ease, allowing you to revert or reapply edits in your editor. More in the docs."
canonical_url: "https://tiptap.dev/docs/editor/extensions/functionality/undo-redo"
---

# Undo/Redo extension

Undo and redo changes in your Tiptap Editor with ease, allowing you to revert or reapply edits in your editor. More in the docs.

This extension provides undo and redo support. All changes to the document will be tracked and can be removed with `undo`. Undone changes can be applied with `redo` again.

You should only integrate this extension if you don't plan to make your editor collaborative. The Collaboration extension has its own undo/redo support because people generally don't want to revert changes made by others.

> **Interactive demo:** [UndoRedo](https://embed.tiptap.dev/preview/Extensions/UndoRedo)

## Install

```bash
npm install @tiptap/extensions
```

## Usage

```js
import { Editor } from '@tiptap/core'
import { UndoRedo } from '@tiptap/extensions'

new Editor({
  extensions: [UndoRedo],
})
```

## Settings

### depth

The amount of history events that are collected before the oldest events are discarded.

Default: `100`

```js
UndoRedo.configure({
  depth: 10,
})
```

### newGroupDelay

The delay between changes after which a new group should be started (in milliseconds). When changes aren’t adjacent, a new group is always started.

Default: `500`

```js
UndoRedo.configure({
  newGroupDelay: 1000,
})
```

## Commands

### undo()

Undo the last change.

```js
editor.commands.undo()
```

### redo()

Redo the last change.

```js
editor.commands.redo()
```

## Keyboard shortcuts

| Command | Windows/Linux                                             | macOS                                         |
| ------- | --------------------------------------------------------- | --------------------------------------------- |
| undo()  | Control + Z or Control + я                                | Cmd + Z + or Cmd + я                          |
| redo()  | Shift + Control + Z or Control + Y or Shift + Control + я | Shift + Cmd + Z or Cmd + Y or Shift + Cmd + я |

## Source code

[packages/extensions/src/undo-redo/](https://github.com/ueberdosis/tiptap/blob/main/packages/extensions/src/undo-redo/)

## Minimal Install

```js
import { Editor } from '@tiptap/core'
import { UndoRedo } from '@tiptap/extensions/undo-redo'

new Editor({
  extensions: [UndoRedo],
})
```
