TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/pompom454/tea/llms.txt
Use this file to discover all available pages before exploring further.
Save API gives you full programmatic control over the story’s save system. Saves are organized into four storage targets: browser auto, browser slot, disk (file download/upload), and Base64 (encoded string). Each target has its own sub-object on Save, and a pair of lifecycle event registries (Save.onLoad / Save.onSave) let you pre-process save data before it is written or read.
Familiarize yourself with the relevant
Config.saves settings (e.g. maxAutoSaves, maxSlotSaves) before using this API, as they govern capacity limits.Save objects
Save data object
A full save data object is passed toonLoad / onSave handlers and is the return value of Save.base64.save(). It has the following properties:
The save’s creation date in milliseconds elapsed since epoch.
The save’s description string.
The save ID. Determined by
Config.saves.id.Optional metadata supplied when the save was created. Must be JSON-serializable. Present only if specified.
The marshaled story state. Contains the following sub-properties:
Optional version value from
Config.saves.version. Present only if specified.Save descriptor object
Descriptor objects are provided by browser-save enumeration methods (entries(), get(), newest()). They are identical to save data objects except that state is omitted — descriptors are lightweight metadata only.
Save.Type
Save.Type is a pseudo-enumeration used to identify which storage target produced or will consume a save object.
| Constant | Description |
|---|---|
Save.Type.Auto | Browser auto save |
Save.Type.Slot | Browser slot save |
Save.Type.Disk | Disk (file) save |
Save.Type.Base64 | Base64 string save |
Browser saves — general
These methods operate across both auto and slot saves.Save.browser.size
The total count of existing browser saves (auto + slot combined).
Save.browser.clear()
Deletes all existing browser saves, both auto and slot.
Save.browser.continue() → Promise
Loads the most recent browser save (auto or slot, whichever is newer).
Save.browser.isEnabled() → boolean
Returns true if any browser saves are enabled (auto, slot, or both).
Save.browser.newest() → Object | null
Returns the descriptor object for the most recent browser save, or null if no browser saves exist.
Browser saves — auto
The maximum number of auto save slots is controlled by
Config.saves.maxAutoSaves. Indices are zero-based.Save.browser.auto.size
The count of existing auto saves.
Save.browser.auto.clear()
Deletes all auto saves.
Save.browser.auto.delete(index)
Deletes the auto save at the given zero-based index.
Zero-based auto save index. Must be in the range
0–Config.saves.maxAutoSaves.Save.browser.auto.entries() → Array<Object>
Returns an array of { index, info } objects for every existing auto save, or an empty array if none exist. info is a descriptor object.
Save.browser.auto.get(index) → Object | null
Returns the descriptor object for the auto save at the given index, or null if it does not exist.
Zero-based auto save index.
Save.browser.auto.has(index) → boolean
Returns true if an auto save exists at the given index.
Zero-based auto save index.
Save.browser.auto.isEnabled() → boolean
Returns true if auto saves are enabled.
Save.browser.auto.load(index) → Promise
Loads the auto save at the given index.
Zero-based auto save index.
Save.browser.auto.save([desc [, metadata]])
Saves an auto save. If all auto save positions are full, the oldest is replaced.
Description for the save. Defaults to the active passage’s description when omitted or
null.Optional JSON-serializable data stored in the save’s
metadata property.Browser saves — slot
The maximum number of slot saves is controlled by
Config.saves.maxSlotSaves. Indices are zero-based.Save.browser.slot.size
The count of existing slot saves.
Save.browser.slot.clear()
Deletes all slot saves.
Save.browser.slot.delete(index)
Deletes the slot save at the given index.
Zero-based slot save index. Must be in the range
0–Config.saves.maxSlotSaves.Save.browser.slot.entries() → Array<Object>
Returns an array of { index, info } objects for every existing slot save.
Save.browser.slot.get(index) → Object | null
Returns the descriptor object for the slot save at the given index, or null.
Zero-based slot save index.
Save.browser.slot.has(index) → boolean
Returns true if a slot save exists at the given index.
Zero-based slot save index.
Save.browser.slot.isEnabled() → boolean
Returns true if slot saves are enabled.
Save.browser.slot.load(index) → Promise
Loads the slot save at the given index.
Zero-based slot save index.
Save.browser.slot.save(index [, desc [, metadata]])
Saves to the given slot index.
Zero-based slot save index. Must be in the range
0–Config.saves.maxSlotSaves.Description for the save. Defaults to the active passage’s description when omitted or
null.Optional JSON-serializable data stored in the save’s
metadata property.Disk saves
Disk saves write to the player’s filesystem via browser file download/upload. They are useful as portable backups that are unaffected by browser storage limits or clearing.Save.disk.export(filename)
Exports all existing browser saves as a bundle file (.savesbundle). The filename is slugified and a datestamp is appended.
Base filename for the exported bundle. Symbols are removed and a datestamp is appended — e.g.
"My Game" → my-game-20260101-120000.savesbundle.Save.disk.import(event) → Promise
Imports a saves bundle created by Save.disk.export(). Must be called from the change event handler of an <input type="file"> element.
The
change event object from an <input type="file"> element.Save.disk.load(event) → Promise
Loads a single save file created by Save.disk.save(). Must be called from the change event handler of an <input type="file"> element. Resolves with the save’s metadata.
The
change event object from an <input type="file"> element.Save.disk.save(filename [, metadata])
Saves the current story state to a .save file download.
Base filename. Slugified with a datestamp appended — e.g.
"My Game" → my-game-20260101-120000.save.Optional JSON-serializable data stored in the save’s
metadata property.Base64 saves
Base64 saves encode the story state as a plain string, which can be stored anywhere — a database, clipboard, or URL parameter.Save.base64.export() → string
Exports all existing browser saves as a Base64-encoded bundle string.
Save.base64.import(bundle) → Promise
Imports a Base64 saves bundle created by Save.base64.export().
The Base64 saves bundle string.
Save.base64.load(save) → Promise
Loads a single Base64 save string created by Save.base64.save(). Resolves with the save’s metadata.
The Base64 save string.
Save.base64.save([metadata]) → string
Saves the current story state as a Base64-encoded string.
Optional JSON-serializable data stored in the save’s
metadata property.Save event handlers
Save.onLoad and Save.onSave let you intercept saves before they are read or written — useful for migrating old save formats, stripping sensitive data, or tagging saves.
Save.onLoad
Save.onLoad.size
Save.onLoad.size
The count of currently registered on-load handlers.
Save.onLoad.add(handler)
Save.onLoad.add(handler)
Registers a function to be called before a save is loaded. The handler receives the full save data object. Throwing inside the handler displays the error to the player and aborts loading.
A function that receives the save data object as its sole argument.
Save.onLoad.clear()
Save.onLoad.clear()
Removes all registered on-load handlers.
Save.onLoad.delete(handler)
Save.onLoad.delete(handler)
Removes the specified on-load handler. Returns
true if the handler was registered, false otherwise.The handler function reference to remove.
Save.onSave
Save.onSave.size
Save.onSave.size
The count of currently registered on-save handlers.
Save.onSave.add(handler)
Save.onSave.add(handler)
Registers a function to be called before a save is written. The handler receives the full save data object and may modify it in place.
A function that receives the save data object as its sole argument.
Save.onSave.clear()
Save.onSave.clear()
Removes all registered on-save handlers.
Save.onSave.delete(handler)
Save.onSave.delete(handler)
Removes the specified on-save handler. Returns
true if the handler was registered, false otherwise.The handler function reference to remove.