Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

use-localstorage-react

marcusthelin15MITdeprecated1.0.4

This package is no longer being maintained. This hook will be included in the the @24/react-hooks package.

A custom hook to save state to localstorage!

react hook, hooks, use localstorage, localstorage hook, localstorage react

readme

use-localstorage-react

A custom hook to save state to localstorage!

Demo

Sandbox Demo

Usage

Import it

import useLocalStorage from 'use-localstorage-react'

Set key and initial value

const [count, setCount] = useLocalStorage(0, 'counter')

Reload to see that the value stays the same.