Gathering detailed insights and metrics for @plq/use-persisted-state
Gathering detailed insights and metrics for @plq/use-persisted-state
Gathering detailed insights and metrics for @plq/use-persisted-state
Gathering detailed insights and metrics for @plq/use-persisted-state
npm install @plq/use-persisted-state
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (91.92%)
JavaScript (8.08%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
20 Stars
623 Commits
7 Forks
4 Watchers
14 Branches
2 Contributors
Updated on Dec 06, 2023
Latest Version
1.2.0
Package Id
@plq/use-persisted-state@1.2.0
Unpacked Size
65.16 kB
Size
14.72 kB
File Count
86
NPM Version
10.1.0
Node Version
20.8.0
Published on
Oct 09, 2023
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
25
Persists the state to localStorage, sessionStorage or any custom storage
localStorage
, sessionStorage
or almost anything else implements storage API1import createPersistedState from '@plq/use-persisted-state' 2import storage from '@plq/use-persisted-state/lib/storages/local-storage' 3 4const [usePersistedState] = createPersistedState('example', storage) 5 6export default function App() { 7 const [count, setCount] = usePersistedState('count', 0) 8 const handleIncrement = () => setCount(prevCount => prevCount + 1) 9 10 return ( 11 <div> 12 {count} 13 <button onClick={handleIncrement}>+</button> 14 </div> 15 ) 16}
To use @plq/use-persisted-state
, you must use react@16.8.0
or greater which includes Hooks.
1import createPersistedState from '@plq/use-persisted-state' 2import storage from '@plq/use-persisted-state/lib/storages/local-storage' 3 4const [usePersistedState, clear] = createPersistedState('example', storage) 5 6export default function App() { 7 const [count, setCount] = usePersistedState('count', 0) 8 const increment = () => setCount(prevCount => prevCount + 1) 9 10 return ( 11 <div> 12 {count} 13 <button onClick={increment}>+</button> 14 <button onClick={clear}>Clear</button> 15 </div> 16 ) 17}
1import createPersistedState from '@plq/use-persisted-state' 2import storage from '@plq/use-persisted-state/lib/storages/session-storage' 3 4const [usePersistedState, clear] = createPersistedState('example', storage)
1import createPersistedState from '@plq/use-persisted-state' 2// or 3import { createAsyncPersistedState } from '@plq/use-persisted-state' 4import { local } from '@plq/use-persisted-state/lib/storages/browser-storage' 5 6const [usePersistedState, clear] = createPersistedState('example', local)
The storage API is similar to the browser.storage but with a few differences
1import createPersistedState from '@plq/use-persisted-state'
2
3const storageListeners = new Set()
4
5onChangeSomeStorage(event => {
6 const changes = {
7 [event.key]: {
8 newValue: event.newValue,
9 oldValue: event.oldValue,
10 },
11 }
12
13 listeners.forEach(listener => {
14 listener(changes)
15 })
16})
17
18const myStorage = {
19 get: keys => getItemsFromSomeStorage(keys),
20 set: items => setItemsToSomeStorage(items),
21 remove: keys => removeItemsFromSomeStorage(keys),
22 onChanged: {
23 addListener: listener => storageListeners.add(listener),
24 removeListener: listener => storageListeners.delete(listener),
25 hasListener: listener => storageListeners.has(listener),
26 }
27}
28
29const [usePersistedState, clear] = createPersistedState('example', myStorage)
@plq/use-persisted-state/lib/storages/local-storage
@plq/use-persisted-state/lib/storages/session-storage
@plq/use-persisted-state/lib/storages/browser-storage
manifest.json
file@plq/use-persisted-state/lib/storages/chrome-storage
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
14 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