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
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
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.
SaveStorage.set("chapter", 3);
SaveStorage.set("flags", { metContact: true, foundKey: false });SaveStorage.remove(key)
Remove a key from this save's storage.
SaveStorage.remove("chapter");SaveStorage.clear()
Clear all of this mod's data for the current save.
SaveStorage.clear();SaveStorage.getAll()
Get all stored key-value pairs for this mod in the current save.
Returns: Record<string, any>
const all = SaveStorage.getAll();Storage vs SaveStorage
| Storage | SaveStorage | |
|---|---|---|
| Scope | Per mod, global | Per mod, per save |
| Shared across saves | Yes | No |
| Travels with a save export | No | Yes |
| Removed when a save is deleted | No | Yes |
| Survives mod uninstall/reinstall | Yes | Yes (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.
// 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);