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

128
Vistas
Firebase Auth Interface UserMetadata

I'm learning how to access UserMetadata in firebase Auth through this documentation (https://firebase.google.com/docs/reference/js/auth.usermetadata)

I'm trying to get UserMetadata.lastSignInTime but I can't seem to console.log this code. Please have a look at my code.

I greatly appreciate your help. Thank you have a nice day :)

import React, { useState, useEffect } from 'react'
import { initializeApp } from "firebase/app"
import { getAuth, UserMetadata } from '@firebase/auth'
import { getFirestore, doc, getDoc} from "firebase/firestore"
import { useAuth } from "../contexts/AuthContext"
import { useHistory } from 'react-router-dom'


const Trainings = () => {
    const firebaseConfig = {
        //some configurations      
    
    }
    
    const app = initializeApp(firebaseConfig)
    
    const db = getFirestore(app);

    const auth = getAuth(app);

    console.log(UserMetadata.lastSignInDate);

  //some code below

Then it throws in an error that says:

"Attempted import error: 'UserMetadata' is not exported from '@firebase/auth'."

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This import is working on Firebase v9.1.1.

import { UserMetadata } from "firebase/auth"

Also that's an interface and not an object containing user's metadata. To get user's metadata try this:

const auth = getAuth(app)
const user = auth.currentUser

const userMetadata = user?.metadata

You don't need to explicitly import UserMetadata and use it like this:

const userMetadata: UserMetadata = user?.metadata
about 4 years ago · Juan Pablo Isaza Denunciar
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