Website and mobile application development on Elixir

Hello everyone.

I plan to write my own small project using Phoenix LiveView for the browser, but I am also interested in creating an application for Android/iOS.

LiveView makes it easy to create web pages, but due to the specific interaction with the server, it will not be possible to create a mobile application based on the same code.

Surely someone had a similar experience. Are you creating a separate CRUD API for the app? :sweat_smile:
I know about the existence of LiveView Native, but it’s still too raw.

I’m new to Elixir and don’t know much, but I like the ecosystem created for writing websites.
But you may have to duplicate the code for the mobile app.

Hi @fowos

You can create api endpoints for crud in the router and call those from the app.

You can always wrap a webview in Flutter/React Native/Capacitor. It’s not optimal UX, but if you want something that runs on all platforms, and also allows for native mobile app integrations (location, notifications, etc.), then it is an option.

Live View communicates over websockets, on the first load it sends a static html page template with dynamic parts and subsequently it sends diffs on the dynamic parts of the html. I think in essence there is no reason why you cannot connect to this websockets and listen to these messages. The only part that is useless to you is the static html page.

If you want to get fancy you could update Phoenix live View to send a static json instead of a html page and on the client update your json or app state with the diff messages.

LiveView transmits data not just to WebSocket or Phoenix Channels, but in its own format, specific to the framework and the specific place on the site where the widget needs to be updated.

That is, something like this JSON:

{ “1” : { “0”: “…” } }

And it is unpleasant to read it. What if it changes during the update or just like that? It doesn’t fit.

Well, I understand that no one has any other options but to create a separate JSON API and partially duplicate the logic.

Of course, that’s the way to do it. For years I have been seperating back-end and front-end codes. Completely.

But at that moment you commit yourself to:

  • securing an API
  • writing a second application in another language while also duplicating a lot of logic
  • maintaining 2 applications instead of 1

I would consider every other possibility very seriously before going this route.

  1. Needs to be done in all cases.
  2. Love doing it so, this gives me 100% freedom and flexibility.
  3. See no issue in doing that.

Nr. 1 certainly does not need to be done if you write a Liveview app.