jinder

jinder

Hi all,
I am new to Phoenix with small frontend experience. I have a usecase where I am curious to know how you would approach the following:

Use Case : Need to render data in table where rows can be sorted again column in acs and des. order of values. Sorting happens for the current rendered rows.
Since the sorting is straightforward, should it be handled by liveview handle_event or directly handle on frontend using component like material-ui react table . I am using react for frontend. Would there be any advantage of liveview over react in such case ?

Showing Posts 1 to 5

tfwright

tfwright

Most of the power of live view comes from keeping state on the server and rendering markup there. Rendering a table is an extremely common use case. I would only even contemplate dealing with react if I had to build a front end for a backend I dont control.

kanishka

kanishka

Not that I can tell.

My limited understanding of the advantage of liveview is that you don’t have to implement an API and your full stack devs can focus on one programming language. If you are dealing with basic data entry/crud UIs for an early startup or small company with limited resources this can provide a boost in productivity.

lerosbif

lerosbif

2 years later, is there any update to the when and why to use React over LiveView for a frontend in Phoenix?

As a learning exercise. I spent some time wiring up React to Phoenix, and in the end, I am left pondering the ‘why’ in all of this. Are there things that LiveView cannot do as well as React?

garrison

garrison

The obvious things are offline/local-first and e2e encryption. There are also some latency advantages for a client-rendered app but the difference is very domain-specific in practice because most React apps are hitting the server for API calls constantly anyway and the distance to the database matters much more than the distance to the server.

There are some advantages for client rendering in terms of performance for some use-cases but LiveView apps can be optimized to perform better than you would probably think and React optimization is not trivial either.

LiveView apps are stateful on the server so (and this is implementation specific) they may be more expensive to operate than a client-rendered app. In practice I don’t think this is very meaningful unless you are operating at astronomical scale with thin margins - servers are cheap and Elixir scales out.

If you want the best possible user experience I still think client rendering will always win, but it’s important to understand that LiveView has a declarative stateful rendering model (like React) but on the server. This is fundamentally different from other approaches like HTMX, LiveWire, etc. It is actually possible to build extremely complex interfaces in LiveView (unlike those others), and the advantage for client rendering with respect to the average web developer is very small. The vast majority of web devs will never even get a chance to work on an app where there is a substantial difference IMO, at least if the current state of the industry holds.

I’m referring to apps like Linear or Figma here.

Finally there are a handful of use-cases for which I suspect server-rendering is actually optimal, which may be surprising. These are cases where the state is inherently biased towards the server. I think a good canonical example of this is something like the AWS console - everything is inherently server-side, and the UI is just a thin client over those APIs. I suspect that AI/Agentic apps will fall into this category once people figure out how to actually build them - a good example would be the Deep Research paradigm, where again everything is happening on the server essentially by definition.

lerosbif

lerosbif

Thank you for the detailed reply. You have given me a lot to think about regarding the architecture of an application I am considering developing.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews