acrolink

acrolink

I hope you can help me choose between two possible setups:

a. Phoenix JSON API on the back-end and Vue.js on the front end to render views / lists / filters / forms (basically all UI).

b. Phoenix HTML views (eex) and partial use of Vue.js on the UI for special elements (such as nested forms).

Which solution gives better overall user performance experience?

Showing Posts 1 to 10

acrolink

acrolink OP

I am seeing that using Vue.js within Pheonix HTML files can be better, since Phoenix keeps taking care of routing and there is no need to run two servers, one for backend and another for front end.

Clemens

Clemens

It depends on what you want to build…

If you build a simple webapp with some simple forms and static sites, you are better off using Phoenix html…

If you build a highly interactive single page application and you might want to add other clients later (for example a mobile app) I would recommend to build the front end completely with Vue.js.

acrolink

acrolink OP

Let’s say that I need to render some html element conditionally if the currently logged in user has a particular role. How could VueJS access that information inside its templates and render accordingly ? In Phoenix HTML, that’s easy but how to do that in a complete VueJS build with a Phoenix JSON API backend?

kokolegorille

kokolegorille

When You are completely separating frontend from backend, it is usually nice to use a state manager that will hold the state of your UI. In your case, storing user and maybe roles.

This can be done by Redux, or Vuex if You use Vue. Or by any similar tools…

Here is a blogpost that compares both…

herdibintang

herdibintang

I’m curious too. No answer for this?

jeroenvisser101

jeroenvisser101

@hlx and I are using a different approach, also using Vue and Elixir. We’re running a Elixir server with a GraphQL endpoint using Absinthe, which allows for a lot of flexibility and is quite nice to work with. Alongside that, we’re deploying our Vue application as a static web app to Netlify which is also incredibly easy to do.

GraphQL allows you to query multiple resources in one HTTP request, which might end up getting better performance for your users.

amnu3387

amnu3387

What part specifically? It’s highly dependent on what you’re doing. There’s plenty of ways to communicate with the back-end, either by implementing router solutions for your front-end, making ajax calls, using libraries that handle that, etc.

That’s a game I’m developing (it’s fairly more developed now than when that video went up). All the logic is processed in the server, which then serves the state through Phoenix Channels, on the front-end it’s a Vue application, that hooks to the “game” channel the user is playing and to a particular “user” channel just for him.

From the state that I pass from the server I bind information to each user’s Vue instance, which then is used on the component to draw the gameboard. Users only emit certain messages to the server, such as “pass”, “cast” (with the additional info of what they chose), “strike” (again with the relevant info), the server processes those calls, checks for legality, and if everything lines up correctly broadcasts a new state, which the vue instance receives through the form of a event listener, and re-binds the information to it’s relevant variables, from which the component again redraws the gameboard.

The “game lobby” parts is also composed of a vue instance, with two components, a “list” of games (open, closed, etc, that gets refreshed through a broadcast from the back-end whenever there are changes), and a component to “create/open” a new game and wait opponents. Then the same logic, when someone joins a game, the back-end processes that, and fires a broadcast which is interpreted in the vue part of the front-end and reflected on the page.

acrolink

acrolink OP

Here I am answering my own question :slight_smile:

I have gained in the meantime some experience in VueJS. Any use of VueJS inside Phoenix means creating JSON API endpoints, so the best solution is to create a pure JSON/API Phoenix application and use VueJS for the UI (front-end).

VueJS is simply amazing. I have already created some friendly UI using VueJS with log-in, pagination, routes, filters etc.

herdibintang

herdibintang

Hi, thank you for your reply. Your game looked so smooth!

I want to dynamically adding element like when using Jquery but this time using Vuejs. But after seeing author’s latest answer I think it’s impossible.

acrolink

acrolink OP

@herdibintang you are welcome to share what you want to achieve using jQuery (the code) and get feedback as to if the same can be done in VueJS.

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
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
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews