# @sjblurton/use-storage

> useStorage hook stores the data in local, or session storage. It takes a key as a string argument, and a default value as a string. The hook will search the storage the key in storage for a value and return if it there is one, otherwise it will use the de

Latest version **0.1.3** (published 2022-04-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sjblurton/use-storage
pnpm add @sjblurton/use-storage
yarn add @sjblurton/use-storage
bun add @sjblurton/use-storage
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2022-04-16 |
| First published | 2022-04-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 13.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Simon Blurton |
| Maintainers | sjblurton |
| Keywords | react, hooks, custom, typescript, test, testing |

## Links

- npm: https://www.npmjs.com/package/@sjblurton/use-storage
- Repository: https://github.com/sjblurton/use-storage
- npm.io page: https://npm.io/package/@sjblurton/use-storage

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 0.1.3 (latest) — 2022-04-16
- 0.1.2 — 2022-04-16
- 0.1.1 — 2022-04-16
- 0.1.0 — 2022-04-15

## README

# useStorage

useStorage hook stores the data in local, or session storage. It takes a key as a string argument, and a default value as a string. The hook will search the storage the key in storage for a value and return if it there is one, otherwise it will use the default value.

If you want to store an object then use JON.stringify, and JON.parse to send a string to the hook.

return a tuple of [ string, setState function, and a remove function ].

### **To install...**

```bash
mpn i @sjblurton/use-storage

yarn add @sjblurton/use-storage
```

### **To import...**

```bash
import { useLocalStorage, useSessionStorage } from "../hooks/use-storage"
```

### **To call the hook...**

```bash
const [name, setName, removeName] = useSessionStorage("name", "foo")

const [age, setAge, removeAge] = useLocalStorage("age", "40")
```

### **Links**

GitHub: https://github.com/sjblurton/use-storage
<br/>
NPM: https://www.npmjs.com/package/@sjblurton/use-storage

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