When should we use LiveView or traditional Phoenix?

Recently I studied the book Programming Phoenix Liveview, and PragmaticStudio’s Liveview course, and I found out that if we try to build a common Web App, seems everything we can do in Phoenix MVC, we can just finish it with Liveview, These two resources I learned almost has no “controllers” code, does that mean we don’t need traditional MVC anymore, just liveview is enough?

As with anything in the overly complex world of web development the answer is: ItDepends :tm: on the requirements of what you are building.

LiveView is great because, to quite a large degree, it simplifies the web programming model if we care about updating our page without a page refresh. This is probably the case for most apps these days but it’s not always.

LiveView is not great if we need to store a LOT of in-memory user state since it stores its state on the server. There are out-of-the-box ways to store this state on the client but there comes a point where you need to question if you should be using a client-side framework built for this instead.

LiveView is terrible if you need a progressive web app (you can make it work (probably) but it won’t be fun) and useless if you need offline support—It’s upfront about this.

There are several scenarios where LiveView is great but notably: it absolutely shines when it comes to form-based business applications. This is where I say (and have said literally to coworkers): “Hey, this could just be a controller+view, but it’s going to be both a better DX and UX if we use a LiveView.”

3 Likes

Controllers are still important for everything that doesn’t happen over Websockets - APIs, webhooks, data feeds, etc etc

3 Likes

Yeah, I agree in this. Seems in most of the “traditional way” (not too much state), Liveview can replace controller + view, but in some more complex area, like to build a Figma, both of them will not sufficient.

1 Like