# @awesome-cordova-library/localstorage

> Library to use localstorage easily

Latest version **1.0.4** (published 2023-09-12) · SEE LICENSE IN LICENSE license · 0 weekly downloads

## Install

```sh
npm install @awesome-cordova-library/localstorage
pnpm add @awesome-cordova-library/localstorage
yarn add @awesome-cordova-library/localstorage
bun add @awesome-cordova-library/localstorage
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2023-09-12 |
| First published | 2022-05-31 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Jordan AZOULAY |
| Maintainers | joazco |
| Keywords | cordova, capacitor, ionic, javascript, mobile, localstorage |

## Links

- npm: https://www.npmjs.com/package/@awesome-cordova-library/localstorage
- Repository: https://github.com/joazco/awesome-cordova-library
- Issues: https://github.com/joazco/awesome-cordova-library/issues
- npm.io page: https://npm.io/package/@awesome-cordova-library/localstorage

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2023-09-12
- 1.0.3 — 2022-05-31
- 1.0.2 — 2022-05-31
- 1.0.1 — 2022-05-31
- 1.0.0 — 2022-05-31

## README

---
id: plugin-localstorage
title: Localstorage
tags:
  - javascript
  - typescript
  - localstorage
sidebar_position: 2
---

# Localstorage

Library to use localstorage easily

[Online documentation](https://awesomecordovalibrary.com)

[Mozilla documentation](https://developer.mozilla.org/fr/docs/Web/API/Window/localStorage)

## Installation

```sh
npm install @awesome-cordova-library/localstorage
```

## Vanilla

### Declartion

```typescript
class LocalStorage {
  static setItem<T = any>(key: string, value: T): void;
  static getItem<T = any>(key: string): T | null;
  static removeItem(key: string): void;
  static clear(): void;
}
```

### Usages

```typescript
import LocalStorage from "@awesome-cordova-library/localstorage";

LocalStorage.setItem<string[]>("item", value);
LocalStorage.getItem<string[]>("item");
LocalStorage.removeItem("item");
LocalStorage.clear();
```

## React

### Declaration

```typescript
const useLocalStorage: () => {
  setItem: <T = any>(key: string, value: T) => void;
  getItem: <T_1 = any>(key: string) => T_1 | null;
  removeItem: (key: string) => void;
  clear: () => void;
};
```

### Usages

```typescript
import { useEffect } from "react";
import useLocalStorage from "@awesome-cordova-library/localstorage/lib/react";

function App() {
  const { setItem, getItem, removeItem, clear } = useLocalStorage();

  useEffect(() => {
    setItem<string[]>("item", value);
    getItem<string[]>("item");
    removeItem("item");
    clear();
  }, []);

  return <div />;
}
```

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