⚡
Vue Reactivity API
Built on @vue/reactivity - use ref(), reactive(), computed() in React with automatic UI updates
Bring Vue's reactivity system to React with zustand-like simplicity
import { createState } from 'reactivity-store';
const useCount = createState(
() => ({ count: 0 }),
{ withActions: (s) => ({ add: () => s.count++ })
});Reactive count component:
RStore adapts to your background:
import React from "react";
import { createStore, ref } from "reactivity-store";
// Use Vue APIs: ref, reactive, computed
const useCounter = createStore(() => {
const count = ref(0);
const increment = () => count.value++;
return { count, increment };
});
function App() {
const { count, increment } = useCounter();
return <button onClick={increment}>Count: {count}</button>;
}import React from "react";
import { createState } from "reactivity-store";
// Use actions - no Vue APIs needed
const useCounter = createState(
() => ({ count: 0 }),
{
withActions: (state) => ({
increment: () => state.count++
})
}
);
function App() {
const { count, increment } = useCounter();
return <button onClick={increment}>Count: {count}</button>;
}| Vue Approach | React Approach | |
|---|---|---|
| Best for | Vue developers | React developers |
| APIs | ref, reactive, computed | Plain objects + actions |
| Features | Auto-computed, lifecycle hooks | Middleware: persist, DevTools |
| Learn more | createStore | createState |