pmndrs/valtio

🧙 Valtio makes proxy-state simple for React and Vanilla

View on GitHub ↗Jump to charts ↓Open shareable report

Summary Information

Updated 47 minutes ago
Added to GitGenius on January 9th, 2022
Created on November 16th, 2020
Open Issues & Pull Requests: 6 (+0)
Number of forks: 291
Total Stargazers: 10,226 (+0)
Total Subscribers: 35 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 6.3 hours
Mean response time: 445.5 days
90th percentile: 1162.1 days
Tracked items: 14

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 4
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 639 days
Stale 30+ days: 3
Stale 90+ days: 1

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

  • help wanted (11)
  • needs repro (5)
  • enhancement (4)
  • good first issue (3)
  • documentation (2)
  • on hold (1)
  • wontfix (1)

Most active issues this week

No issue events were indexed in the last 7 days.

Detailed Description

Valtio is a state management library that simplifies proxy-based state handling for both React and vanilla JavaScript applications. The library is maintained by the pmndrs organization and is written in TypeScript, with its primary purpose being to make mutable state management intuitive and performant through JavaScript proxies.

The core concept of Valtio is straightforward: it wraps a JavaScript object into a self-aware proxy that can be mutated directly like a normal object, without requiring immutable update patterns or complex state management boilerplate. Developers can make changes to the state from anywhere in their application using standard JavaScript mutation syntax. For React integration, Valtio provides the useSnapshot hook, which creates a local snapshot of the state that tracks changes and triggers re-renders only when the specific parts of state accessed in the render function have changed. This approach provides render optimization by detecting property access through an internal proxy mechanism based on proxy-compare technology.

Beyond React, Valtio supports vanilla JavaScript usage, allowing developers to subscribe to state changes from anywhere in their application, including outside of components. The library includes utilities like subscribeKey for subscribing to primitive values and watch for convenient state observation.

The library offers several advanced features for different use cases. The ref utility allows developers to hold objects in state without proxy tracking, useful for large nested objects with accessors. Valtio supports transient updates for frequently occurring state changes without triggering re-renders, and developers can control whether mutations are batched or synchronous depending on their needs. The library integrates with Redux DevTools Extension for debugging and state manipulation in plain objects and arrays.

Valtio includes specialized utilities like proxySet and proxyMap that mimic native Set and Map behavior while maintaining proxy reactivity. The useProxy utility provides a convenient abstraction for beginners by returning both shallow proxy state and its snapshot together. Computed properties can be defined using object getters for advanced use cases, though the library notes that this requires careful handling of the this context.

Valtio v2 requires React 18 and up and works with various renderers including react-dom, react-native, and react-three-fiber. The library is framework-agnostic and functions in Node.js, Next.js, and other environments. The ecosystem includes eslint-plugin-valtio for linting support and community-contributed recipes covering state organization, persistence, context integration, and state composition patterns.