{"id":16349527,"url":"https://github.com/arojunior/redux-localstore","last_synced_at":"2025-07-16T05:04:20.873Z","repository":{"id":20496425,"uuid":"90074981","full_name":"arojunior/redux-localstore","owner":"arojunior","description":"Synchronize Redux Store with localStorage","archived":false,"fork":false,"pushed_at":"2023-01-04T14:35:21.000Z","size":1011,"stargazers_count":40,"open_issues_count":12,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-22T16:41:37.054Z","etag":null,"topics":["javascript","localstorage","redux","sessionstorage"],"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/arojunior.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-02T20:27:07.000Z","updated_at":"2023-09-20T18:16:02.000Z","dependencies_parsed_at":"2023-01-13T21:00:19.468Z","dependency_job_id":null,"html_url":"https://github.com/arojunior/redux-localstore","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/arojunior/redux-localstore","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arojunior%2Fredux-localstore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arojunior%2Fredux-localstore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arojunior%2Fredux-localstore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arojunior%2Fredux-localstore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arojunior","download_url":"https://codeload.github.com/arojunior/redux-localstore/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arojunior%2Fredux-localstore/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265483213,"owners_count":23774167,"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":["javascript","localstorage","redux","sessionstorage"],"created_at":"2024-10-11T01:00:12.435Z","updated_at":"2025-07-16T05:04:20.608Z","avatar_url":"https://github.com/arojunior.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Synchronize Redux Store with localStorage/sessionStorage\n\n[![npm version](https://img.shields.io/npm/v/redux-localstore.svg)](https://www.npmjs.com/package/redux-localstore) [![npm downloads](https://img.shields.io/npm/dm/redux-localstore.svg)](https://www.npmjs.com/package/redux-localstore) [![Standard - JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)\n\nSubscribe Redux Store and replicate to `localStorage`, so user will can refresh page and keep the App state\n\n### Store example\n\nJust import the **_default method_** (you can call storeSynchronize as the example above) from `'redux-localstore'` and pass store as parameter\n\n```javascript\nimport { createStore, combineReducers } from 'redux';\nimport storeSynchronize from 'redux-localstore';\n\nconst combineReducer = combineReducers({\n  Auth,\n  Product\n});\n\nexport const store = createStore(combineReducer);\n\nstoreSynchronize(store); // the default config synchronizes the whole store\n```\n\n### localStorage / sessionStorage\n\nThe default browser storage is the `localStorage` (persists until the **_browser_** is closed), but since version 0.3.0 you can change the default to `sessionStorage` (persists until the **_tab_** is closed).\n\n```javascript\nstoreSynchronize(store, {\n  storage: 'sessionStorage'\n});\n```\n\n### Blacklist\n\nIf you need to ignore some reducer, you can use the **blacklist** configuration:\n\n```javascript\nstoreSynchronize(store, {\n  blacklist: ['Auth']\n});\n```\n\n### Whitelist\n\nIf you want to sync just specific reducers, you can use the **whitelist** configuration:\n\n```javascript\nstoreSynchronize(store, {\n  whitelist: ['Product']\n});\n```\n\n### Reducer example\n\nTo populate the initalState from browser storage, import **_defineState_** method from `'redux-localstore'`, pass your `defaultState` as first parameter and the reducer key as second. (note that it's using currying)\n\n```javascript\nimport { defineState } from 'redux-localstore';\n\nconst defaultState = {\n  data: null\n};\n\nconst initialState = defineState(defaultState)('Product');\n\nexport default (state = initialState, action) =\u003e {\n  switch (action.type) {\n    case 'ACTION1':\n      return {\n        ...state,\n        data: action.payload\n      };\n    case 'ACTION2':\n      return {\n        ...state,\n        data: null\n      };\n    default:\n      return state;\n  }\n};\n```\n\n### Getting local state\n\nThis method gets the persisted state. It shouldn't be actually necessary, since the state from your redux store is supposed to be the same.\n\n```javascript\nimport { getState } from 'redux-localstore';\n\nconst state = getState();\n```\n\n### If you need to reset the local store\n\n```javascript\nimport { resetState } from 'redux-localstore';\n\nresetState();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farojunior%2Fredux-localstore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farojunior%2Fredux-localstore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farojunior%2Fredux-localstore/lists"}