Firestore user id is different of the document id react native firebase

I’m doing a simple user creation, but the id field in the firestore is null and the ids are different.

why is this happening? how to solve?

code below:

const auth = await authFB().createUserWithEmailAndPassword(data.email, data.password);

const db = firestore();

await db
        .collection('Clients')
        .doc(auth.user.uid)
        .set({
          id: auth.user.uid,
          name: {
            first: firstName,
            last: lastName
            }
         });

Document image below: (Look at id: null):

enter image description here

68 thoughts on “Firestore user id is different of the document id react native firebase”

  1. The solution that we have found:

    const auth = await authFB().createUserWithEmailAndPassword(data.email, data.password);
    
    const uid = auth.user.uid;
    
    const db = firestore();
    
    await db
            .collection('Clients')
            .doc(uid)
            .set({
              id: uid,
              name: {
                first: firstName,
                last: lastName
                }
             });
    
    Reply

Leave a Comment