[Vuejs]-Difference between Vue router and express, are both needed (especially when using Firebase)?

0👍

You could use Cloud Functions for Firebase as your backend and then limit your stack to Vue.js and Firebase.

From the doc:

Cloud Functions for Firebase lets you automatically run backend code
in response to events triggered by Firebase features and HTTPS
requests. Your code is stored in Google’s cloud and runs in a managed
environment. There’s no need to manage and scale your own servers.

For your specific need: “backend logic to manipulate that data and spit it back out to the user in a view.” you have several possible approaches:

  • You manipulate the data with Cloud Functions (in the back end), write the results of this manipulation to the Real Time Database and setup some listeners in your Vue.js frontend (with the on() method) that will refresh your front end upon changes in the database
  • Use some HTTPS Cloud Functions that you call, from your Vue.js front-end, as REST API endpoints. You can use Axios for example. See the doc here.

One advantage of the first solution is that you can easily, by default, rely on the database security rules, while it would need some more extra work in the second case.

Leave a comment