Firebase Authentication stores only a few things about a user: email, display name, photo URL and phone number (for phone sign-in). To save anything else – full name, mobile number, city, role – create a document for each user in Cloud Firestore, keyed by the user’s UID. This guide shows how to do that in Kotlin right after sign-up, and how to read and update it later.
Updated for 2026: this post used to use Java, the Realtime Database and old Gradle versions. It now uses Kotlin, coroutines and Firestore. The idea is the same in the Realtime Database – save under users/<uid>.
Page Contents
Before you start
- Set up email/password sign-up first: Firebase Authentication in Kotlin. This post reuses its
AuthRepository. - In the Firebase console, open Firestore Database → Create database. Pick a location close to your users.
Step 1: Add Firestore
dependencies {
implementation(platform("com.google.firebase:firebase-bom:35.0.2"))
implementation("com.google.firebase:firebase-auth")
implementation("com.google.firebase:firebase-firestore")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.10.2")
}Step 2: Describe the custom fields
Firestore can map a Kotlin data class to a document. Every property needs a default value so Firestore can create it when reading.
data class UserProfile(
val uid: String = "",
val fullName: String = "",
val email: String = "",
val phone: String = "",
val city: String = "",
val createdAt: Long = System.currentTimeMillis()
)Step 3: Save the profile right after sign-up
import com.google.firebase.Firebase
import com.google.firebase.auth.auth
import com.google.firebase.auth.userProfileChangeRequest
import com.google.firebase.firestore.firestore
import kotlinx.coroutines.tasks.await
class UserRepository {
private val auth = Firebase.auth
private val users = Firebase.firestore.collection("users")
suspend fun signUpWithProfile(
email: String,
password: String,
fullName: String,
phone: String,
city: String
): Result<UserProfile> = runCatching {
val user = auth.createUserWithEmailAndPassword(email, password).await().user!!
// Optional: also keep the name on the Auth user itself
user.updateProfile(userProfileChangeRequest { displayName = fullName }).await()
val profile = UserProfile(
uid = user.uid,
fullName = fullName,
email = email,
phone = phone,
city = city
)
users.document(user.uid).set(profile).await()
profile
}
}Using the UID as the document id means you can always find the right profile with users/{uid} – no searching needed.
Step 4: Read the profile
suspend fun getProfile(): Result<UserProfile?> = runCatching {
val uid = Firebase.auth.currentUser?.uid ?: return@runCatching null
Firebase.firestore.collection("users").document(uid)
.get().await()
.toObject(UserProfile::class.java)
}Step 5: Update one field
suspend fun updateCity(city: String): Result<Unit> = runCatching {
val uid = Firebase.auth.currentUser!!.uid
Firebase.firestore.collection("users").document(uid)
.update("city", city).await()
Unit
}Step 6: Protect the data with security rules
In Firestore → Rules, allow each signed-in user to read and write only their own document. Don’t leave the database in test mode, which lets anyone read everything.
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
}
}Which fields go where?
| Data | Where to store it |
|---|---|
| Email, password | Firebase Auth (passwords are never stored in your database) |
| Display name, photo URL | Firebase Auth profile (and optionally Firestore) |
| Full name, phone, city, role, preferences | Firestore users/{uid} document |
| Admin or role checks used by security rules | Firestore field or Auth custom claims (set from a server) |
Common problems
PERMISSION_DENIED when saving
Your rules don’t match: check the collection name and that the document id equals request.auth.uid.
The user is created but the profile is missing
The Firestore write failed after sign-up (often rules or no network). Show the error, and on next login create the document if getProfile() returns null.
Could not deserialize object
Give every property in the data class a default value, and make sure field names match the document.
Video tutorial (older Java version)
More Firebase guides
- Getting started: add Firebase to your Android project
- Firebase Authentication in Kotlin: sign up, log in and log out
- All Firebase tutorials

Hello I’m following your tutorial about this, but I got error when I launch the Register page
which type of error?
Thank you very much ! Your tutorial helped me a lot. Very complete !
Thank you☺
Excellent post. Keep posting such kind of information on your site. Kelila Lief Tseng
sure☺
Please visit the web pages we comply with, such as this a single, because it represents our picks in the web. Corrie Bailie Armillas
I have recently started a site, the information you offer on this site has helped me greatly. Thank you for all of your time & work. Fey Ronnie Scevor
☺
Thanks so much for the blog post.Thanks Again. Great.
I like and follow your site, thanks
Greetings! I know this is somewhat off topic but I was wondering if you knew
where I could locate a captcha plugin for my comment form?
I’m using the same blog platform as yours and I’m having trouble finding
one? Thanks a lot.!
Thank you for this beautiful article. It’s really a good article
The article is really excellent. Every time I read it, I get information again.
The best article I’ve read in a long time….
Hello there! This article couldn’t be written much better!
Looking through this article reminds me of my previous roommate!
He always kept preaching about this. I’ll forward this post to him.
Pretty sure he will have a very good read. Thank you for sharing!
Spot on with this write-up, I actually feel this
website needs a great deal more attention. I’ll probably be returning to see
more, thanks for the information!
Greetings! I know this is somewhat off topic but I was wondering if you knew
where I could locate a captcha plugin for my comment form?
I’m using the same blog platform as yours and I’m having trouble finding
one? Thanks a lot!
Run to my study.- By-and-by!- God’s will,
Wife. Nurse, where’s my daughter? Call her forth to me.
fantastic as well as incredible blog site. I really want to thanks, for offering us much better info.
Have a look at my web blog … One Nine Elms
I have been browsing online more than 3 hours lately, yet I by no means found any fascinating article like yours. It’s lovely price sufficient for me. Personally, if all site owners and bloggers made good content material as you probably did, the internet will be much more useful than ever before.|
thanks
Asking questions are actually good thing if you are not understanding anything entirely, but this paragraph gives good understanding even.
wow, awesome blog post.Really looking forward to read more. Really Cool.
Thanks 🙂