valtio
Valtio is a proxy-based state management library for React that makes state management as simple as mutating a JavaScript object. Valtio uses JavaScript Proxy t…
Installation
npm install valtio
yarn add valtio
pnpm add valtio
Import
import { proxy, useSnapshot } from 'valtio';Quick Example
import { proxy, useSnapshot } from 'valtio';
const state = proxy({ count: 0, text: 'hello' });
function Counter() {
const snap = useSnapshot(state);
return (
<button onClick={() => { state.count++; }}>
{snap.count}
</button>
);
}About valtio
Valtio is a proxy-based state management library for React that makes state management as simple as mutating a JavaScript object. Valtio uses JavaScript Proxy to track which properties are accessed during rendering and automatically re-renders components when those specific properties change. State is created with proxy({ count: 0, text: 'hello' }), and components read state reactively using the useSnapshot() hook: const snap = useSnapshot(state). Mutations are applied directly to the proxy object: state.count++ — no action creators, reducers, or immutable update patterns needed. Valtio detects which properties each component reads and only triggers re-renders when those exact properties change, providing optimal performance without manual memoization. The library supports nested objects and arrays, computed properties through derive(), subscriptions for side effects, and devtools integration for debugging. Valtio works with TypeScript and provides proxyWithComputed for derived state, proxyWithHistory for undo/redo, and proxyMap/proxySet for reactive Map and Set collections. Valtio is created by Daishi Kato (who also created Zustand and Jotai) and is designed for developers who prefer the simplicity of mutable state updates with automatic change detection over explicit immutable update patterns.
Quick Facts
| Package | valtio |
| Category | State Management |
| Weekly Downloads | 500K+ |
| License | MIT |
| Install | npm install valtio |
Related Packages
Zustand is a small, fast, and scalable state management library for React that provides a simple hoo…
Jotai is a primitive and flexible state management library for React that takes an atomic approach i…
MobX is a battle-tested state management library that makes state management simple and scalable thr…
Redux is a predictable state container for JavaScript applications, most commonly used with React bu…
React is the most popular JavaScript library for building user interfaces, developed and maintained …
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.