{"repo":"astoilkov/use-local-storage-state","free":true,"listed":false,"github":"https://github.com/astoilkov/use-local-storage-state","clone":"git clone https://github.com/astoilkov/use-local-storage-state.git","description":"React hook that persists data in localStorage","language":"TypeScript","stars":1232,"topics":["hook","localstorage","persistent","react","usestate"],"license":"MIT","category":"ui-components","readme_excerpt":"use-local-storage-state React hook that persist data in localStorage Install React 18 and above: React 17 and below. For docs, go to the react-17 branch. Why - Actively maintained for the past 6 years — see contributors page. - Production ready. - 677 B (brotlied). - SSR support. - Works with React 18 concurrent rendering and React 19. - Handles the Window storage event and updates changes across browser tabs, windows, and iframe's. Disable with storageSync: false . - In-memory fallback when localStorage throws an error and can't store the data. Provides a isPersistent API to let you notify the user their data isn't currently being stored. - Aiming for high-quality with my open-source principles. Usage Todo list example Notify the user when localStorage isn't saving the data using the isPersistent property There are a few cases when localStorage isn't available. The isPersistent property tells you if the data is persisted in localStorage or in-memory. Useful when you want to notify the user that their data won't be persisted. Removing the data from localStorage and resetting to the default The removeItem() method will reset the value to its default and will remove the key from the localStorage . It returns to the same state as when the hook was initially created. Why my component renders twice? If you are hydrating your component (for example, if you are using Next.js), your component might re-render twice. This is behavior specific to React and not to this library. It's caus","default_branch":null,"files":null,"tree":[],"storefront":"/r/astoilkov","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/astoilkov/use-local-storage-state/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}