interface StorageAPI {
    SetString(key: string, value: string): void;
    GetString(key: string): string;
    SetObject(key: string, value: unknown): void;
    GetObject<T = unknown>(key: string): T;
}

Methods

  • Persists a string value under the given key. Data is scoped to the current script. Values are stored locally for fast access and synced to the server in the background.

    Parameters

    • key: string

      Storage key.

    • value: string

      String value to store.

    Returns void

    Storage.SetString("count", "42");
    Storage.SetString("lastRun", new Date().toISOString());
  • Retrieves a previously stored string value.

    Parameters

    • key: string

      Storage key.

    Returns string

    The stored string, or null if the key does not exist.

    ALWAYS check for null — the return value is null when the key has never been set.

    const count = Storage.GetString("count");
    if (count !== null) {
    Console.Log("count: " + count);
    }
  • Persists a JSON-serializable object under the given key.

    Parameters

    • key: string

      Storage key.

    • value: unknown

      Any JSON-serializable value (object, array, number, etc.).

    Returns void

    Storage.SetObject("prefs", { delay: 100, enabled: true });
    
  • Retrieves a previously stored object.

    Type Parameters

    • T = unknown

    Parameters

    • key: string

      Storage key.

    Returns T

    The deserialized object, or null if the key does not exist.

    ALWAYS check for null — the return value is null when the key has never been set. The returned value is a plain deserialized JS object; prototype methods are not preserved.

    const prefs = Storage.GetObject<{ delay: number; enabled: boolean }>("prefs");
    if (prefs !== null) {
    Console.Log("delay: " + prefs.delay);
    }