{"id":16788731,"url":"https://github.com/markmead/alpinejs-persist-extended","last_synced_at":"2025-03-22T00:33:03.610Z","repository":{"id":41468250,"uuid":"509711503","full_name":"markmead/alpinejs-persist-extended","owner":"markmead","description":"Extends the official `$persist` plugin to help you work with `localStorage` 📦","archived":false,"fork":false,"pushed_at":"2024-04-04T10:53:22.000Z","size":30,"stargazers_count":19,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-14T08:24:38.274Z","etag":null,"topics":["alpine-js","alpinejs","alpinejs-persist","alpinejs-plugin","javascript","javascript-localstorage","localstorage"],"latest_commit_sha":null,"homepage":"https://js.hyperui.dev/examples/storage-extended","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/markmead.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":"2022-07-02T09:22:22.000Z","updated_at":"2024-10-02T16:44:10.000Z","dependencies_parsed_at":"2024-09-18T16:46:59.952Z","dependency_job_id":null,"html_url":"https://github.com/markmead/alpinejs-persist-extended","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/markmead%2Falpinejs-persist-extended","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markmead%2Falpinejs-persist-extended/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markmead%2Falpinejs-persist-extended/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markmead%2Falpinejs-persist-extended/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markmead","download_url":"https://codeload.github.com/markmead/alpinejs-persist-extended/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221820900,"owners_count":16886225,"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":["alpine-js","alpinejs","alpinejs-persist","alpinejs-plugin","javascript","javascript-localstorage","localstorage"],"created_at":"2024-10-13T08:24:31.735Z","updated_at":"2025-03-22T00:33:03.604Z","avatar_url":"https://github.com/markmead.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Alpine JS Persist Extended\n\n\u003e [!IMPORTANT] \n\u003e This plugin is no longer maintained or supported.\n\n![](https://img.shields.io/bundlephobia/min/alpinejs-persist-extended)\n![](https://img.shields.io/npm/v/alpinejs-persist-extended)\n![](https://img.shields.io/npm/dt/alpinejs-persist-extended)\n![](https://img.shields.io/github/license/markmead/alpinejs-persist-extended)\n\nExtends the official Alpine JS `$persist` plugin with additional utilities to\nhelp you work with `localStorage` more effectively. This plugin adds methods to\nget and delete persisted data without needing to set up additional data\nproperties.\n\n## Benefits\n\n- 📌 `$persistGet`: Retrieve persisted data directly from localStorage without\n  defining an x-data property\n- 🗑️ `$persistDelete`: Remove items from localStorage and trigger custom events\n- 🔄 Works seamlessly alongside the official Alpine JS persist plugin\n- 🪶 Lightweight solution (under 1KB minified)\n- ⛓️ Zero dependencies beyond Alpine JS and the official persist plugin\n\n## Install\n\n### CDN\n\n```html\n\u003cscript\n  defer\n  src=\"https://unpkg.com/alpinejs-persist-extended@latest/dist/cdn.min.js\"\n\u003e\u003c/script\u003e\n\n\u003cscript\n  defer\n  src=\"https://unpkg.com/@alpinejs/persist@latest/dist/cdn.min.js\"\n\u003e\u003c/script\u003e\n\n\u003cscript defer src=\"https://unpkg.com/alpinejs@latest/dist/cdn.min.js\"\u003e\u003c/script\u003e\n```\n\n### Package\n\n```shell\nyarn add -D alpinejs-persist-extended\nnpm install -D alpinejs-persist-extended\n```\n\n```js\nimport Alpine from 'alpinejs'\nimport storage from 'alpinejs-persist-extended'\n\nAlpine.plugin(storage)\n\nwindow.Alpine = Alpine\n\nAlpine.start()\n```\n\n## Example\n\nHere's a practical example showing how to use the extended persist\nfunctionality:\n\n```html\n\u003cdiv\n  x-data=\"{ name: $persist('Rob Brydon') }\"\n  @persist:delete.window=\"name = ''\"\n\u003e\n  \u003ch2 x-text=\"name\"\u003e\u003c/h2\u003e\n\n  \u003cinput type=\"text\" x-model=\"name\" placeholder=\"Enter your name\" /\u003e\n\n  \u003cbutton type=\"button\" @click=\"alert($persistGet('name'))\"\u003e\n    Show persisted name\n  \u003c/button\u003e\n\n  \u003cbutton type=\"button\" @click=\"$persistDelete('name')\"\u003eReset name\u003c/button\u003e\n\u003c/div\u003e\n```\n\nIn this example:\n\n- We initialize a persisted `name` property that saves to localStorage\n- When the name is deleted, we listen for the `persist:delete` event\n- We provide UI controls to view and delete the persisted data\n\n## API Reference\n\n### Get\n\n```js\n$persistGet('name')\n```\n\nGets the value from `localStorage` for the provided key. This is useful when you\nneed to access persisted data without having to define it in your `x-data`\nobject.\n\n### Delete\n\n```js\n$persistDelete('name')\n```\n\nRemoves the data from `localStorage` for the specified key. When called, it also\ndispatches a `persist:delete` custom event that you can listen for in your\nAlpine components.\n\n```html\n\u003cdiv @persist:delete.window=\"name = ''\"\u003e\u003c/div\u003e\n```\n\nThe event listener pattern is particularly useful for resetting related data or\nupdating UI elements when persistence is cleared.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkmead%2Falpinejs-persist-extended","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkmead%2Falpinejs-persist-extended","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkmead%2Falpinejs-persist-extended/lists"}