← Back to Documentation Index

💾 Storage API

LocalStorage wrapper for saving and loading game data

📋 Overview

The Storage API provides easy save/load functionality using browser LocalStorage for persisting game state, high scores, and settings.

💾 Storage Functions

save(key, value)

Saves data to LocalStorage.

key string - Storage key name
value any - Data to save (auto-serialized to JSON)
Returns: void - No return value
Example:
save("highScore", 1000);
load(key, defaultValue)

Loads data from LocalStorage.

key string - Storage key name
defaultValue any - Value if key doesn't exist
Returns: any - Loaded data or default value
Example:
const score = load("highScore", 0);