• I am calling an action with VUEX and i check if user is authenticated in the life cycle CREATED through main.js with vue without quasar

    created() {
      firebase.auth().onAuthStateChanged(function(user) {
      if (user) {
        // add user into the store 

    What can i do to call some action in quasar when all my application start, since these current versions there is not the main.js
    #quasar #doubt

  • @MathSilva You don’t need main.js with Quasar. As it said in Quasar docs

    For initialization code and importing libraries into your website/app, read about App Plugins.

    Read this also quasar.conf.js

  • @shone i have read that, acctually all the documentation, but how can i call an action when the whole application starts? I was doing that with main of vue it was working fine. But i need to do it in quasar. I mean i don’t want to call this action when a single component loads, cuz i could call it directly in the component, but in the whole application.

  • I haven’t used firebase before and not sure what best practices are for using firebase, but it appears you are trying to check authentication before your main component is created. Again as I have not used firebase, what I would do with a regular spa jwt is to take all auth logic and set it in an app plugin. you can read more about this in quasar docs. Then I would set another plugin for my routerHooks (utilise beforeRouteEnter to check for auth and redirect accordingly) so this would serve as an auth middleware.

    To create an app plugin you need to first create a file in plugin folder either manually or using quasar cli(recommended)

    // first import firebase and whatever you need
    export default ({ app, router, store, Vue }) => {
      // add your code here to check for auth user and interact with store

    Next you need to make sure you register the plugin in quasar.conf (refer to docs).

    Another way this can be done is to use the preFetch feature, check it out maybe it helps.

Log in to reply