# preact-localstorage

> Easy use localstorage in Preact

Latest version **1.0.2** (published 2020-01-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install preact-localstorage
pnpm add preact-localstorage
yarn add preact-localstorage
bun add preact-localstorage
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-01-31 |
| First published | 2019-12-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Faisal Manzer |
| Maintainers | faisal_manzer |
| Keywords | preact, localstorage, react, local storage |

## Links

- npm: https://www.npmjs.com/package/preact-localstorage
- Repository: https://github.com/Faisal-Manzer/preact-localstorage
- Homepage: https://github.com/Faisal-Manzer/preact-localstorage.git
- Issues: https://github.com/Faisal-Manzer/preact-localstorage.git/issues
- npm.io page: https://npm.io/package/preact-localstorage

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-01-31
- 1.0.1 — 2020-01-30
- 0.0.2 — 2019-12-27
- 0.0.1 — 2019-12-27

## README

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

## Installation

```bash
npm install preact-localstorage
```
or
```bash
yarn add preact-localstorage
```

## Examples

```javascript
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

---
_Source: https://npm.io/package/preact-localstorage · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
