📌 Feature Request: Add setLocalStorage
Extension to Store hx-data
in Local Storage
#141
Labels
setLocalStorage
Extension to Store hx-data
in Local Storage
#141
Issue Description:
HTMX currently does not have a built-in way to persist
hx-data
values inlocalStorage
. A new extension,setLocalStorage
, would allow developers to automatically storehx-data
attributes when an element is clicked. This would enable client-side data persistence and enhance state management in HTMX applications.✨ Proposed Feature:
The
setLocalStorage
extension will:hx-data
when they are processed by HTMX.click
event listener to storehx-data
values inlocalStorage
.💡 Example Usage:
localStorage.setItem("theme", "dark")
localStorage.setItem("username", "Alice")
🛠 Suggested Implementation:
🎯 Why This Feature Matters:
✅ Enhances Client-Side State Management – Allows developers to persist important UI data (e.g., theme, form inputs, filters).
✅ Improves UX – Users can reload a page and still retain previously selected values.
✅ Lightweight & Simple – Works within HTMX’s declarative approach without requiring extra JavaScript.
Would love to see this feature added to HTMX! Let me know if you need any refinements or contributions. 🙌🔥
The text was updated successfully, but these errors were encountered: