LogoLogo
  • Home
  • Services
    • Fiber
    • Accessor
    • Schema
    • Form
    • Translator
  • Components
    • <Router/>
    • <Memo />
  • Observables
    • Async
    • Value
    • Store
    • List
    • Local Storage Value
    • Local Storage Store
    • Local Storage List
  • Hooks
    • useAsync
    • useAffect
    • useStream
    • useAction
    • useDebounce
    • useThrottle
    • usePrevious
    • useIdle
    • useValue
    • useList
    • useStore
    • useForm
    • useFormBinder
    • useTranslator
    • useQuery
  • Helpers
    • Tag
    • Input Helpers
    • Promise Helpers
    • Save Helpers
    • Pagination Helpers
    • Clipboard Helpers
    • Calendar Helpers
    • Local Storage Helpers
Powered by GitBook
On this page
  • Quick Start
  • createLocalStorageStore()

Was this helpful?

  1. Observables

Local Storage Store

Simple observable store that can be subscribed to, in React, using Hooks. State is automatically synced to the localStorage.

PreviousLocal Storage ValueNextLocal Storage List

Last updated 3 years ago

Was this helpful?

Source code is hosted on

yarn add @corets/local-storage-store
npm install --save @corets/local-storage-store

Seamless React integration is shipped in a separate package:

This is a localStorage version of this package:

Quick Start

Example of how to use this package in React:

import React from "react"
import { createLocalStorageStore } from "@corets/local-storage-store"
import { useStore } from "@corets/use-store"

const Example = () => {
  const counterStore = useStore(() => createLocalStorageStore("storageKey", { counter: 0 }))
  const increment = () => counterStore.set({ counter: counterStore.get().counter + 1 })
  return (
    <div>
      <button onClick={increment}>{counterStore.get().counter}</button>
    </div>
  )
}

createLocalStorageStore()

Create a new observable store:

import { createLocalStorageStore } from "@corets/local-storage-store"

const store = createLocalStorageStore("storageKey", { some: "data" })
GitHub
useStore
Store