CodeVetter · Repo Unpack · Feature catalog
pmndrs/valtio
The library exposes mutable proxy state, snapshots, subscriptions, and React hooks as its primary developer-facing features. Utilities add reactive collections, cloning, normalization, effects, and debugging. Examples demonstrate complete interactions, while the website provides documentation navigation and theme controls. History and derived-state documentation also introduce external packages, whose implementations are outside this inspection.
- proxy() accepts an object or defaults to {}, reuses a cached proxy for the same base object, and wraps eligible assigned children; snapshot() and getVersion() expose current derived state and version information.
- subscribe() returns an unsubscribe function and supports batched or synchronous delivery; subscribeKey() adds Object.is filtering for a particular property, and unstable_enableOp() enables set/delete mutation records.
- useSnapshot() returns a property-tracked Snapshot<T> with an optional sync flag; useProxy() provides render-time snapshot reads and post-layout live reads, with an explicit React Compiler compatibility caveat.
- proxyMap() implements reactive lookup, mutation, iteration, size, and snapshot mutation guards; proxySet() adds reactive Set operations and union/intersection/difference predicates, while proxyMap's getOrInsert methods explicitly throw.
- ref() excludes an identity from tracking; deepClone() recursively copies ordinary containers while retaining configured references, and unstable_deepProxy() additionally converts native or proxy Maps/Sets into reactive collections.
- watch() runs an effect immediately, tracks proxies passed to get(), and manages cleanup/subscriptions, but is deprecated; devtools() connects to Redux DevTools for state inspection, ACTION updates, time travel, commit, and imported history.
- Examples expose counter increment/decrement and independent ticks, array-backed todo add/toggle/delete/filter, and Map-backed todo editing, bulk completion, three filters, and active counts; the history editor exposes undo/redo through valtio-history.
- The photo booth captures camera frames, accepts/rejects candidates, selects/deletes saved images, and persists images through localforage; the website exposes MDX docs, a mobile navigation dialog, and localStorage/system-driven dark mode.