Jono

Jono

Serving Phoenix LiveView App from another web app

First, I recognize that there will probably be some CORS issues - and maybe the best solution is to put both apps behind a proxy and have them under the same IP. Currently, both are served from Heroku - and I’m not entirely sure how to stick a proxy like NGINX in front of them - I’m open to that whatever solutions.

But back to the problem at hand, the overarching goal is - I have a webapp written in Django as a rest server, with React/Typescript (App D) - that I’d like to start writing in LiveView (App E) and Phoenix.

Can I somehow make requests from my React code - and serve up the html + socket from LiveView in my already created React app?

Can I do this super incrementally? What issues can I expect?

Most Liked

kokolegorille

kokolegorille

Liveview is autonomous, You receive a full html page, that is remote controlled. It receives incremental changes, applied by morphdom. There would be no need to serve it with React.

Also, React does not like Dom modification…

But if You have already React, You don’t need Liveview. You already have a reactive UI, that could update itself.

What You could do is link your React to Phoenix channels, and that’s easy to do with Phoenix.js. You could build the same system as Liveview do.

Probably most of the people here are backend related, but there are some advantage to have a separate frontend, and You have one. You could switch them, and transform your Django backend into a Phoenix backend :slight_smile:

While porting a Liveview frontend to anything other than Phoenix would be nearly impossible.

patrickdm

patrickdm

So say we all!

Anyway I promise to check this TypeScript stuff out :thinking:, but only after I’ll have enough of Rust which is also awesome :heart_eyes: (and mind blowing). I guess it will take some time.

mindok

mindok

The main issue you will face is both React and LiveView fighting for control over the DOM. If you can get clear demarcation you may have a chance, but if you want React to pull in bits of LiveView I think you will really struggle (without resorting to something ugly like iframes). The pages hosting LiveView will need to be fully “Phoenixed”. I don’t have any React specific experience, but I don’t think that will stop you from hosting a React component on a LiveView page provided you mark which bits of the DOM React is allowed to mess with using phx-update="ignore" as per Phoenix.LiveView — Phoenix LiveView v1.2.5

You could use also just use Phoenix to provide a “real-time API” using Channels - Channels — Phoenix v1.8.8 - this is the same backend comms tech that LiveView is built on but doesn’t do any DOM mutation for you so you would do that in React.

Is there any way you can break out one page at a time from the React app or is it all one big SPA?

Where Next?

Popular in Discussions Top

blackode
Elixir Upgrading is so Simple in Ubuntu and It worked for me Ubuntu 16.04 git clone https://github.com/elixir-lang/elixir.git cd elixir...
New
sashaafm
I’m trying to evaluate the best combo/stack for a BEAM Web app. Right now I’m exploring Yaws a bit, after having dealt with Phoenix for a...
New
sashaafm
Piggy backing a bit on @dvcrn topic BEAM optimization for functions with static return type?, I’ve been trying to understand in a deeper ...
New
AlexMcConnell
The reason that Rails is as popular as it is is because it’s very easy for relatively inexperienced developers to get a lot of work done....
588 19568 166
New
New
rower687
Hi all, I’ve been reading a lot about the “let it crash” term and how supervising processes and the whole messaging passing make an elixi...
New
jer
I’ve been using umbrellas for a while, and generally started off (on greenfield projects at least) by isolating subapps based on clearly ...
New
AstonJ
If so I (and hopefully others!) might have some tips for you :slight_smile: But first, please say which area you’re finding most challen...
New
scouten
I’m looking for a host for the server part of a small (personal) side project that I’m working on. It’s currently written in Node.js and ...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement