depdepdep

depdepdep

Migrating React app to Phoenix

Hello Elixir Forum! :smiley:
I have questions about migrating a client-side specific feature from a React app to Phoenix (or maybe to a traditional server-side app).

I have an existing app built with NextJS and Django (REST) and I’ve been considering to migrate it to Phoenix. But, some aspect of the app might be very well-suited to client-side nature of a React app, and I’m not sure if I can really migrate the whole thing to Phoenix.

Users can submit a product in a multi-step (multi-page) form, where they can upload images (and some other additional files) and edit them in an editor (made with fabric.js) where they can move around/resize the images. Every time it happens, another “preview” image is generated on the browser and will be displayed on the other pages in this multi-step form.

Everything happens on client-side: uploaded files and generated preview images are still being kept on the client until users actually hit submit, so the file is not being sent unnecessarily to the server if later on the user decided not to continue the process.

Question: how should I approach to do that on Phoenix?
What I can think of currently is to have the multi-page form, save every step of the form on a “draft” record and actually “publish” after the last submit button clicked. I can set up a scheduled job to remove all “draft” records (unfinished form submissions). But this approach would mean that every files uploaded & preview images generated to be saved on server and sent across the network, with the additional network to/from AWS S3 which I’m using.

I’m new to Elixir and Phoenix and not aware of commonly used libraries/patterns that might fit the problem well, so I need some suggestions :smiley: would like to just migrate the React component to LiveView + some JS (if that’s possible), or embedding the React component, or rendering React component for this specific route with some other libraries I can found on this forum.

First Post!

BartOtten

BartOtten

Welcome! But…but…why? What advantages do you expect Phoenix (Live)Views will bring you in this use case? If we know, this might influence the advice.

Option 1: less Python
Phoenix can act as API server. You could swap Django with Phoenix + Absinthe (and use it’s websocket subscriptions). Then you can keep the React frontend.

Option 2: less javascript
Try Liveview; but know how to combine it with Javascript libs before you start building and keep in mind the roundtrip delays.

Option x, y, z…etc we need more info :wink:

Where Next?

Popular in Questions Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
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
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 126479 1222
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