Gathering detailed insights and metrics for mst-persist
Gathering detailed insights and metrics for mst-persist
Gathering detailed insights and metrics for mst-persist
Gathering detailed insights and metrics for mst-persist
Persist and hydrate MobX-state-tree stores (in < 100 LoC)
npm install mst-persist
Typescript
Module System
Node Version
NPM Version
72.4
Supply Chain
96.9
Quality
75.7
Maintenance
100
Vulnerability
100
License
v0.1.4 -- more permissive MST peerDep
Updated on Jul 13, 2023
v0.1.3 -- fixes missing __esModule in CJS
Updated on Dec 04, 2019
v0.1.2 -- fixes `jsonify: false` and localStorage `Illegal Invocation` errors
Updated on Nov 19, 2019
v0.1.1 -- fixes/enables support for Node usage
Updated on Jul 27, 2019
v0.1.0 -- adds types and new build variants
Updated on Jul 14, 2019
v0.0.2 -- fixes bug when key does not yet exist in storage
Updated on Jul 07, 2019
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
NOASSERTION License
86 Stars
67 Commits
17 Forks
4 Watchers
4 Branches
2 Contributors
Updated on Dec 21, 2024
Latest Version
0.1.4
Package Id
mst-persist@0.1.4
Unpacked Size
33.74 kB
Size
7.37 kB
File Count
12
NPM Version
9.5.1
Node Version
18.16.1
Published on
Jul 13, 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
Persist and hydrate MobX-state-tree stores.
1npm i -S mst-persist
1import { types } from 'mobx-state-tree' 2import localForage from 'localForage' 3import { persist } from 'mst-persist' 4 5const SomeStore = types.model('Store', { 6 name: 'John Doe', 7 age: 32 8}) 9 10const someStore = SomeStore.create() 11 12persist('some', someStore, { 13 storage: localForage, // or AsyncStorage in react-native. 14 // default: localStorage 15 jsonify: false // if you use AsyncStorage, this shoud be true 16 // default: true 17 whitelist: ['name'] // only these keys will be persisted 18}).then(() => console.log('someStore has been hydrated')) 19
persist(key, store, options)
arguments
localForage
.
The default is localStorage
, which has a built-in adaptor to make it support Promises.
For React Native, one may configure AsyncStorage
instead.
redux-persist
's Storage Engines should also be compatible with mst-persist
.true
).returns a void Promise
Node environments are supported so long as you configure a Storage Engine that supports Node, such as redux-persist-node-storage
, redux-persist-cookie-storage
, etc.
This allows you to hydrate your store server-side.
For SSR though, you may not want to hydrate your store server-side, so in that case you can call persist
conditionally:
1if (typeof window !== 'undefined') { // window is undefined in Node 2 persist(...) 3}
With this conditional check, your store will only be hydrated client-side.
None yet, but can take a look at agilgur5/react-native-manga-reader-app which uses it in production. Can view the commit that implements it here.
Basically just a small wrapper around MST's onSnapshot
and applySnapshot
.
The source code is currently shorter than this README, so take a look under the hood! :)
Inspiration for parts of the code and API came from redux-persist
, mobx-persist
, and this MST persist PoC gist
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/19 approved changesets -- 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
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
54 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
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