Skip to content

Save and load

Attach storage before using save operations:

const storage = new FilesystemAdapter({ dir: "./saves" });
engine.useStorage(storage);

await engine.persist("my-game", "after turn 5");
const loaded = await engine.resume("my-game");
if (!loaded) console.log("No save found");

persist(name, description?) serializes the current Chronicle and calls the adapter. resume(name) returns true when a record is found and loaded and false when it is absent. listSaves() returns SaveMetadata[], sorted by timestamp descending; deleteSave(name) deletes a record.

Auto-save can be enabled with engine.enableAutoSave(intervalMs, name) and stopped with disableAutoSave(). Auto-save failures are reported through the Engine's debug path; choose an interval and backup policy that tolerate a crash between writes. Saves are full document snapshots, so size can grow as the CRDT grows.