https://github.com/shop3/react-cpls
React cross page local storage
https://github.com/shop3/react-cpls
localstorage react
Last synced: 8 months 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 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-02T23:19:09.000Z (over 2 years ago)
- Last Synced: 2025-02-08T14:12:46.093Z (9 months ago)
- Topics: localstorage, react
- Language: TypeScript
- Size: 1.51 MB
- Stars: 0
- Watchers: 1
- 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

# Development
## Installation
```bash
npm install
npm run husky:install
```
## Development
```bash
npm run develop
```