Gathering detailed insights and metrics for react-hooks-global-state
Gathering detailed insights and metrics for react-hooks-global-state
Gathering detailed insights and metrics for react-hooks-global-state
Gathering detailed insights and metrics for react-hooks-global-state
react-hooks-global-states
This is a package to easily handling global-state across your react-components using hooks.
react-global-state-hooks
This is a package to easily handling global-state across your react components No-redux, No-context.
react-native-global-state-hooks
This is a package to easily handling global-state across your react-native-components No-redux... The library now includes @react-native-async-storage/async-storage to persist your state across sessions... if you want to keep using the old version without
@dr.pogodin/react-global-state
Hook-based global state for React
[NOT MAINTAINED] Simple global state for React with Hooks API without Context API
npm install react-hooks-global-state
Typescript
Module System
Node Version
NPM Version
TypeScript (96.94%)
JavaScript (3.06%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1,105 Stars
278 Commits
62 Forks
12 Watchers
7 Branches
6 Contributors
Updated on May 26, 2025
Latest Version
2.1.0
Package Id
react-hooks-global-state@2.1.0
Unpacked Size
54.50 kB
Size
10.72 kB
File Count
16
NPM Version
6.14.17
Node Version
14.21.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
1
37
Simple global state for React with Hooks API without Context API
This is a library to provide a global state with React Hooks. It has following characteristics.
1npm install react-hooks-global-state
1import React from 'react'; 2import { createGlobalState } from 'react-hooks-global-state'; 3 4const initialState = { count: 0 }; 5const { useGlobalState } = createGlobalState(initialState); 6 7const Counter = () => { 8 const [count, setCount] = useGlobalState('count'); 9 return ( 10 <div> 11 <span>Counter: {count}</span> 12 {/* update state by passing callback function */} 13 <button onClick={() => setCount(v => v + 1)}>+1</button> 14 {/* update state by passing new value */} 15 <button onClick={() => setCount(count - 1)}>-1</button> 16 </div> 17 ); 18}; 19 20const App = () => ( 21 <> 22 <Counter /> 23 <Counter /> 24 </> 25);
1import React from 'react'; 2import { createStore } from 'react-hooks-global-state'; 3 4const reducer = (state, action) => { 5 switch (action.type) { 6 case 'increment': return { ...state, count: state.count + 1 }; 7 case 'decrement': return { ...state, count: state.count - 1 }; 8 default: return state; 9 } 10}; 11const initialState = { count: 0 }; 12const { dispatch, useStoreState } = createStore(reducer, initialState); 13 14const Counter = () => { 15 const value = useStoreState('count'); 16 return ( 17 <div> 18 <span>Counter: {value}</span> 19 <button onClick={() => dispatch({ type: 'increment' })}>+1</button> 20 <button onClick={() => dispatch({ type: 'decrement' })}>-1</button> 21 </div> 22 ); 23}; 24 25const App = () => ( 26 <> 27 <Counter /> 28 <Counter /> 29 </> 30);
Create a global state.
It returns a set of functions
useGlobalState
: a custom hook works like React.useStategetGlobalState
: a function to get a global state by key outside ReactsetGlobalState
: a function to set a global state by key outside Reactsubscribe
: a function that subscribes to state changesinitialState
State1import { createGlobalState } from 'react-hooks-global-state'; 2 3const { useGlobalState } = createGlobalState({ count: 0 }); 4 5const Component = () => { 6 const [count, setCount] = useGlobalState('count'); 7 ... 8};
Create a global store.
It returns a set of functions
useStoreState
: a custom hook to read store state by keygetState
: a function to get store state by key outside Reactdispatch
: a function to dispatch an action to storeA store works somewhat similarly to Redux, but not the same.
reducer
Reducer<State, Action>initialState
State (optional, default (reducer as any)(undefined,{type:undefined})
)enhancer
any?1import { createStore } from 'react-hooks-global-state'; 2 3const initialState = { count: 0 }; 4const reducer = ...; 5 6const store = createStore(reducer, initialState); 7const { useStoreState, dispatch } = store; 8 9const Component = () => { 10 const count = useStoreState('count'); 11 ... 12};
Returns Store<State, Action>
useGlobalState created by createStore is deprecated.
Type: function (stateKey: StateKey): any
Meta
The examples folder contains working examples. You can run one of them with
1PORT=8080 npm run examples:01_minimal
and open http://localhost:8080 in your web browser.
You can also try them in codesandbox.io: 01 02 03 04 05 06 07 08 09 10 11 13
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/28 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
47 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More