Fabric.js Document Engine

Search documentation

Find a page or section

中文

Fabric.js Document Engine

Everything your canvas editor needs around the canvas

Fabric.js draws and edits objects. This engine adds the rest of a real canvas editor: Fabric.js save and load, undo redo, autosave, export and recovery. Your canvas, toolbar and UI stay yours.

Explore the features

Live examples

See every feature running

Each example is a real Fabric.js canvas running the package from npm. Try it here, then copy its code from the guide into your own editor.

Browse the guides

Developer docs

Clear guides, live examples and a full API reference, from your first Fabric.js save and load to a production editor.

Documentation
import { useDocumentEngine, useDocumentState } from "fabricjs-document-engine/react";
import { createLocalStorage } from "fabricjs-document-engine/storage";
 
const storage = createLocalStorage();
 
export function Editor() {
  const { elementRef, canvas } = useFabricCanvas(800, 500);
  const engine = useDocumentEngine(canvas, { storage, autosave: true });
  const state = useDocumentState(engine);
 
  return (
    <>
      <button disabled={!state?.canUndo} onClick={() => engine?.undo()}>
        Undo {state?.undoLabel}
      </button>
      <canvas ref={elementRef} />
    </>
  );
}