Use when the user wants to persist React state to localStorage, read stored values on mount, or clear a stored key. Covers controlled get/set/remove with JSON serialization and error handling.
How this skill is triggered — by the user, by Claude, or both
Slash command
/f-rha-use-local-storage:use-local-storageThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Persist React state to `localStorage`. Reads the stored value on mount and keeps state in sync on every update.
Persist React state to localStorage. Reads the stored value on mount and keeps state in sync on every update.
const [value, setValue, removeValue] = useLocalStorage(key, initialValue);
| Parameter | Type | Description |
|---|---|---|
key | string | localStorage key |
initialValue | any | Fallback value when key doesn't exist yet |
| Index | Name | Type | Description |
|---|---|---|---|
| 0 | value | any | Current stored value |
| 1 | setValue | (value | fn) => void | Update state and localStorage |
| 2 | removeValue | () => void | Remove key and reset to initialValue |
import { useLocalStorage } from "f-rha";
// Basic
const [theme, setTheme] = useLocalStorage("theme", "light");
<button onClick={() => setTheme("dark")}>Dark mode</button>
// Functional update (same as useState)
const [count, setCount] = useLocalStorage("count", 0);
<button onClick={() => setCount((c) => c + 1)}>+1</button>
// Remove
const [, , clearTheme] = useLocalStorage("theme", "light");
<button onClick={clearTheme}>Reset</button>
npx claudepluginhub dio-chu/f-rha-marketplace --plugin f-rha-use-local-storagePersists Zustand store to localStorage or custom storage with automatic rehydration and migration support for state survival across page reloads.
Creates and manages Zustand stores with selectors, persistence, devtools, and middleware. Useful for global state in React or vanilla JavaScript.
Zustand v5 state management for React. Use when implementing global state, stores, persist, or client-side state.