Local Storage Helpers

Various helpers related to localStorage specific functionality.

Source code is hosted on GitHub

yarn add @corets/local-storage-helpers

readLocalStorage()

Reads a value from the localStorage:

import { readLocalStorage } from "@corets/local-storage-helpers"

type AuthData = { token?: string }

const defaultData: AuthData = { token: undefined }

const data = readLocalStorage<AuthData>("auth", defaultData)

writeLocalStorage()

Writes a value to the localStorage:

import { writeLocalStorage } from "@corets/local-storage-helpers"

const data = { token: "foo" }

writeLocalStorage("auth", data)

Last updated