{"id":51613122,"url":"https://github.com/ultimatecourses/vault","last_synced_at":"2026-07-12T10:30:24.742Z","repository":{"id":11963570,"uuid":"14535754","full_name":"ultimatecourses/vault","owner":"ultimatecourses","description":"Typed localStorage and sessionStorage utility with data structure and prefix support.","archived":false,"fork":false,"pushed_at":"2022-07-25T23:11:28.000Z","size":162,"stargazers_count":178,"open_issues_count":0,"forks_count":15,"subscribers_count":4,"default_branch":"master","last_synced_at":"2026-05-19T23:57:42.823Z","etag":null,"topics":["javascript","localstorage","storage"],"latest_commit_sha":null,"homepage":"https://ultimatecourses.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ultimatecourses.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":"2013-11-19T19:40:22.000Z","updated_at":"2025-02-14T17:59:54.000Z","dependencies_parsed_at":"2022-09-12T01:01:11.821Z","dependency_job_id":null,"html_url":"https://github.com/ultimatecourses/vault","commit_stats":null,"previous_names":["toddmotto/vault"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/ultimatecourses/vault","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultimatecourses%2Fvault","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultimatecourses%2Fvault/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultimatecourses%2Fvault/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultimatecourses%2Fvault/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ultimatecourses","download_url":"https://codeload.github.com/ultimatecourses/vault/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultimatecourses%2Fvault/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35390360,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-12T02:00:06.386Z","response_time":87,"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":["javascript","localstorage","storage"],"created_at":"2026-07-12T10:30:23.744Z","updated_at":"2026-07-12T10:30:24.731Z","avatar_url":"https://github.com/ultimatecourses.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n🔒 @ultimate/vault\n\u003c/h1\u003e\n\u003ch4 align=\"center\"\u003e\n  \u003cimg width=\"25\" valign=\"middle\" src=\"https://ultimatecourses.com/static/icons/typescript.svg\"\u003e\n  1KB typed \u003ccode\u003elocalStorage\u003c/code\u003e and \u003ccode\u003esessionStorage\u003c/code\u003e utility with data structure and prefix support.\n\u003c/h4\u003e\n\n\u003ca href=\"https://ultimatecourses.com/courses/javascript\" target=\"_blank\"\u003e\n  \u003cimg src=\"https://ultimatecourses.com/static/banners/ultimate-javascript-leader.svg\"\u003e\n\u003c/a\u003e\n\n## Installation\n\nInstall via `npm i @ultimate/vault`.\n\n## Documentation\n\n_ESModule_: Import `Vault` into your TypeScript or JavaScript project and create a new instance:\n\n```ts\nimport { Vault } from '@ultimate/vault';\n\nconst localStorage = new Vault();\n```\n\n_Global_: Access `window.Vault` if you are not using a module system:\n\n```html\n\u003cscript src=\"vault.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  // implicitly uses localStorage until specified\nconst localStorage = new Vault();\n\u003c/script\u003e\n```\n\n### Local or Session Storage\n\nBy default `new Vault()` will use `localStorage`. You may specify the type of storage:\n\n```ts\nconst localStorage = new Vault({ type: 'local' });\nconst sessionStorage = new Vault({ type: 'session' });\n```\n\nAs `Vault` is a `class` each instance works independently.\n\n### Key Prefixes\n\nCreate a prefix for each `Vault` instance:\n\n```ts\nconst localStorage = new Vault({ prefix: 'x9ea45' });\n```\n\nAll keys set into storage via this instance will be stored as `x9ea45-\u003ckey\u003e`.\n\n### isSupported property\n\nBrowser support is IE8+ so this shouldn't be wildly needed, but it's there anyway:\n\n```ts\nconst localStorage = new Vault();\n\nif (localStorage.isSupported) {\n  // initialize...\n}\n```\n\n### `set\u003cT\u003e(key: string, value: T): void`\n\nSet a key and value into storage using the typed `set` method:\n\n```ts\n// TypeScript\nconst localStorage = new Vault();\n\ninterface User {\n  name: string\n}\n\nlocalStorage.set\u003cUser\u003e('user', { name: 'Todd Motto' });\n```\n\nAll methods are available to use without TypeScript:\n\n```js\nconst localStorage = new Vault();\n\nlocalStorage.set('user', { name: 'Todd Motto' });\n```\n\n### `get\u003cT\u003e(key: string): T | undefined`\n\nGet a value from storage using the typed `get` method:\n\n```ts\nconst localStorage = new Vault();\n\ninterface User {\n  name: string\n}\n\nlocalStorage.get\u003cUser\u003e('user');\n```\n\n### `remove(key: string): void`\n\nRemove an item from storage using the `remove` method:\n\n```ts\nconst localStorage = new Vault();\n\nlocalStorage.remove('user');\n```\n\n### `removeAll(): void`\n\nRemove _all_ items from storage:\n\n```ts\nconst localStorage = new Vault();\n\nlocalStorage.removeAll();\n```\n\n### `onChange(key: string, fn: (e: StorageEvent) =\u003e void): () =\u003e void`\n\nListen to the `storage` change event from another tab, which is emitted when any storage value is changed. Here we can specify to only listen to specific property changes:\n\n```ts\nconst localStorage = new Vault();\n\nconst unsubscribe = localStorage.onChange('user', (e: StorageEvent) =\u003e {\n  // `user` was changed in another tab\n  // we could use this new data to sync our UI\n  console.log(e);\n});\n\n// remove the event listener when you're ready\nunsubscribe();\n```\n\n### Get all values\n\nObtain all storage values by accessing the `value` getter:\n\n```ts\nconst localStorage = new Vault();\n\nconsole.log(localStorage.value); // { \"user\": \"Todd Motto\", ... }\n```\n\nReturns an object with all keys and values. Values will remain a `string` type and will need parsing with `JSON.parse()` if you need to access the value.\n\n### Length of Storage\n\nAccess how many items are currently in storage with `length`:\n\n```ts\nconst localStorage = new Vault();\n\nconsole.log(localStorage.length); // 3\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fultimatecourses%2Fvault","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fultimatecourses%2Fvault","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fultimatecourses%2Fvault/lists"}