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! Switch mode

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:

Last Post!

depdepdep

depdepdep

Hello @kokolegorille , thanks for the reply!

The main reason I want to enter Phoenix is to move out from the “client and API server” model with NextJS/Django REST that I currently have, and also to use LiveView on other parts on my app. (and some other reason I described on my previous post)

I will take a look on possibly embedding the React component for some routes and if there’s any Webpack setup I might need to have.

Thanks for the LiveView upload resource, will take a look on it! :smiley:

Where Next?

Trending in Questions Top

jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
saveman71
Hello ! We want new/edit form pages to POST/PUT to their own URL rather than the resources REST defaults (post /things, put /things/:id)...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
michallepicki
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New

We're in Beta

About us Mission Statement