
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Gudam stands as a robust yet lightweight React state management library, designed to elevate your application's performance. With an impressively small footprint of just 1kb, it boasts quick execution, straightforward implementation, and scalability. This TypeScript-based library ensures reliable and statically-typed state management for your React applications.
Getting started with Gudam is a breeze. Simply install it using npm with the following command:
npm install gudam
Integrating Gudam into your root component is a straightforward process. Follow these steps:
import { GudamContext, useGudam } from 'gudam'
function App() {
const gudam = useGudam()
return (
<GudamContext.Provider value={gudam}>
{/* Your application is now powered by Gudam */}
<div>Your App Content</div>
</GudamContext.Provider>
)
}
export default App
Define a store in Gudam using the defineStore function. The following example illustrates how to define a store for authentication, including additional details:
import { defineStore } from 'gudam'
export const authGudam = defineStore(
'auth', // Unique key
{
// states
token: '', // Authentication token
role: '', // User role
profile: {
firstName: '', // User's first name
lastName: '', // User's last name
},
// accessors
get isLoggedIn() {
return !!this.token && !!this.role; // Check if the user is logged in
},
get greetingMessage() {
return this.profile.firstName
? `Welcome back ${this.profile.firstName}`
: 'Welcome Guest';
},
// methods
setAuth(token, role) {
this.token = token;
this.role = role;
},
setFirstName(name: string) {
this.profile = { ...this.profile, firstName: name };
},
},
{
version: '0.0.1', // Version of the store
storage: localStorage, // Storage engine (localStorage or sessionStorage)
parse: JSON.parse, // Parser function to parse from string to store state
stringify: JSON.stringify, // Converts stateful properties of your store to JSON string
}
);
defineStore accepts three parameters:
key: A unique identifier for your store.
store: Your store object with states, accessors, and methods.
states: Non-function-type writable properties are states. In our authGudam store, we have token, role, and profile states.
accessors: Accessors are functions with the get identifier, providing a way to access computed or derived properties from the state.
methods: Methods are pure JavaScript functions. You can use these functions to make changes to your store states.
The store object is a regular JavaScript object, except that it triggers effects if changes are made to any state property.
persistOptions (optional): An object with persist options.
| Property | Description | Default Value |
|---|---|---|
| storage* | Storage engine (localStorage or sessionStorage). It is required to enable persistence | undefined |
| version | Version of your current store. Change the version to invalidate old store values in the browser cache | 0.0.1 |
| parse | Parser function to convert from string to store state | JSON.parse |
| stringify | Converts stateful properties of your store to a JSON string | JSON.stringify |
Access and utilize the store in your components as follows:
import { gudamAuth } from '../store/authStore'
const Greeting = () => {
const auth = gudamAuth()
const loginAsDemo = () => {
auth.setFirstName('Demo')
}
return (
<>
<div>{auth.greetingMessage}</div>
{!auth.username && (
<div>
<button onClick={loginAsDemo}>Login as Demo User</button>
</div>
)}
</>
)
}
export default Greeting
You can use the $preload built-in function to preload data into your store. It takes a callback function that receives an object with initial state values and returns the updated state. The following example provides additional details:
import { GudamContext, useGudam } from 'gudam'
import { gudamAuth } from '../store/authStore'
function App() {
const gudam = useGudam()
const auth = gudamAuth(gudam) // providing the gudam instance because the context is not provided yet
auth.$preload((states) => {
return { ...states, token: 'jwt-token', role: 'user' }
})
return (
<GudamContext.Provider value={gudam}>
{/* Your application is now empowered by Gudam */}
<div>Your App Content</div>
</GudamContext.Provider>
)
}
export default App
Please note that once the store is changed, $preload does not execute its callback, and it does not support asynchronous operations.
Gudam follows a modular design, allowing you to use one store inside another. This can be achieved by creating an instance of the store:
export const gudamAccount = defineStore('account', {
balance: 0,
get auth() {
return gudamAuth() // Create an instance of gudamAuth
},
doSomething() {
this.auth.setFirstName('Hasinoor')
},
})
If you require further assistance or have any questions, please don't hesitate to create an issue. The Gudam team is committed to simplifying your state management experience!
FAQs
Gudam is a tiny store management library for react.
We found that gudam demonstrated a not healthy version release cadence and project activity because the last version was released 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
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.