Socket
Socket
Sign inDemoInstall

react-localstorage-hook

Package Overview
Dependencies
5
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-localstorage-hook

[![npm package][npm-badge]][npm] ![npm-bundle-size] ![Module formats][module-formats] ![npm-download-count]


Version published
Weekly downloads
556
increased by46.32%
Maintainers
1
Install size
6.52 kB
Created
Weekly downloads
 

Readme

Source

React useLocalStorage

npm package npm-bundle-size Module formats npm-download-count

  • It is an custom hook for browser localstorage management.
  • For the same localstorage key It is consistent across the component (synchronize values between components).
  • serializer (JSON.stringify)
  • deserializer (JSON.parse)

Demo

https://codesandbox.io/s/react-localstorage-hook-yfj5f

Installation

Add react-localstorage-hook dependency

yarn add react-localstorage-hook
npm install react-localstorage-hook --save

Usage

import useLocalStorage from 'react-localstorage-hook'
const [values, setValue] = useLocalStorage(key, initialValue)

Options

NameTypeDefaultRequiredDescription
keyStringnulltrueThe key that will be used when calling localStorage.setItem(key)and localStorage.getItem(key)
initialValueany''falseThe initial value of the data.

License

This project is licensed under the MIT License - see the LICENCE.md file for details

Keywords

FAQs

Last updated on 20 Sep 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc