https://github.com/embbnux/use-global-storage
React hook to connect storage and state
https://github.com/embbnux/use-global-storage
Last synced: 3 months ago
JSON representation
React hook to connect storage and state
- Host: GitHub
- URL: https://github.com/embbnux/use-global-storage
- Owner: embbnux
- Created: 2019-04-22T08:40:48.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T04:52:57.000Z (over 2 years ago)
- Last Synced: 2025-02-07T07:22:34.654Z (5 months ago)
- Language: TypeScript
- Homepage: https://embbnux.github.io/use-global-storage-demo/
- Size: 578 KB
- Stars: 12
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# use-global-storage
[](https://www.npmjs.com/package/use-global-storage)
React Hook to connect storage and state. You can use this as a global state manager in React.
## Install
via npm:
```
npm install use-global-storage
```via yarn:
```
yarn add use-global-storage
```## Usage
```js
import useGlobalStorage from 'use-global-storage';const useStorage = useGlobalStorage({
storageOptions: { name: 'test-db' }
});const Counter = () => {
const [state, setState] = useStorage('counter');
return (
Counter:
{state || 0}
setState(state + 1)}>
+1 to global
);
};
```