# Local Storage Value

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

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

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

{% endtab %}

{% tab title="npm" %}

```bash
npm install --save @corets/local-storage-value
```

{% endtab %}
{% endtabs %}

Seamless React integration is shipped in a separate package:

{% content-ref url="../hooks/use-value" %}
[use-value](https://docs.corets.io/hooks/use-value)
{% endcontent-ref %}

This is a `localStorage` version of this package:

{% content-ref url="value" %}
[value](https://docs.corets.io/observables/value)
{% endcontent-ref %}

## Quick Start

Example of how to use this package in React:

```typescript
import React from "react"
import { createLocalStorageValue } from "@corets/local-storage-value"
import { useValue } from "@corets/use-value"

const Example = () => {
  const counter = useValue(() => createLocalStorageValue("storageKey", 1))
  const increment = () => counter.set(counter.get() + 1)
  
  return (
    <div>
      <button onClick={increment}>{counter.get()}</button>
    </div>
  )
}
```

## createLocalStorageValue() <a href="#createlocalstoragevalue" id="createlocalstoragevalue"></a>

Create a new observable value:

```typescript
import { createLocalStorageValue } from "@corets/local-storage-value"

const value = createLocalStorageValue("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-value.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.
