Skip to content

EmilEinarsen/useStorage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is this?

A React hook used for managing state and Storage simultaneously.

Install

Use npm to install bjork_useStorage or copy the code manually form github.

> npm i bjork_useStorage

Usage

useStorage takes three params:

  1. type ('local' | 'session' | 'cookie'): Storage type.
  2. key (string)
  3. initalValue (@default '').

The returned "set" takes two parameters, key and value. If the chosen type is cookie, then the returned "set" also takes an optional third parameter that configures how the cookie is formatted, for more information check out the dependency cookie-helper.

import useStorage from 'bjork_usestorage'

const [ state, setState ] = useStorage(type, key, initalvalue?)

Contribution

Pull requests are welcome. For any considerable changes, please open an issue first to discuss what you would like to change.

Licence

MIT

About

A react hook for managing state and storage

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published