Skip to content

[+Extension] hx-keep, enables form and html content to persist across reloads. #3293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AjaniBilby
Copy link
Contributor

@AjaniBilby AjaniBilby commented Apr 26, 2025

I've created a library to enable forms to be cached in localStorage to allow them to survive refreshes, accidental tab closures, etc - with the server being able to then clear the cache with http hx-keep-evict header when the data is successfully saved to the server.

banner

It also provides client side APIs to allow frontends like react to hook into it to store their state in a form for custom input elements.

HTML attribute prefix used: hx-keep* (with support for data- prefix)
Respects hx-history="false"

@AjaniBilby
Copy link
Contributor Author

This does have some overlap with the behaviour of hx-preserve, however hx-keep has nothing to do with element state like video - it only considers the raw html or FormData.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant