@gphone/sdk
    Preparing search index...

    Function usePersisted

    • A writable store that survives a reload.

      useStorage is imperative — getItem/setItem — so every preference, draft and high score was the same hand-written pair: read once at init, write on every change. The shell had already written it by hand for volumeStep, sanitizer and all, which is the signal that it belongs in the SDK rather than in each app.

      Reads are namespaced per app by useStorage, so two apps may use the same key.

      const highScore = usePersisted('snake', 'highScore', 0);
      $highScore = Math.max($highScore, score);

      Type Parameters

      • T

      Parameters

      Returns Writable<T>