
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-smart-state
Advanced tools
Next-generation local and global state management for React
react-smart-state simplifies React state handling with a minimal, powerful API for both local and global state.
Unlike Redux, Zustand, Recoil, or Jotai, this library removes boilerplate, offers smarter proxying, and supports hot reloading — no need to refresh after each change in development mode.
npm install react-smart-state
buildState() APIUse buildState() to create and configure a local or global state instance.
| Method | Description |
|---|---|
ignore(...keys) | Ignores deeply nested objects to prevent performance overhead (e.g., recursive or large structures). |
bind(...paths) | Globally binds a property inside an ignored object to allow reactivity. |
localBind(...path) | Same as bind, but only applies to the local component. |
onInit(fn: (state) => Promise<void>) | Called once asynchronously when the state is initialized. |
| `timeout(ms: number | undefined)` |
build() | Builds a local (component-scoped) state. |
globalBuild() | Builds a global shared state instance. |
After building a state, you can use these instance methods:
| Method / Prop | Description |
|---|---|
bind(path) | Globally binds ignored sub-properties to track changes. |
unbind(path) | Unbinds a previously bound property. |
| `batch(fn: () => void | Promise)` |
localBind(path) | Binds sub-properties only within the current component that is ignored. |
hook(path) | Hooks into property changes reactively. |
hook().on(conditionFn) | Conditionally triggers updates based on a function. Example: hook("count").on(x => x.count > 5) |
useEffect(fn, ...keys) | Runs a callback when a specific state key changes. |
useComputed(fn, ...keys) | Returns a reactive computed value based on keys. |
resetState() | Resets the local state to its original values. if onInit is set, it will also trigger it |
import buildState from "react-smart-state";
const globalState = buildState({
counter: 0,
item: { count: 1 }
}).timeout(undefined).globalBuild();
const Counter = () => {
globalState.hook("counter")
const state = buildState({
localCount: 0,
nested: { value: 0 }
})
.ignore("nested")
.localBind("nested.value")
.build();
state.useEffect(() => {
console.log("localCount changed:", state.localCount);
}, "localCount");
return (
<div>
<p>Global Counter: {globalState.counter}</p>
<p>Local Count: {state.localCount}</p>
<button onClick={() => {
globalState.counter++;
state.localCount++;
state.nested.value++;
}}>
Increment
</button>
</div>
);
};
onInitconst state = buildState({ user: null })
.onInit(async (state) => {
state.user = await fetchUser();
})
.build();
batchawait state.batch(async () => {
state.a = 1;
state.b = 2;
await someAsyncCall();
state.c = 3;
});
// components only updates once, after the batch is done
hook().onstate.hook("value").on(v => v.value > 10);
import { PrimitiveValue, PrimitiveObject } from 'react-smart-state';
const [counter, setCounter] = PrimitiveValue(0);
const txt = PrimitiveObject("test")
setCounter(1);
txt.value = "test"; // unlike PrimitiveValue or useState value already is test even before render;
MIT © [Alen Toma]
FAQs
Next generation local and global state management
The npm package react-smart-state receives a total of 20 weekly downloads. As such, react-smart-state popularity was classified as not popular.
We found that react-smart-state demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.