Skip to content

⬅️ Back to Table of Contents

📄 useAuth

📊 Analysis Summary

Metric Count
🔧 Functions 1
📦 Imports 6
🟢 Vue Composition API 1
📐 Interfaces 1

📚 Table of Contents

🛠️ File Location:

📂 packages/firebase/useAuth/index.ts

📦 Imports

Name Source
Auth firebase/auth
User firebase/auth
ComputedRef vue
Ref vue
computed vue
deepRef vue

Vue Composition API

Name Type Reactive Variables Composables
computed computed none none

Functions

useAuth(auth: Auth): { isAuthenticated: any; user: any; }

Reactive Firebase Auth binding

See: https://vueuse.org/useAuth

Tags: @__NO_SIDE_EFFECTS__

Raw JSDoc
/**
 * Reactive Firebase Auth binding
 *
 * @see https://vueuse.org/useAuth
 *
 * @__NO_SIDE_EFFECTS__
 */

Calls:

  • deepRef (from vue)
  • computed (from vue)
  • auth.onIdTokenChanged
Code
export function useAuth(auth: Auth) {
  const user = deepRef<User | null>(auth.currentUser)
  const isAuthenticated = computed(() => !!user.value)

  auth.onIdTokenChanged(authUser => user.value = authUser)

  return {
    isAuthenticated,
    user,
  }
}

Interfaces

UseFirebaseAuthOptions

Interface Code
export interface UseFirebaseAuthOptions {
  isAuthenticated: ComputedRef<boolean>
  user: Ref<User | null>
}

Properties

Name Type Optional Description
isAuthenticated ComputedRef<boolean> not shown
user Ref<User \| null> not shown

Generated by Syntax Scribe