Hacker News new | ask | show | jobs
by void_mint 1721 days ago
I thought the purpose of LiveView was to remove the need for JS frameworks?
2 comments

When you use a front-end framework like React, there are UI changes you can make that must hit the server for information and other UI changes that can be done locally without interacting with the server. LiveView really shines in cases where you’re hitting the server anyway, but JavaScript can be more efficient for client-side-only changes. So, if you want, you can combine LiveView and JavaScript to optimize your site for both types of UI changes. You don’t have to. You can use LiveView exclusively, but the choice to combine LiveView and JavaScript is there if you want it.

Personally, I think React is a bloated choice if you’re going to use both LiveView and JavaScript. In cases where I use both, I typically use a small framework like AlpineJS or vanilla JavaScript for client-side-only changes.

> Personally, I think React is a bloated choice if you’re going to use both LiveView and JavaScript. In cases where I use both, I typically use a small framework like AlpineJS or vanilla JavaScript for client-side-only changes.

Good to know! That's probably why this boilerplate generator only has a handful of (what I think are) smaller JS libs and not Vue/React?

Yep. What your parent poster said is the accepted common wisdom in the Elixir Phoenix circles.
No, the purpose of live view is to act as a "smart server-side caching layer" so you don't throw everything away and start from scratch each time you hit the server.
That’s really not what it is. Live View is a replacement for most of what you can do with JS, but isn’t great for everything. The browser connects to the server via web socket and a process is started to manage the DOM state. Diffs are sent to the browser in response to various events such as clicks on elements or PubSub broadcasts.
you are describing what it is, but not what the bigger point is. Here it is, from Chris McCord: https://www.youtube.com/watch?v=XhNv1ikZNLs&list=PLqj39LCvnO...
Ah, TIL. I have no experience other than being a passive fan. Thanks!