Hacker News new | ask | show | jobs
by vlz 1037 days ago
I don't think there is a single answer to state management with htmx as in "put your key-value pairs here“. Instead the page depicts the application state and offers ways to change it or to change what is depicted each time updating parts of the page. So the state is what's on the page so to say. However some options are: 1. you can have some form of state in your url by having every user actions change a param, returning the updated page with updated links/forms. 2. You could keep a session on the backend. Never used this myself, however Django which you speak of above should have support for sessions without a user/login. 3. you can keep state in the database if is important enough and you have a user. 4. htmx also sends a lot of js events which you can react to by using some plain Javascript yourself. You can also send your own events and have htmx listen on them to have different components react to a page/state update elsewhere with their own page update.