{"id":13727101,"url":"https://github.com/mswjs/storage","last_synced_at":"2025-09-02T14:35:03.743Z","repository":{"id":53717524,"uuid":"309964798","full_name":"mswjs/storage","owner":"mswjs","description":"Persistence and live synchronization layer for testing JavaScript applications.","archived":false,"fork":false,"pushed_at":"2021-08-09T10:48:26.000Z","size":167,"stargazers_count":18,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-25T03:37:17.447Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/mswjs.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}},"created_at":"2020-11-04T10:08:38.000Z","updated_at":"2024-07-19T16:10:56.000Z","dependencies_parsed_at":"2022-09-10T13:40:10.454Z","dependency_job_id":null,"html_url":"https://github.com/mswjs/storage","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mswjs/storage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mswjs%2Fstorage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mswjs%2Fstorage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mswjs%2Fstorage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mswjs%2Fstorage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mswjs","download_url":"https://codeload.github.com/mswjs/storage/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mswjs%2Fstorage/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273297914,"owners_count":25080478,"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-09-02T02:00:09.530Z","response_time":77,"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-03T01:03:39.469Z","updated_at":"2025-09-02T14:35:03.696Z","avatar_url":"https://github.com/mswjs.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003e **Please note that this library is about to be discontinued. Please prefer using the [@mswjs/data](https://github.com/mswjs/data) package that provides data modeling capabilities, querying client, and data persistency. Thank you.**\n\n# Storage\n\nData storage and persistency layer for testing JavaScript applications.\n\n## Features\n\n### Persistency\n\nThe values of a live storage are persisted in the session. In a browser that is achieved by [`sessionStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage).\n\n### Real-time synchronization\n\nUpdates to the storage are synchronized between all active clients in real time. In a browser that is achieved by using a [`BroadcastChannel`](https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel) to signal updates.\n\n## When to use?\n\n- When writing CRUD operations in tests;\n- When conducting local in-browser testing/debugging;\n- In combination with API mocking tools (i.e. [MSW](https://github.com/mswjs/msw))\n\n## Get started\n\n### Install\n\n```bash\n$ npm install @mswjs/storage --save-dev\n```\n\n### Create storage\n\n```js\nimport { LiveStorage } from '@mswjs/storage'\n\n// Instantiate a new storage with a unique string key\n// and initial value.\nconst posts = new LiveStorage('posts', [])\n```\n\n### Update values\n\n```js\n// Storage update is a function that derives the next value\n// from the previous storage value.\nposts.update((prevPosts) =\u003e prevPosts.concat({ title: 'Brave new world' });\n```\n\n### Get value\n\n```js\nposts.getValue() // [{ title: 'Brave new world' }]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmswjs%2Fstorage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmswjs%2Fstorage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmswjs%2Fstorage/lists"}