sashaafm

sashaafm

Embedded Elixir/Phoenix in a webpage vs. Frontend communicating with a Phoenix Backend

I’d like to know what are your opinion between building a Web App using embedded Elixir/Phoenix (.eex files), where the data is being passed with the render function to the template, like so:

<%= if @var do %>
  It is obviously true
<% else %>
  This will never appear
<% end %>

vs. separating the frontend (with Javascript and AngularJS maybe) from the backend, using Phoenix to serve a RESTful API:

$http({method: 'GET', url: '/some/phoenix/api/resource'})

What are the advantages and situations where each one is better suited? Are there any use cases where they should be mixed? (particularly does Phoenix mix well with Angular?)

For a simple information system, I think embedded is more than enough but for more modular, better structured and to allow frontend and backend developers to work concurrently the latter is better. Also, separating makes the backend development easier since you just have to build on the :api pipeline instead of both :browser and :api pipelines.

The main disadvantage (for me at least) when separating the frontend from the backend is to have to use a lot of Javascript which I personally hate and find difficult.

Most Liked

OvermindDL1

OvermindDL1

Well using embedded it is significantly easier to internationalize if that is important for your project first of all.

Personally I would go with embedded regardless unless I want/need a single-page-app, in which case phoenix would just be an API endpoint.

zimt28

zimt28

I’m currently rebuilding an SPA app, which I had built in Meteor using Phoenix. Rendering things on the server again, like I’ve done “in the past” makes things so easy again! Also, comparing the two, the SPA solution didn’t feel or responds faster. There are some places where I need JS, but I will just use Vue.js or so where is makes sense.

Just because everyone builds SPAs now doesn’t mean it’s always the best solution!

andre1sk

andre1sk

It highly depends on your particular application.

Last Post!

ibgib

ibgib

I think this is a great idea. :thumbsup:

I’m in the middle of deploying the first stab at ibgib (v0.1.0) which uses server-side rendering + plain vanilla js (mostly relying on d3.js) to simplify development. But I inevitably need a real solution on the front end, so I’ve been keeping a watch on this thread and others similar to it.

So your idea of a slightly more formal wiki of the landscape would be a big help. I would only hope that in addition to what “should” be a good stack, that we also encourage anyone who lists in the new Showcase category to include what they are actually using WRT front end and how they communicate with the back end (channels/sockets, json api, etc.). This way, we could see real world :globe_with_meridians: examples of the end result of the stack.

Where Next?

Popular in Discussions Top

jesse
Hi everyone, I hesitated to post this here because I don’t want you to think I’m spamming, but I’ve been working on a Platform-as-a-Serv...
New
mbenatti
Following https://github.com/tbrand/which_is_the_fastest |&gt; https://raw.githubusercontent.com/tbrand/which_is_the_fastest/master/imgs...
New
und0ck3d
Hello everyone! A few days ago I’ve created a topic here about how people were creating CMSs with Elixir and Phoenix. I’ve been studying...
New
acrolink
How does the two languages compare when it comes to server side application development? Any experiences or ideas? Thank you.
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
crispinb
On reading dhh’s latest The One Person Framework it strikes me that Phoenix with LiveView is already pretty much this. However, never hav...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

Other popular topics Top

JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54921 245
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
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49084 226
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
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

We're in Beta

About us Mission Statement