{"id":22788993,"url":"https://github.com/ripeworks/local-storage-fallback","last_synced_at":"2025-04-04T14:08:55.397Z","repository":{"id":8593951,"uuid":"58941552","full_name":"ripeworks/local-storage-fallback","owner":"ripeworks","description":"Check and use appropriate storage adapter for browser (localStorage, sessionStorage, cookies, memory)","archived":false,"fork":false,"pushed_at":"2023-01-12T06:49:05.000Z","size":703,"stargazers_count":105,"open_issues_count":15,"forks_count":18,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-15T00:20:59.647Z","etag":null,"topics":["cookies","localstorage","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/ripeworks.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}},"created_at":"2016-05-16T15:00:58.000Z","updated_at":"2024-01-25T18:28:16.000Z","dependencies_parsed_at":"2023-01-14T11:48:17.833Z","dependency_job_id":null,"html_url":"https://github.com/ripeworks/local-storage-fallback","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripeworks%2Flocal-storage-fallback","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripeworks%2Flocal-storage-fallback/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripeworks%2Flocal-storage-fallback/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ripeworks%2Flocal-storage-fallback/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ripeworks","download_url":"https://codeload.github.com/ripeworks/local-storage-fallback/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247190252,"owners_count":20898702,"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":["cookies","localstorage","sessionstorage"],"created_at":"2024-12-12T01:39:34.879Z","updated_at":"2025-04-04T14:08:55.360Z","avatar_url":"https://github.com/ripeworks.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# local-storage-fallback\nCheck and use appropriate storage adapter for browser (localStorage, sessionStorage, cookies, memory)\n\n[![npm version](https://badge.fury.io/js/local-storage-fallback.svg)](https://badge.fury.io/js/local-storage-fallback)\n\n## Installation\n\n```\n$ npm install local-storage-fallback\n```\n\n## Usage\n\n```js\nimport storage from 'local-storage-fallback' // if you use es6 or typescript\n// use object destructuring when using require()\n// const {storage} = require('local-storage-fallback')\n\n// Use storage directly\nstorage.setItem('foo', 'bar');\nstorage.getItem('foo'); // bar\n\n// Or shim window.localStorage\nif (!('localStorage' in window)) {\n  window.localStorage = storage;\n}\n```\n\n## Browser Bundle\n\n```html\n\u003cscript src=\"https://unpkg.com/local-storage-fallback/lib/dist.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  window.localStorageFallback.setItem('foo', 'bar')\n\u003c/script\u003e\n```\n\n## Purpose\n\nWith browser settings like \"Private Browsing\" it has become a problem to rely on a working `window.localStorage`, even in newer browsers. Even though it may exist, it will throw exceptions when trying to use `setItem` or `getItem`. This module will run appropriate checks to see what browser storage mechanism might be available, and then expose it. It uses the same API as `localStorage` so it should work as a drop-in replacement in most cases.\n\n## Gotchas\n\n* `CookieStorage` __has__ storage limits. Be careful here.\n* `MemoryStorage` will __not__ persist between page loads. This is more or less a stop-gap to prevent page crashes, but may be sufficient for websites that don't do full page loads.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fripeworks%2Flocal-storage-fallback","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fripeworks%2Flocal-storage-fallback","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fripeworks%2Flocal-storage-fallback/lists"}