Skip to content

SaveStorage

The SaveStorage namespace provides per-save persistent key-value storage scoped to the current mod.

Unlike Storage — which is global and shared by every save file — data written with SaveStorage belongs to the currently loaded save. It is stored inside that save's own data, so it:

  • never leaks between different saves (each save starts empty),
  • travels with the save (export / backup / cloud),
  • is deleted automatically when the player deletes the save.

Use this for per-playthrough mod progress. Use Storage for data that should be the same for the player regardless of which save is loaded.

No permission required.

Import

typescript
import { SaveStorage } from "@hotbunny/hackhub-content-sdk";

Methods

SaveStorage.get<T>(key)

Get a value by key for the current save. Returns undefined if not found.

Returns: T | undefined

typescript
const chapter = SaveStorage.get<number>("chapter");

SaveStorage.set(key, value)

Set a value by key for the current save. The value must be JSON-serializable.

typescript
SaveStorage.set("chapter", 3);
SaveStorage.set("flags", { metContact: true, foundKey: false });

SaveStorage.remove(key)

Remove a key from this save's storage.

typescript
SaveStorage.remove("chapter");

SaveStorage.clear()

Clear all of this mod's data for the current save.

typescript
SaveStorage.clear();

SaveStorage.getAll()

Get all stored key-value pairs for this mod in the current save.

Returns: Record<string, any>

typescript
const all = SaveStorage.getAll();

Storage vs SaveStorage

StorageSaveStorage
ScopePer mod, globalPer mod, per save
Shared across savesYesNo
Travels with a save exportNoYes
Removed when a save is deletedNoYes
Survives mod uninstall/reinstallYesYes (within the same save)

Why this exists

A common pattern is to track your mod's own progress and restore it when the mod is reinstalled. Doing that with global Storage causes progress to "bleed" into brand-new games, because global storage is shared by all saves. SaveStorage keeps that state attached to the specific playthrough, so reinstalling your mod restores progress only in the save it came from.

typescript
// On load: restore this save's progress (empty in a fresh game)
const completed = SaveStorage.get<string[]>("completedQuests") ?? [];

// Later, when the player finishes one of your quests:
completed.push(questId);
SaveStorage.set("completedQuests", completed);

HotBunny Interactive Entertainment Inc.