52
localStorage wrapper functions
localStorage allows saving client-side configuration. Several functions are provided to safely execute
localStorage functions, as they might fail is some cases like private mode on iOS. It also allows storing
any values that can be serialized using JSON.stringify.
• storeSet(key, value) sets key/value pair
• storeGet(key) retrieves key value, returns null when key is not found
• storeRemove(key) removes key from storage
Storage keys must be prefixed with unique application name to minimize collisions between different
applications
Examples
Get currently selected theme (light/dark)
var theme = storeGet('theme') || 'light';
Store JavaScript objects
var user = { name: 'John', surname: 'Doe', age: 42 };
storeSet('myapp_user', user);