Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding new data to firebase users

I want to add a new data to firebase authentication which has data like displayname, phone number, image. But i want to add more such gender, birthday and more. is it possible to add new?

like image 433
Wahyu Setiawan Avatar asked Jul 12 '26 12:07

Wahyu Setiawan


2 Answers

There is no way to add arbitrary additional data to Firebase Authentication user profiles. If you want that, consider using the Firebase Realtime Database (or Cloud Firestore) for storing the additional information.

This approach has been covered in quite a few questions in the past, so I'll link you to those:

  • Firebase: setting additional user properties
  • Add extra User Information with firebase
  • How do I link each user to their data in Firebase?
  • Swift & Firebase - How to store more user data other than email and password?
  • Store additional information during registration with Firebase in Android
  • How to add additional information to firebase.auth()

Since a few weeks ago you can add small bits of information to the Firebase Authentication user profile. While this might sound like what you need, it is explicitly not meant for storing user metadata such as you need. Instead this is intended for storing so-called claims: properties about the user that you then access in the security rules. See the documentation for setting custom claims.

like image 152
Frank van Puffelen Avatar answered Jul 15 '26 01:07

Frank van Puffelen


I had the same problem when introducing user roles for authorization in my React with Firebase application. Somehow I wanted to be able to pass a roles property to the authenticated user, but found myself again in Firebase's restrictive framework of doing it their way.

I found a way around it by (1) managing users myself in the Firebase database and (2) merging the authenticated user with the database user when the application loads. Then I am able to add additional user properties (e.g. roles) to my database user, because it will be merged with the authenticated user anyway.

If you are interested in this approach, checkout this tutorial.

like image 26
Robin Wieruch Avatar answered Jul 15 '26 03:07

Robin Wieruch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!