Function: useSaveGame()
useSaveGame(): (
slot,options?) =>Promise<SaveResult>
Defined in: packages/core/src/saves/hooks/useSaveGame.ts:28
React hook that provides a function to save the current game state to a specific slot. The save is stored in IndexedDB with the slot number as its slot key.
Returns
Function that accepts a slot number and optional annotations, and saves the game
(
slot,options?):Promise<SaveResult>
Parameters
slot
string | number
options?
Returns
Promise<SaveResult>
Example
const saveGame = useSaveGame();
const handleSave = async () => {
const result = await saveGame(1, {
title: 'Before the boss',
meta: { day: 3, place: 'flat' },
});
if (!result.success) {
console.error('Save failed:', result.error);
}
};