Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nuxt3] error caught during app initialization Error: Component auth has not been registered yet #1

Open
sniperadmin opened this issue May 9, 2023 · 1 comment

Comments

@sniperadmin
Copy link

Description:

App loads fine when first time loading. After doing changes to the DOM, this error log comes:

nuxt.js:93 [nuxt] error caught during app initialization Error: Component auth has not been registered yet
    at Provider.initialize (provider.ts:239:13)
    at initializeAuth (initialize.ts:66:25)
    at getAuth (index.ts:80:16)
    at useAuth (use-auth.mjs?v=bc7696e5:11:16)
    at Object.setup (plugin.client.mjs:8:16)
    at wrapper (nuxt.js:189:21)
    at fn (nuxt.js:203:27)
    at callWithNuxt (nuxt.js:208:12)
    at applyPlugin (nuxt.js:124:29)
    at applyPlugins (nuxt.js:133:11)

How to re-generate this:

  • Install Nuxt 3
  • Install nuxt-flame according to the readme file
The following code is applied on a page or `App.vue`:
<template>
  <v-container>
    <v-btn color="primary" @click="checkAuth">
      <v-icon>mdi-account-outline</v-icon>
      {{ $t('auth.form.actions.login') }}
    </v-btn>
    <v-btn color="secondary" @click="logout">
      <v-icon>mdi-account-outline</v-icon>
      {{ $t('e-toolbar.logout') }}
    </v-btn>
  </v-container>
</template>

<script lang="ts" setup>
import {signInAnonymously, signOut} from "@firebase/auth";

import {useAuth} from "#imports";

const checkAuth = async () => {
  try {
    const auth = useAuth()
    if (!auth) return
    const result = await signInAnonymously(auth)
    console.info('success! => ', result)
  } catch (error) {
    console.log('error logging in => ', error)
  }
}

const logout = async () => {
  try {
    const auth = useAuth()
    if (!auth) return
    const result = await signOut(auth)
    console.info('logout success => ', result)
  } catch(error) {
    console.log('Error logout => ', error)
  }
}
</script>

<style scoped>

</style>

Environment details:

  • "OS": windows 10
  • "Node version": 18.16.0
  • "Package manager used": yarn@1.22.19
  • "nuxt": ^3.4.3
  • "firebase": ^9.21.0
  • "firebase-admin": ^11.8.0
  • "firebase-tools": latest
  • "nuxt-flame": ^1.0.0-beta.9
@CharlieDigital
Copy link

Getting the same issue on a MacOS env.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants