
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
kea-localstorage
Advanced tools
Perstist Kea reducers in localstorage
Read the documentation for Kea
Install via yarn or npm
yarn add kea-localstorage
npm install --save kea-localstorage
Then add it to the context:
import { localStoragePlugin } from 'kea-localstorage'
import { resetContext } from 'kea'
resetContext({
plugins: [ localStoragePlugin ]
})
To use it, make sure your logic store has a defined path. Then just pass { persist: true } as an option to your reducer, like so:
const someLogic = kea({
path: () => ['scenes', 'something', 'foobar'], // NEEDED!
actions: () => ({
change: value => ({ value })
}),
reducers: ({ actions }) => ({
persistedValue: [0, PropTypes.number, { persist: true }, {
[actions.change]: (_, payload) => payload.value
}]
})
})
You may optionally configure the plugin by passing in some options:
import { localStoragePlugin } from 'kea-localstorage'
import { resetContext } from 'kea'
resetContext({
plugins: [
localStoragePlugin({
// in case you want to replace this, e.g. for tests or non browser environments
storageEngine: window.localStorage,
// added before all paths in localStorage's keys
prefix: 'example',
// to change the symbol that concats path parts
separator: '_'
})
]
})
With the above configuration all persisted reducers will now be save in the path: example_scenes_something_foobar
const someLogic = kea([
path(['scenes', 'something', 'foobar']),
reducers({
persistedValue: [0, { persist: true, prefix: 'example', separator: '_' }, {
changeThing: (_, payload) => payload.value
}]
}),
])
Now the persistedValue will not be saved in scenes.something.foobar, but in example_scenes_something_foobar
Under the hood kea-localstorage overrides the defaults value for your reducer with whatever was
stored in localstorage. In case you need to access the original default, it's stored here:
logic.cache.localStorageDefaults['reducerKey']
storageKeyPass a storageKey, to override the key used for storage. This allows multiple logics to share the same value. For example
to have all keyed logics store a reducer globally.
const someLogic = kea([
key(props => props.key), // not used for localstorage, overridden by storageKey
reducers(({ actions }) => ({
persistedValue: [0, { persist: true, storageKey: 'my.global.key' }, {
[actions.change]: (_, payload) => payload.value
}]
}))
])
FAQs
Store reducer state in localStorage with Kea
The npm package kea-localstorage receives a total of 1,738 weekly downloads. As such, kea-localstorage popularity was classified as popular.
We found that kea-localstorage 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.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.