session.storage to save and retrieve data that persists across sessions. When a user closes your app and opens it again later, their stored data is still there.
Basic Usage
JSON.stringify and JSON.parse:
Methods
get
Retrieve a value by key. Returnsnull if the key doesn’t exist.
set
Store a value. Overwrites any existing value for that key.delete
Remove a key and its value.getAll
Retrieve all stored key-value pairs.clear
Remove all stored data for this app and user.keys
Get all stored keys. ReturnsPromise<string[]>.
has
Check if a key exists. ReturnsPromise<boolean>.
setMultiple
Batch set multiple key-value pairs. Takes aRecord<string, any>.
flush
Force-flush any pending writes to the server.Common Patterns
User preferences
Session state that survives restarts
Counters
Storage Limits
Storage is per-app, per-user. Each user of your app has their own isolated storage. Data stored for one user is not visible to other users. Storage is backed by the cloud - it’s not local to the glasses or phone. This means it works across devices if the user switches phones.Migrating from v2
session.storage instead of session.simpleStorage. See the Migration Guide for the full list of changes.
