Skip to content

Filesystem adapter

FilesystemAdapter writes one JSON file per save under its configured directory. The default directory is ./saves; use { dir: "..." } to choose another location. The JSON record contains metadata and the base64 Automerge document.

import { FilesystemAdapter } from "./core/storage/FilesystemAdapter.js";

engine.useStorage(new FilesystemAdapter({ dir: "./saves" }));
await engine.persist("server-game", "checkpoint");

The adapter creates the directory as needed. list() ignores non-JSON files and tolerates an individual corrupted file while listing others. Filesystem storage is not a backup system: use filesystem permissions, snapshots, and an off-host backup policy appropriate to the deployment.