Version history
Version history lets users browse earlier versions of a document and restore them, like in Google Docs or Figma. Each version is a snapshot of a room, capturing both its Storage and Yjs documents at a point in time. Versions are separate from multiplayer undo/redo, which tracks each user’s individual changes—a version instead records a meaningful milestone that anyone can return to later.
This page is an overview for Storage, for a step-by-step setup guide, and to learn more about Yjs version history, read how to add version history to your app.
Creating versions
Versions can be created automatically at intervals,
enabled in your project’s dashboard,
or manually from your back end with
Liveblocks.createVersionHistorySnapshot.
Manual snapshots are useful at meaningful moments, for example:
- When a user publishes, submits, or saves a document.
- Before an AI agent makes a substantial change, so users can recover the previous state.
- Before importing or migrating external data.
Listing versions
On the client,
useHistoryVersions
returns the current room’s versions, newest first. Render them with the
ready-made
HistoryVersionSummary
and
HistoryVersionSummaryList
components, which display each version’s authors and date.
These UI components are optional, but are a helpful starting point.
Previewing a version
useHistoryVersionStorageData
returns the Storage data for a version, reconstructed as a read-only
LiveObject. Use it to
render a preview before the user decides to restore.
Because an old version may not match your current Storage type, the data is
typed as the more permissive LsonObject.
Restoring a version
useRestoreToStorageVersion
returns a function that restores the room’s Storage to a given version.
The restoration is applied as a single change and synchronized to everyone in the room. Because it’s added to the user’s undo history like any other edit, restoring is safe—a user who changes their mind can simply undo it.
Deleting versions
To allow users to remove a version, use
useDeleteHistoryVersion.
Unlike restoring, deletion is permanent and can’t be undone, so it’s best to ask
for confirmation first.
Server-side access
Versions can also be listed from your back end with
Liveblocks.getVersionHistory,
which supports pagination, for example to build custom tooling or scheduled
exports.