{"id":13547924,"url":"https://github.com/jamen/hyperapp-persist","last_synced_at":"2025-08-01T09:34:28.408Z","repository":{"id":96784749,"uuid":"94142906","full_name":"jamen/hyperapp-persist","owner":"jamen","description":"Persist an app's state to the next session.","archived":false,"fork":false,"pushed_at":"2017-11-10T14:01:12.000Z","size":40,"stargazers_count":18,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-12T11:43:42.758Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/jamen.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-12T21:39:21.000Z","updated_at":"2023-02-19T08:55:16.000Z","dependencies_parsed_at":"2023-06-17T12:00:22.532Z","dependency_job_id":null,"html_url":"https://github.com/jamen/hyperapp-persist","commit_stats":{"total_commits":25,"total_committers":3,"mean_commits":8.333333333333334,"dds":0.48,"last_synced_commit":"8e4f6ac6d8a6557327515563c6194a56c3671c74"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Fhyperapp-persist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Fhyperapp-persist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Fhyperapp-persist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamen%2Fhyperapp-persist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamen","download_url":"https://codeload.github.com/jamen/hyperapp-persist/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234143876,"owners_count":18786244,"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-08-01T12:01:03.218Z","updated_at":"2025-01-16T03:24:28.857Z","avatar_url":"https://github.com/jamen.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"\n# hyperapp-persist\n\n\u003e Persist an app's state between sessions\n\nUse this [Hyperapp](https://github.com/hyperapp/hyperapp) HOA (Higher-Order App) to persist the state between sessions.  As the page unloads the state is saved in `localStorage`, and then the it is restored on the next load.\n\n\u003c!-- Add screencast demo --\u003e\n\n## Install\n\n```sh\nnpm i hyperapp-persist\n```\n\n## Usage\n\n### `persist(app, options)`\n\nPersist is a Higher-Order App that bootstraps the `app()`.\n\nThe options required are:\n\n - `storage` where the state is saved on `localStorage`\n - `include` to specify what state gets saved\n\n```js\nimport { app } from 'hyperapp'\nimport persist from 'hyperapp-persist'\n\napp = persist(app, {\n  storage: 'my-app/v1',\n  include: [ 'router', 'player' ]\n})\n\napp({\n  // ...\n})\n```\n\nAlso possible to use environment variables to remove it in production:\n\n```js\nif (process.env.DEV) {\n  app = persist(app, { ... })\n}\n```\n\n### Versioning the storage\n\nSometimes when developing an app, you'll change the state in a way incompatible with what all your users have saved.  In this case, it is recommended you version the `storage` key.  For example:\n\n```js\napp = persist(app, {\n  storage: 'my-app/1',\n  include: [ 'inputs', 'router', ... ]\n})\n```\n\nThen if a breaking change is made you increment the number to `my-app/2` and so on.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamen%2Fhyperapp-persist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamen%2Fhyperapp-persist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamen%2Fhyperapp-persist/lists"}