@bytesoftio/helpers-local-storage
Installation
yarn add @bytesoftio/helpers-local-storage
or npm install @bytesoftio/helpers-local-storage
Table of contents
Description
This package provides several localStorage
related helper functions.
readLocalStorage
Reads a value from localStorage
.
import { readLocalStorage } from "@bytesoftio/helpers-local-storage"
type AuthData = { token: string | undefined }
const defaultData: AuthData = {token: undefined}
const data = readLocalStorage<AuthData>("auth", defaultData)
writeLocalStorage
Writes a value to localStorage
.
import { writeLocalStorage } from "@bytesoftio/helpers-local-storage"
const data = { token: "foo" }
writeLocalStorage("auth", data)