Socket
Book a DemoInstallSign in
Socket

preact-localstorage

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

preact-localstorage

Easy use localstorage in Preact

1.0.2
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

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

Keywords

preact

FAQs

Package last updated on 31 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.