Hello, I’m planning to create a Phoenix Liveview application. I need some guidance on the JS side.
I’ve researched the topic and concluded that Alpine.js may be the way to go for me. I have experience with Vue and Angular, but this time I prefer something lightweight that works well with LiveView.
Lately, I’ve started to have some doubts. My main concerns are:
compatibility issues where HTML updates on LiveView components break the Alpine.js virtual DOM
mixing data and code and bloating the HTML
Could anybody share their experience with LiveView + Alpine.js or recommend any other combination instead?
I used to use it but I much prefer to use Phoenix.LiveView.JS commands and LiveVIew Hooks these days. I don’t find Alpine to be worth the hassle of having to deal with the compatability with LiveView or the additionaly bundle size.
For many apps with LiveView probably don’t need a “JS-side” as such (the JS module can do some basic stuff).
When LiveView doesn’t cut it and you do need JS, personally I’d recommend rendering frontend JS components here and there (most frameworks allow you to sprinkle components here and there on the page - the whole page doesn’t need to be an SPA).
My go-to would be Svelte - for that you could use LiveSvelte or you could use a library I recently published Komodo