Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!