Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

110
Vistas
Problem with showing only one of two buttons depending on a computed property

In a nuxt component with a div and button, I want to show only one of them depending on the user state (Login and Logout).

When I Login the signout button shows up and the login is hidden as wanted.

The problem is when I logout the signout button is hidden but the login button doesn't show.

What's strange to me is when i log the isUserLoggedIn property, it gives me the correct value between true/false on the client, but it's always returning false in the terminal and Nuxt SSR in the browser.

I use @nuxtjs/firebase module to handle the auth and this is the config

 firebase: {
    config: {
      // My config
    },
    services: {
      auth: {
        persistence: "local",
        initialize: {
          onAuthStateChangedAction: "onAuthStateChanged",
          subscribeManually: false,
        },
        ssr: false,
      },
    },
  },

My Login.vue component:

<template>
  <div>
    <div v-show="!isUserLoggedIn" id="firebase-auth-google"></div>

    <button
      @click="logout"
      v-show="isUserLoggedIn"
      class="flex px-4 py-2 text-white bg-red-600"
    >
      Logout
    </button>
  </div>
</template>

<script>
export default {
  computed: {
    isUserLoggedIn() {
      console.log("Login page", this.$store.getters["isLoggedIn"]);
      return this.$store.getters["isLoggedIn"];
    },
  },

  methods: {
    async logout() {
      await this.$firebaseAuth.signOut();
    },
  },

  mounted() {
    this.$firebaseAuth.renderGoogleLogin("firebase-auth-google");
  },
};
</script>
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda