{"id":13796573,"url":"https://github.com/rt2zz/unstated-persist","last_synced_at":"2025-08-14T00:07:00.369Z","repository":{"id":66106618,"uuid":"129565733","full_name":"rt2zz/unstated-persist","owner":"rt2zz","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-02T09:36:42.000Z","size":403,"stargazers_count":19,"open_issues_count":12,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-08T18:16:46.324Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rt2zz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-04-15T00:55:00.000Z","updated_at":"2021-12-10T02:43:14.000Z","dependencies_parsed_at":"2023-04-04T17:31:01.530Z","dependency_job_id":null,"html_url":"https://github.com/rt2zz/unstated-persist","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rt2zz/unstated-persist","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rt2zz%2Funstated-persist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rt2zz%2Funstated-persist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rt2zz%2Funstated-persist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rt2zz%2Funstated-persist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rt2zz","download_url":"https://codeload.github.com/rt2zz/unstated-persist/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rt2zz%2Funstated-persist/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270336686,"owners_count":24566779,"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","status":"online","status_checked_at":"2025-08-13T02:00:09.904Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-08-03T23:01:12.022Z","updated_at":"2025-08-14T00:07:00.332Z","avatar_url":"https://github.com/rt2zz.png","language":"JavaScript","funding_links":[],"categories":["Packages"],"sub_categories":[],"readme":"## Unstated Persist\n\nunstated container w/ persistence\n\n### Usage\nUsage is simple, replace Container with PersistContainer and add persist config as a class property\n```js\nimport { PersistContainer } from 'unstated-persist'\nimport localForage from 'localforage'\n\ntype CounterState = {\n  count: number\n};\n\nclass CounterContainer extends PersistContainer\u003cCounterState\u003e {\n  persist = {\n    key: 'counter',\n    version: 1,\n    storage: localForage,\n  }\n // ...\n}\n```\n\n### FAQ\n#### Class inheritance are you crazy?\nWell it works, and [its tiny and simple](https://github.com/rt2zz/unstated-persist/blob/master/packages/unstated-persist/src/unstated-persist.js). Risk of inheritance collision / confusion is minimal in this case.\n\n#### Migrations\nIn the future we will add redux-persist like migrations / transforms. For now, changing persist version will simply clobber stored state. \n\n#### PersistGate\nAn example of how PersistGate might be implemented [lives here](https://github.com/rt2zz/unstated-persist/tree/master/packages/unstated-persist-gate). However it is so simple, I expect in most cases components will their own gating. Something like:\n```js\nimport { Subscribe } from 'unstated'\nimport { isBootstrapped } from 'unstated-persist'\n\n//...\n\n\u003cSubscribe to={[containers]}\u003e\n  {(...containers) =\u003e {\n    if (!containers.every(isBootstrapped)) return \u003cLoading /\u003e\n    return \u003cApp /\u003e\n  }}\n\u003c/Subscribe\u003e\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frt2zz%2Funstated-persist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frt2zz%2Funstated-persist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frt2zz%2Funstated-persist/lists"}