{"id":19303396,"url":"https://github.com/jsheaven/simply-persist","last_synced_at":"2025-09-12T19:36:41.962Z","repository":{"id":137502724,"uuid":"597579198","full_name":"jsheaven/simply-persist","owner":"jsheaven","description":"Isomorphic object key/value persistence layer (browser, server) with in-memory, browser and free-tier serverless backend providers","archived":false,"fork":false,"pushed_at":"2023-03-15T14:24:34.000Z","size":93,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-05T23:40:56.270Z","etag":null,"topics":["isomorphic","key-value-database","persistence-layer","storage-api"],"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/jsheaven.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":"2023-02-05T00:42:09.000Z","updated_at":"2023-07-01T08:53:27.000Z","dependencies_parsed_at":"2023-06-10T11:45:47.911Z","dependency_job_id":null,"html_url":"https://github.com/jsheaven/simply-persist","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsheaven%2Fsimply-persist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsheaven%2Fsimply-persist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsheaven%2Fsimply-persist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsheaven%2Fsimply-persist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsheaven","download_url":"https://codeload.github.com/jsheaven/simply-persist/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240404755,"owners_count":19796064,"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":["isomorphic","key-value-database","persistence-layer","storage-api"],"created_at":"2024-11-09T23:26:15.620Z","updated_at":"2025-02-24T02:12:35.566Z","avatar_url":"https://github.com/jsheaven.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003esimply-persist\u003c/h1\u003e\n\n\u003e Nano utility library for JavaScript to persist objects (POJOs) everywhere and with ease\n\n\u003ch2 align=\"center\"\u003ePurpose\u003c/h2\u003e\n\nAccessing `localStorage` and `sessionStorage` or writing to an in-memory object seems easy,\nbut then there is browser private mode, there are security and quota restrictions, and if\nyou try to run the same code on client (in the browser) and server, fun with Errors is guaranteed.\n\nThis is, why we've built this library that only has one job: Write an object into a storage backend,\nbe able to read from it by key to get a value and also be able to delete data by key and make this\npossible isomorphic on client and server side, no matter what.\n\n\u003ch2 align=\"center\"\u003eFeatures\u003c/h2\u003e\n\n- ✅ Write to storage using simple key/value API\n- ✅ Middleware function API allows to hook what is read and written\n- ✅ Isomorphic, works in-browser and in Node.js\n- ✅ Supports `localStorage`\n- ✅ Supports `sessionStorage`\n- ✅ Supports in-memory as an automatic fallback\n- ✅ Supports [Upstash](https://www.upstash.com) (serverless, free-tier database backend)\n- ✅ Exposes the backend API reference of each storage provider for low-level API access\n- ✅ Just `592 byte` nano sized (ESM, gizpped)\n- ✅ Tree-shakable, side-effect free, so maybe just `~200 byte` for you\n- ✅ First class TypeScript support\n- ✅ 100% Unit Test coverage\n\n\u003ch2 align=\"center\"\u003eInstall\u003c/h2\u003e\n\n- yarn: `yarn add simply-persist`\n- npm: `npm install simply-persist`\n\n\u003ch2 align=\"center\"\u003eUse\u003c/h2\u003e\n\n\u003ch3 align=\"center\"\u003eESM\u003c/h2\u003e\n\n```ts\nimport { getStorage } from 'simply-persist'\n\nconst storage = getStorage('memory') // also: 'local' | 'session' | 'upstash'\n\n// store a value\nawait storage.set('abc', 123)\n\n// read a previously stored value, if not existing, return the default (0)\nconst valueStored = await storage.get('abc', 0)\n\n// delete a single value\nawait storage.del('abc')\n\n// delete all values\nawait storage.clear()\n```\n\n\u003ch3 align=\"center\"\u003eCommonJS\u003c/h2\u003e\n\n```ts\nconst { getStorage } = require('simply-persist')\n\n// same API like ESM variant\n```\n\n\u003ch2 align=\"center\"\u003eOne thing about Node.js and `localStorage` and `sessionStorage`\u003c/h2\u003e\n\nThe web storage APIs such as `localStorage` and `sessionStorage` are not available in Node.js.\nThis library will gently fallback to the in-memory variant instead. Please mind the slightly\ndifferent application behaviour in this case.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsheaven%2Fsimply-persist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsheaven%2Fsimply-persist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsheaven%2Fsimply-persist/lists"}