Skip to content

RStoreVue-inspired Reactive State Management for React

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:

Two Approaches, One Library

RStore adapts to your background:

tsx
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
>;
}
tsx
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
>;
}

Choose Your Path

Vue ApproachReact Approach
Best forVue developersReact developers
APIsref, reactive, computedPlain objects + actions
FeaturesAuto-computed, lifecycle hooksMiddleware: persist, DevTools
Learn morecreateStorecreateState

npm downloadsnpm versionGitHub stars

Released under the MIT License.