Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-localstorage-hook

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

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]

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.1K
decreased by-13.32%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 20 Sep 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc