1.0.2 • Published 4 years ago

preact-localstorage v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

reactLocalStorage

Easy use localstorage in Preact. It also supports SSR (Prerender).

Installation

npm install preact-localstorage

or

yarn add preact-localstorage

Examples

import preactLocalStorage from 'preact-localstorage';

preactLocalStorage.set('var', true);
preactLocalStorage.get('var', true);
preactLocalStorage.setObject('var', {'test': 'test'});
preactLocalStorage.getObject('var');
preactLocalStorage.remove('var');
preactLocalStorage.clear();

API Guide

Default VALUE is required while getting values (because SSR doesn't have real localStorage)

  • preactLocalStorage.set(key, value)
  • preactLocalStorage.get(key, deafultValue, silent=true)
  • preactLocalStorage.setObject(key, object)
  • preactLocalStorage.getObject(key, defaultValue, silent=true)
  • preactLocalStorage.remove(key)
  • preactLocalStorage.clear()

silent:

  • true: Will not throw exception instead will return defaultValue
  • false: Will throw exception

License

MIT

1.0.2

4 years ago

1.0.1

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago