

Custom hook that uses the [`localStorage API`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) to persist state across page reloads.

## Usage [#usage]

```tsx
import { useLocalStorage } from "@tilt-legal/cubitt-components/utilities/hooks";

const [count, setCount, removeCount] = useLocalStorage('count', 0);
// Access the `count` value, the `setCount` function to update it and `removeCount` function to remove the key from storage.
```

## API [#api]

### Signature [#signature]

```ts
declare function useLocalStorage<T>(key: string, initialValue: T | (() => T), options?: UseLocalStorageOptions<T>): [T, Dispatch<SetStateAction<T>>, () => void];
```

### Parameters [#parameters]

| Parameter      | Type                              | Description                                                                           | Default                                                                      |   |
| -------------- | --------------------------------- | ------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | - |
| `key`          | `string`                          | The key under which the value will be stored in local storage.                        | -                                                                            |   |
| `initialValue` | \`T                               | (() => T)\`                                                                           | The initial value of the state or a function that returns the initial value. | - |
| `[options]`    | `UseLocalStorageOptions&lt;T&gt;` | Options for customizing the behavior of serialization and deserialization (optional). | -                                                                            |   |

### Return Value [#return-value]

| Value    | Type                                                          | Description                                                                                                     |
| -------- | ------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| `return` | `[T, Dispatch&lt;SetStateAction&lt;T&gt;&gt;, () =&gt; void]` | A tuple containing the stored value, a function to set the value and a function to remove the key from storage. |
