Proxy-based state for React and vanilla JavaScript
open sourceMITfree
Valtio is a state management library that turns a plain object into a proxy you can mutate from anywhere, the way you'd change a normal JavaScript object. In React, useSnapshot gives a component a read-only snapshot and re-renders it only when the parts of the state it reads change. It also works without React through valtio/vanilla, and comes from Poimandres, the makers of Jotai.
Problems it solves
- share mutable state between React components without reducers
- re-render only the components that use the part of state that changed
- manage app state the same way inside and outside React
Features
- mutate state directly with ordinary assignments
- useSnapshot re-renders a component only when the state it reads changes
- subscribe to changes from outside React
- Suspense support for promises in state
- Redux DevTools integration through valtio/utils
- proxySet and proxyMap helpers and computed properties
Limitations
- Valtio v2 needs React 18 or later.1
Alternatives
The same job
These do what Valtio does.
