3 ms·
samwillis: since I see you are here answering questions, any reason you choose Alpine over HTMX? I've been thinking about building something like Tetra for Fla
by rsyring 4y ago
samwillis: since I see you are here answering questions, any reason you choose Alpine over HTMX?
I've been thinking about building something like Tetra for Flask, but was planning on using HTMX.
- samwillis 4y agoFirstly HTMX is awesome, its a really cool project. There is also a Django project implementing helpers for it: https://django-htmx.readthedocs.io/en/latest/ https://django-htmx.readthedocs.io/en/latest/ HTMX and Alpine take quite different approaches, HTMX is more about calling remote endpoints, returning html fragments and replacing parts of the DOM. It's really nicely done. Alpine on the other hand is more about decorating your elements with directives and having a "reactive" client side state, very much like a mini Vue.js (it actually uses the reactive core from Vue). It also has a "morph" plugin, which Tetra uses, that rather than replacing the dom with html retuned from the server it makes all the necessary changes to make the existing dom match, keeping all user state (cursers in text boxes etc.). This is a lot like how Vue and React work. Tetra components are sort of inspired by Vue and so more closely align with the Alpine approach.
- rsyring 4y agoThanks for the detailed reply. It's helpful to understand the difference between the two approaches at a high level. You probably know this but for others who might read, HTMX has an alpine plugin which uses morph and persists client side state, including Alpine competent state: https://htmx.org/extensions/alpine-morph/ https://htmx.org/extensions/alpine-morph/ I also thought HTMX persisted some state on swapped elements, but it's possible that's only the html attributes. Can't seem to find details in the docs at the moment.