use-loc-storage
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Minified size   Version   Typescript   License  

Easy to use React.js useLocalStorage hook for updating and subscribing to localStorage keys

Value for the given key will be in sync across different hook calls, components and tabs. Thats all.

Q1Qnv1xaUj

import useLocalStorage from "use-loc-storage";

// Signature
type useLocalStorageFn = (key: string, initialValue?: string) => [string | null, (newValue: string) => void, () => void];

const [
  value,  // value of the given key
  setValue, // set the value
  clear // remove the key from localStorage
] = useLocalStorage('key','optional initial value');

Package Sidebar

Install

npm i use-loc-storage

Weekly Downloads

1

Version

1.0.4

License

MIT

Unpacked Size

11.6 kB

Total Files

9

Last publish

Collaborators

  • dogan_hekimoglu