local-preferences

2.1.2 • Public • Published

Methods

localPreferences.set(key, value)

Sets value in localStorage. set key to null to clear the entry.

import {set} from "local-preferences"

set("isLoggedIn", true)
set("userId", 123)
set("email", "foo@bar.baz")
set("object", {
  foo: {
    bar: "baz"
  }
})

localPreferences.get(key, [fallback])

Retrieves value from localStorage.

import {get} from "local-preferences"

get("isLoggedIn") // => true
get("userId")  // => 123
get("email")  // => "foo@bar.baz"
get("object")  // => {foo: {bar: "baz"}}

get("unset", "foo")  // => "foo"

localPreferences.clear()

Passthrough to the native localStorage.clear()

Readme

Keywords

Package Sidebar

Install

npm i local-preferences

Weekly Downloads

1

Version

2.1.2

License

MIT

Last publish

Collaborators

  • teffenellis