Founding price: $35, then $99 after 23:59 UTC on 4 November, then $99
Get ProKeep the last N values a variable has held, newest last, for sparklines, recent searches, change logs and trend arrows.
Derived from this item’s props table, because it declares no controls of its own. This item has no standalone playground, so changes update the code, the share link and the AI prompt.
Use it to show how a live value moved: a sparkline of the last 30 readings, the last five searches, a log of changes.
Do not use it for Undo and Redo (use useUndoState) or to compare only with the last render (use usePrevious).
import { useValueHistory } from "@/hooks/use-value-history"const history = useValueHistory(temperature, { size: 30 })useValueHistory<T>(value: T, options?): readonly T[]
| Option | Type | Default | Description |
|---|---|---|---|
size | number | 10 | Most values kept. |
The array includes the current value as its last item. A render with the same value as the latest records nothing, and the array is a new one only when a value is recorded.
A hook has no markup. If you chart the history, give the chart a text alternative, such as the latest value and the range.
The hook ships with renderHook tests (use-value-history.test.ts) covering its behaviour, cleanup on unmount and server-safe defaults. It is safe to render on the server.