Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/shop3/react-cpls
- Owner: shop3
- License: mit
- Created: 2022-05-17T11:04:03.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-02T23:19:09.000Z (almost 2 years ago)
- Last Synced: 2023-03-07T05:17:36.416Z (almost 2 years ago)
- Topics: localstorage, react
- Language: TypeScript
- Size: 1.51 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
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 installnpm run husky:install
```## Development
```bash
npm run develop
```