# Local Storage List

Source code is hosted on [GitHub](https://github.com/corets/local-storage-list)

{% tabs %}
{% tab title="yarn" %}

```bash
yarn add @corets/local-storage-list
```

{% endtab %}

{% tab title="npm" %}

```
npm install --save @corets/local-storage-list
```

{% endtab %}
{% endtabs %}

Seamless React integration is shipped in a separate package:

{% content-ref url="/pages/-MeeGIckpb\_jmyQLy7TY" %}
[useList](/hooks/use-list.md)
{% endcontent-ref %}

This is a `localStorage` version of this package:

{% content-ref url="/pages/-MeeBIuqvkAwUjx0ORFs" %}
[List](/observables/list.md)
{% endcontent-ref %}

## Quick Start <a href="#react" id="react"></a>

Example of how to use this package in React:

```typescript
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() <a href="#createlocalstoragelist" id="createlocalstoragelist"></a>

Create a new observable list:

```typescript
import { createLocalStorageList } from "@corets/local-storage-list"

const list = createLocalStorageList("storageKey", ["some", "data"])
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.corets.io/observables/local-storage-list.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
