{"id":19565430,"url":"https://github.com/mitchellcash/node-storage-polyfill","last_synced_at":"2026-06-09T22:31:15.009Z","repository":{"id":78773143,"uuid":"329936513","full_name":"MitchellCash/node-storage-polyfill","owner":"MitchellCash","description":"A Web Storage API polyfill for Node.js environments","archived":false,"fork":false,"pushed_at":"2021-04-16T12:50:07.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-18T08:44:41.530Z","etag":null,"topics":["localstorage","polyfill","sessionstorage","storage","webstorage"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/MitchellCash.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-15T14:35:12.000Z","updated_at":"2022-07-30T15:00:00.000Z","dependencies_parsed_at":"2023-05-22T23:01:56.756Z","dependency_job_id":null,"html_url":"https://github.com/MitchellCash/node-storage-polyfill","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"00a7cae921124259b75bc64163c525d98b6555d4"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MitchellCash%2Fnode-storage-polyfill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MitchellCash%2Fnode-storage-polyfill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MitchellCash%2Fnode-storage-polyfill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MitchellCash%2Fnode-storage-polyfill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MitchellCash","download_url":"https://codeload.github.com/MitchellCash/node-storage-polyfill/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240824164,"owners_count":19863606,"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":["localstorage","polyfill","sessionstorage","storage","webstorage"],"created_at":"2024-11-11T05:26:43.971Z","updated_at":"2025-11-19T22:03:16.832Z","avatar_url":"https://github.com/MitchellCash.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-storage-polyfill\n\nA Web Storage API polyfill for both `window.localStorage` and `window.sessionStorage` for Node.js\nenvironments.\n\n## Motivation\n\nThere are certain situations where you need to access the Web Storage browser APIs, but they aren't\navailable in Node.js environments, such as:\n\n- Running tests locally in a Node.js environment that make calls to the Web Storage browser APIs\n- Using a Server-Side Rendering (SSR) framework that won't compile because the browser APIs aren't\n  available server-side\n\nThis module provides fully compatible APIs and exposes both `localStorage` and `sessionStorage`\nglobally as if you were working in a browser context where the APIs would be fully available.\n\n## Installation\n\n```sh\nnpm install node-storage-polyfill\n```\n\n## Usage\n\n```js\n// CommonJS\nrequire('node-storage-polyfill');\n\n// ES Module\nimport 'node-storage-polyfill';\n```\n\nThis exposes `global.localStorage` and `global.sessionStorage` to your codebase to interact with.\n\n## Example\n\n```js\nimport 'node-storage-polyfill';\n\nsessionStorage.setItem('KEY_1', 'VALUE_1');\nconsole.log(sessionStorage.getItem('KEY_1'));\n// Output: 'VALUE_1'\n```\n\n## Limitations\n\nThe `localStorage` API that is exposed does not differ from `sessionStorage` and only holds the\ndata in-memory. This differs from the browser based `localStorage` API which stores data between\nsessions.\n\n## Recognition\n\nI would like to thank [capaj](https://github.com/capaj) and his work on\n[localstorage-polyfill](https://github.com/capaj/localstorage-polyfill) which was working for me\nuntil I needed a `sessionStorage` polyfill, and a new project to spend some time on. Most of the\nlogic and tests are based on their module, but rewritten in TypeScript and adds support for\n`sessionStorage` as well as `localStorage`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitchellcash%2Fnode-storage-polyfill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitchellcash%2Fnode-storage-polyfill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitchellcash%2Fnode-storage-polyfill/lists"}