# react-esc-storage

> Easy to use Client and Server Storage

Latest version **4.0.0-beta.27** (published 2018-04-20) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install react-esc-storage
pnpm add react-esc-storage
yarn add react-esc-storage
bun add react-esc-storage
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 4.0.0-beta.27 |
| Published | 2018-04-20 |
| First published | 2017-03-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 39.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Tycho Bokdam |
| Maintainers | tripss |
| Keywords | cookies, koa, local storage, react, server side rendering, session storage |

## Links

- npm: https://www.npmjs.com/package/react-esc-storage
- Repository: https://github.com/TriPSs/react-esc
- Homepage: https://github.com/TriPSs/react-esc/tree/master/packages/react-esc-storage
- Issues: https://github.com/TriPss/react-esc/issues
- npm.io page: https://npm.io/package/react-esc-storage

## 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

- 4.0.0-beta.27 (latest) — 2018-04-20
- 4.0.0-beta.26 — 2018-04-12
- 4.0.0-beta.25 — 2018-04-11
- 4.0.0-beta.24 — 2018-04-11
- 4.0.0-beta.23 — 2018-04-11
- 4.0.0-beta.22 — 2018-04-10
- 4.0.0-beta.21 — 2018-04-10
- 4.0.0-beta.20 — 2018-04-10
- 4.0.0-beta.19 — 2018-04-10
- 4.0.0-beta.18 — 2018-04-09
- 4.0.0-beta.17 — 2018-04-09
- 4.0.0-beta.13 — 2018-04-09
- 1.2.0 — 2017-11-08
- 1.1.0 — 2017-04-03
- 1.0.1 — 2017-03-27
- … 2 more at https://npm.io/package/react-esc-storage/versions

## README

# React-ESC-Storage 
![https://img.shields.io/npm/v/react-esc-storage.svg](https://img.shields.io/npm/v/react-esc-storage.svg?style=flat-square) [![npm downloads](https://img.shields.io/npm/dt/react-esc-storage.svg?maxAge=2592000&style=flat-square)](https://npm-stat.com/charts.html?package=react-esc-storage) [![](https://img.shields.io/github/issues-raw/tripss/react-esc-storage.svg?style=flat-square)](https://github.com/tripss/react-esc-storage/issues) [![](https://img.shields.io/david/tripss/react-esc-storage.svg?style=flat-square)](https://david-dm.org/tripss/react-esc-storage#info=dependencies)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/tripss/react-esc-storage.svg)](http://isitmaintained.com/project/tripss/react-esc-storage "Average time to resolve an issue") [![Percentage of issues still open](http://isitmaintained.com/badge/open/tripss/react-esc-storage.svg)](http://isitmaintained.com/project/tripss/react-esc-storage "Percentage of issues still open")

> Storage tool for React applications

React ESC Storage let's you **get and set cookies, local and session storage** in a easy to use way for client and and server

For example, setting a cookie, session or local storage.
```js
import Storage from 'react-esc-storage'

// Setting
Storage.set(Storage.COOKIE, 'token', { cookie: 'cookie content' })
Storage.set(Storage.SESSION, 'token', 'SESSION')
Storage.set(Storage.LOCAL, 'token', { local: true })

// Getting
Storage.get(Storage.COOKIE, 'token')
Storage.get(Storage.LOCAL, 'token')
Storage.get(Storage.SESSION, 'token')

// Check if exists
Storage.has(Storage.COOKIE, 'token')
Storage.has(Storage.LOCAL, 'token')
Storage.has(Storage.SESSION, 'token')

// Remove
Storage.remove(Storage.COOKIE, 'token')
Storage.remove(Storage.LOCAL, 'token')
Storage.remove(Storage.SESSION, 'token')

```
Objects will be automatically stringified when setting and parsed back when getting. 
- - -

Making the **Cookie Storage** available on the server. [Click here for an example](https://github.com/TriPSs/react-esc/blob/master/src/client/server.js#L38)
```js
import CookieStorage from 'react-esc-storage/CookieStorage'

match({ history, routes, location: ctx.req.url }, async(err, redirect, props) => {
         
  // Add Cookie to global so we can use it in the Storage module
  global.cookie = new CookieStorage(ctx.cookies)

})
```

Making the **Storage** available on the client. [Click here for an example](https://github.com/TriPSs/react-esc/blob/master/src/client/index.js#L56)
```js
import Storage from 'react-esc-storage'

match({ history, routes }, (error, redirectLocation, renderProps) => {
  
  // Checks if the Cookie storage is available, if not it will create it
  Storage.check()
  
})
```

### Installation
```shell
$ npm install --save react-esc-storage
```

## Development

If you'd like to contribute to this project, all you need to do is clone
this project and run:

```shell
$ npm install
```

You can use `npm link` to use your development version in your own project:
- Go to `react-esc-strorage` directory and execute command `npm link`
- Go to your project directory and execute command `npm link react-esc-storage`


## [License](https://github.com/tripss/react-esc/blob/master/LICENSE)

React ESC is [MIT licensed](./LICENSE).

## Collaboration

If you have questions or [issues](https://github.com/TriPSs/react-esc/issues), please [open an issue](https://github.com/TriPSs/react-esc/issues/new?title=[Storage])!

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