Registry / storage / react-mkx-storage

react-mkx-storage

JSON →
library1.1.9jsnpmunverified

A React hook library (v1.1.9) providing useLocalStorage, useSessionStorage, and useCookieStorage for state management across browser storage APIs. Minimal API surface with three named hooks, each accepting a key and initial value. Suitable for small-to-medium React projects needing persistent state without a state management library. Last updated in 2023; low release cadence.

npm install react-mkx-storage
INSTALL
IMPORT
SIG · REACT-MKX-STORAGE
R
react-mkx-storage
storagejavascriptv1.1.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

useLocalStorage
import { useLocalStorage } from 'react-mkx-storage'
import useLocalStorage from 'react-mkx-storage'
Named export, not default.
useSessionStorage
import { useSessionStorage } from 'react-mkx-storage'
const useSessionStorage = require('react-mkx-storage').useSessionStorage
CommonJS require is possible but not recommended in ESM projects.
useCookieStorage
import { useCookieStorage } from 'react-mkx-storage'
Named export, correct usage shown.

Shows basic usage of useLocalStorage hook with a default value and input binding.

import React from 'react'; import { useLocalStorage } from 'react-mkx-storage'; function App() { const [name, setName] = useLocalStorage('name', 'John'); return ( <div> <p>Hello, {name}!</p> <input value={name} onChange={e => setName(e.target.value)} /> </div> ); } export default App;
Debug
Known issues
gotchaHook does not synchronize state across tabs for localStorage or sessionStorage.
fix
Manually listen to storage events if cross-tab sync is needed.
affects: >=0.0.0
gotchauseCookieStorage may have limited max cookie size (typically 4096 bytes per cookie).
fix
Store smaller serialized data or consider backend storage for large payloads.
affects: >=0.0.0
gotchaInitial value type must be serializable (string, number, object, array) – functions or symbols will cause errors on JSON.parse.
fix
Only pass JSON-serializable initial values.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'from')
Importing default export instead of named export.
fix
Use correct named imports: import { useLocalStorage } from 'react-mkx-storage'
Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
Using hooks in non-browser environment (SSR) or with third-party cookies blocked.
fix
Wrap hook usage in a component that is only rendered client-side.
Value is not saved after page refresh
Key may be missing or storage was cleared; also SSR environment.
fix
Ensure the component runs in browser context and key is consistent.
Upgrade
Version history
1.1.9latest on npm
Audit
Dependencies
reactrequiredPeer dependency for hooks API.
Agent activity
24 hits · last 30 days
node
22
Amazon
1
OpenAI (training)
1
Resources
react-mkx-storage — npm install react-mkx-storage · libregistry