Skip to main content
The snapshots namespace handles reader mode content — retrieving snapshots, requesting new ones, and managing version history.

snapshots.getSaveSnapshot

Returns the active snapshot for a save, optionally including the full content.
saveId
Id<'saves'>
required
The save ID.
includeContent
boolean
Whether to include the full HTML/text content. Defaults to false (returns metadata only).
snapshot
SaveSnapshot | null
The active snapshot, or null if no snapshot exists.
const snapshot = useQuery(api.snapshots.getSaveSnapshot, {
  saveId: saveId,
  includeContent: true,
});

if (snapshot?.status === "ready") {
  // Render snapshot.html in reader mode
}

snapshots.requestSaveSnapshot

Manually requests a new snapshot (re-snapshot) for a save.
saveId
Id<'saves'>
required
The save ID to re-snapshot.
const requestSnapshot = useMutation(api.snapshots.requestSaveSnapshot);
await requestSnapshot({ saveId: saveId });
Rate limited to 50 requests per user per 24 hours. Automatic snapshots triggered during save creation do not count toward this limit.

snapshots.getSnapshotHistory

Returns all snapshot versions for a save, ordered by version number.
saveId
Id<'saves'>
required
The save ID.
versions
SaveSnapshot[]
Array of all snapshot versions for the save, from newest to oldest.
const history = useQuery(api.snapshots.getSnapshotHistory, {
  saveId: saveId,
});
// history: [{ version: 3, isActive: true, ... }, { version: 2, ... }, { version: 1, ... }]

snapshots.setActiveVersion

Restores a previous snapshot version as the active (displayed) version.
snapshotId
Id<'saveSnapshots'>
required
The snapshot version ID to activate.
const setActive = useMutation(api.snapshots.setActiveVersion);
await setActive({ snapshotId: olderVersionId });
This doesn’t delete other versions — it just changes which version is displayed in reader mode. You can switch between versions at any time.

Content deduplication

Snapshots use content-addressable storage for efficiency:
  • Content is hashed with SHA-256
  • Identical content across saves or versions is stored once
  • Reference counting ensures cleanup when content is no longer needed
  • If a re-snapshot produces the same content, the duplicate version is automatically discarded
This keeps storage efficient even with many saves from the same domain.

Processing flow