Fabric.js Document Engine

Search documentation

Find a page or section

中文

An honest look at the other options, and when each one is enough.

People usually look for a Fabric.js undo redo library first, then find out they also need saving, ids and conflict checks. Below, the common options side by side. Versions were checked on npm in September 2026.

At a glance

Hand-written toJSONfabric-history 2.0fabricjs-react 2.2This package
Fabric.js versionsany55 and 66 and 7
Undo and redowrite it yourselfyesnoyes
How undo is stored—whole canvas JSON per step—only the changed objects
Stable object idsnononoyes
Save and load with storagewrite it yourselfnonoyes
Autosave and conflict checksnononoyes
Custom properties keptlist them on each calllist them on the canvas—register once
Crash recoverynononoyes
React hooks——yesyes, optional

Hand-written toJSON and loadFromJSON

Fabric.js can already turn the canvas into JSON and back. For a demo, that is all you need. The work starts when the editor goes to real users: stable ids, images that fail to load, loads that race each other, saves that arrive out of order, and undo. The why a document engine page lists each of these problems.

fabric-history

fabric-history is a small Fabric.js undo redo library. You import it once and it adds canvas.undo() and canvas.redo() to every canvas by patching Canvas.prototype. Each step stores the whole canvas as a JSON string, which is simple but gets slow and heavy with large drawings. Version 2.0 depends on Fabric.js 5, and it does not save, load or assign ids.

Choose it if you only need undo on a small Fabric.js 5 canvas.

fabricjs-react

fabricjs-react gives React a canvas component and a hook to reach the Fabric.js editor. It helps you mount the canvas in React. It does not save documents or record history, so you can use it together with this package.

This package

This package is the choice when people save work in your editor. Undo stores only what changed, so a step stays fast with thousands of objects. Saving is one-at-a-time with revision checks, and unsaved work survives a crash. It needs Fabric.js 6 or 7.

If you only want undo and never save anything, a smaller Fabric.js undo redo library may be enough. If you save, compare the production checklist with what you would have to build yourself.

Next steps

Fabric.js undo redo library | Fabric.js Document Engine