use-localstorage-hook

A custom React hook that lets you sync with localStorage and helps you manipulate objects via built-in JSON.stringify helpers.

Usage no npm install needed!

<script type="module">
  import useLocalstorageHook from 'https://cdn.skypack.dev/use-localstorage-hook';
</script>

README

NPM

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.

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.

License

MIT © filipdanic