{"id":21190100,"url":"https://github.com/reactiumcore/redux-local-persist","last_synced_at":"2026-06-19T16:32:37.916Z","repository":{"id":57350948,"uuid":"135595935","full_name":"ReactiumCore/redux-local-persist","owner":"ReactiumCore","description":null,"archived":false,"fork":false,"pushed_at":"2019-12-05T18:30:45.000Z","size":50,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-01T14:06:14.373Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ReactiumCore.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-31T14:38:24.000Z","updated_at":"2019-01-17T06:46:12.000Z","dependencies_parsed_at":"2022-09-16T21:11:28.087Z","dependency_job_id":null,"html_url":"https://github.com/ReactiumCore/redux-local-persist","commit_stats":null,"previous_names":["reactiumcore/redux-local-persist","atomic-reactor/redux-local-persist"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiumCore%2Fredux-local-persist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiumCore%2Fredux-local-persist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiumCore%2Fredux-local-persist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactiumCore%2Fredux-local-persist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ReactiumCore","download_url":"https://codeload.github.com/ReactiumCore/redux-local-persist/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243646539,"owners_count":20324583,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T18:59:25.857Z","updated_at":"2025-10-24T15:36:23.032Z","avatar_url":"https://github.com/ReactiumCore.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Redux Local Persist\n\nRedux middleware for selectively loading and saving state to localStorage.\nRedux Local Persist allows you to add a `persist` property to your Redux state that will specify how the defined values are saved in localStorage.\n\n## Applying the Middleware\n```js\nimport todos from './reducers';\nimport initialState from './state';\nimport { load, save } from 'redux-local-persist';\nimport { createStore, applyMiddleware } from 'redux';\n\n\n// Load the persistent state from localStorage\nlet state = {\n    ...initialState,\n    ...load({initialState: initialState})\n};\n\nconst store = createStore(\n  todos,\n  state,\n  applyMiddleware(save())\n);\n\nstore.dispatch({\n  type: 'ADD_TODO',\n  text: 'Understand the middleware'\n});\n```\nIf the `initialState` is persisting the `text` property, it will be saved to localStorage after `store.dispatch` is executed.\n\n\n## Methods\n\n### clear({ properites:String|Array [Optional] })\nClears the Redux Local Persist values from localStorage.\n```js\n/**\n * Given the state:\n    let initialState = {\n        count: 0,\n        deep: {\n            nested: {\n                value: 123\n            }\n        },\n        loaded: true,\n        persist: true,\n    };\n */\n\n...\nimport { clear } from 'redux-local-persist';\n\nclear();                                // returns: {}\nclear('deep.nested.value');             // returns: {count: 0, loaded: true}\nclear(['count', 'deep.nested.value']);  // returns: {loaded: true}\n```\n\n### load({ intialState:Object })\nGets the Redux Local Persist values from localStorage. If the values have expired, the initialState value is used.\n\n### save()\nAutomatically saves state changes to localStorage.\n\n\n\n## The Persist Property\n\nThe persist property can be of type: **Boolean|Number|String|Array|Object**\n\n### Persist as a Boolean\nWhen set to `true`, the entire state tree for the connected component will be saved _indefinitely_.\n\n### Persist as a Number\nThe entire state tree for the connected component will be saved for the specified number of _milliseconds_.\nThe next time the state is loaded from `window.localStorage`, the timestamp of the last save will be checked against the current time and if it's past the duration the Object Path will not be included.\n\n### Persist as a String\nOnly the specified Object Path of the state tree for the connected component will be saved _indefinitely_.\n\nExample: `deep.nested.value` would persist a state tree of:\n```js\n{\n    deep: {\n        nested: {\n            value: 123\n        }\n    }\n}\n```\n\n### Persist as an Array of Strings\nOnly the specified Object Paths of the state tree for the connected component will be saved _indefinitely_.\n\nExample: `['deep.nested.value', 'count']` would persist a state tree of:\n```js\n{\n    count: 0,\n    deep: {\n        nested: {\n            value: 123\n        }\n    }\n}\n```\n\n### Persist as an Object\nOnly the specified Object Paths of the state tree for the connected component will be saved for the specified number of _milliseconds_.\n\nExample: `{'deep.nested.value': 10000, 'loaded': 30000}` would persist a state tree of:\n```js\n{\n    loaded: false,\n    deep: {\n        nested: {\n            value: 123\n        }\n    }\n}\n```\n\n## Usage\n\n### Simple\nPersist the entire state tree indefinitely:\n\n```js\n...\nlet initialState = {\n    count: 0,\n    loaded: false,\n    persist: true\n};\n...\n```\n\n### Simple Usage with Expiration\nPersist the entire state tree for 10 seconds:\n\n```js\n...\nlet initialState = {\n  count: 0,\n  loaded: false,\n  persist: 10000,\n};\n...\n```\n\n\n### Save Specific Parts of State Tree\nPersist only `deep.nested.value` and `loaded` values indefinitely:\n\n```js\n...\nlet initialState = {\n  count: 0,\n  loaded: false,\n  deep: {\n      nested: {\n          value: 123\n      }\n  }\n  persist: ['deep.nested.value', 'loaded'],\n};\n...\n```\n\n\n### Save Specific Parts of State Tree with Expiration\nPersist only the `deep.nested.value` for 10 seconds, `loaded` for 5 seconds, and `count` indefinitely:\n\n```js\n...\nlet initialState = {\n  count: 0,\n  loaded: false,\n  deep: {\n      nested: {\n          value: 123\n      }\n  }\n  persist: {\n      'deep.nested.value': 10000,\n      'loaded': 5000,\n      'count': true\n  },\n};\n...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freactiumcore%2Fredux-local-persist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freactiumcore%2Fredux-local-persist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freactiumcore%2Fredux-local-persist/lists"}