For the complete documentation index, see llms.txt. This page is also available as Markdown.

Local Storage List

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

Source code is hosted on GitHub

yarn add @corets/local-storage-list

Seamless React integration is shipped in a separate package:

useList

This is a localStorage version of this package:

List

Quick Start

Example of how to use this package in React:

import React from "react"
import { createLocalStorageList } from "@corets/local-storage-list"
import { useList } from "@corets/use-list"

const Example = () => {
  const list = useList(() => createLocalStorageList("storageKey", ["apple", "banana"]))
  const addFruit = () => list.add("pineapple")
  return (
    <div>
      Fruits: {list.get().join(",")}
      <button onClick={addFruit}>Add fruit</button>
    </div>
  )
}

createLocalStorageList()

Create a new observable list:

Last updated

Was this helpful?