Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

127
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda