1

How to add custom profile details to the user in firebase? I know we can already add displayName and photoURL, but I want to add more fields like age,sex, country etc. Is there any way to do that?

user.updateProfile({
      displayName: "Jane Q. User",
      photoURL: "https://example.com/jane-q-user/profile.jpg"
    }).then(function() {
      // Update successful.
    }).catch(function(error) {
      // An error happened.
    });
  • 1
    A Firebase User has a fixed set of basic properties—a unique ID, a primary email address, a name and a photo URL—stored in the project's user database, that can be updated by the user (iOS, Android, web). You cannot add other properties to the Firebase User object directly; instead, you can store the additional properties in your Firebase Realtime Database. This has been answered here https://stackoverflow.com/questions/31038611/add-extra-details-on-firebase-user-table by Frank van Puffelen – Vikram Palakurthi Mar 28 '18 at 15:19

1 Answers1

2

You can create a users endpoint and store custom user data in there.

function writeUserData(userId, name, email, imageUrl) {
  firebase.database().ref('users/' + userId).set({
    username: name,
    email: email,
    profile_picture : imageUrl,
    // Add more stuff here
  });
}

See https://firebase.google.com/docs/database/web/read-and-write#basic_write for more info.

Karl Taylor
  • 4,839
  • 3
  • 34
  • 62