Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/shop3/react-cpls

React cross page local storage
https://github.com/shop3/react-cpls

localstorage react

Last synced: 10 days ago
JSON representation

React cross page local storage

Awesome Lists containing this project

README

        

# React Cross Page Local Storage

React provider to simplify localStorage usage, when the storage is updated the new value is reflected across the whole application and on other opened pages.

## Installation

```bash
npm install --save @shop3/react-cpls
```

## Usage

```js
import React, { useEffect } from 'react';
import { StorageProvider, useStorage } from '@shop3/react-cpls';

const App = () => {
return (

{/* app here */}

)
}

const Example = () => {
const storage = useStorage();

useEffect(() => {
storage.setItem('test', 'test value');
}, [storage]);

return (

{storage.getItem('test')}


)
}
```

## Example

![Screen recording demostration](https://github.com/shop3/react-cpls/blob/main/assets/react-cpls-screen-recording.gif)

# Development

## Installation

```bash
npm install

npm run husky:install
```

## Development

```bash
npm run develop
```