https://github.com/filipdanic/use-localstorage-hook
A custom React hook that lets you sync with localStorage and helps you manipulate objects via built-in JSON.stringify helpers.
https://github.com/filipdanic/use-localstorage-hook
localstorage localstorage-api react react-hooks
Last synced: about 2 months ago
JSON representation
A custom React hook that lets you sync with localStorage and helps you manipulate objects via built-in JSON.stringify helpers.
- Host: GitHub
- URL: https://github.com/filipdanic/use-localstorage-hook
- Owner: filipdanic
- License: mit
- Created: 2019-06-18T09:22:03.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-23T01:42:53.000Z (about 2 years ago)
- Last Synced: 2025-02-18T03:15:40.587Z (over 1 year ago)
- Topics: localstorage, localstorage-api, react, react-hooks
- Language: JavaScript
- Homepage: https://filipdanic.github.io/use-localstorage-hook/
- Size: 723 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.npmjs.com/package/use-localstorage-hook)
# use-localstorage-hook
A custom React hook that lets you sync with `localStorage` and helps you manipulate objects via built-in `JSON.stringify` helpers.
[👉 Demo site and docs.](https://filipdanic.github.io/use-localstorage-hook/)
## Quick Start
Start with:
```
npm install --save use-localstorage-hook
```
And in your component use the hook like this:
```
[ val, setVal ] = useLocalStorage(
'demo',
{ a: 'Hello!' }
);
console.log(val.a)
// => "Hello!"
```
## Docs
The complete documentation as well as a live demo [is available here.](https://filipdanic.github.io/use-localstorage-hook/)
## License
MIT © [filipdanic](https://github.com/filipdanic)