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

426
Views
Firebase/javascript -- How to connect data created in firestore with user

Firebase v9

How to connect data created in firestore with user who created this data?

I use the createUserWithEmailAndPassword function to authorize user in firebase and after authorization I getting user data with onAuthStateChanged, but how could i connect particular user with data that is created only by them?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

To create for example a profile document for a specific user, the common pattern is to use the user's UID as the document ID. Something like this:

import { getAuth, onAuthStateChanged } from "firebase/auth";
import { doc, setDoc } from "firebase/firestore"; 

const auth = getAuth();
onAuthStateChanged(auth, (user) => {
  if (user) {
    const uid = user.uid;

    await setDoc(doc(db, "users", uid), {
      name: user.displayName
    });
    // ...
  }
});

Also see:

  • the Firebase documentation on getting the current user
  • the Firebase documentation on writing a document
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!