When one creates a user in Firebase Auth, Firebase Auth generates a userId using some internal algorithm.
Is their a way to use the same logic/function to generate userId but without actually creating a user? If yes, how?
When one creates a user in Firebase Auth, Firebase Auth generates a userId using some internal algorithm.
Is their a way to use the same logic/function to generate userId but without actually creating a user? If yes, how?
It's not entirely clear what your concern is, but there are a few facts to know that might help you move forward.
When Firebase Authentication creates a new user, the ID it generates for that user is just a random string of a certain length. There is no meaning to that string at all - it is just unique.
When Firestore creates a new document with a random ID, it is also just a random string. There is no meaning to that string at all - it is just unique.
The random IDs above have nothing to do with each other. It is merely conventional for developers to use the Auth user ID as a document ID because it makes user data easy for code to find and protect those documents with security rules.
If you want to generate an ID for a user before it's actually created in Firebase Authentication, you are free to do so, but you cannot use the mobile or web client SDK to create the user with that ID. You will have to use the Firebase Admin SDK on your backend to create the user.
Again, it doesn't really matter how you create any of these IDs, as long as they are unique (the longer the random string, the less likely there is of a collision) and they contain only valid characters (alphanumerics). There is no logic involved that you have to follow. Firebase just provides default behavior as a convenience.