We are building a social network and as part of user onboarding, we want to assign each user a unique username
The only currently defined use case for the username is the profile URL, i.e. if your username is
gajus, then your profile is accessible through
foo.xyz/@gajus. Because of this requirement, we chose to force usernames that are URL safe.
We are currently considering 4 ways of assigning usernames:
Username as entered by username
This delegates responsibility of finding unique & available username to the end user.
As username concept is not a center-piece of our social network, we do not want to make it part of sign up flow. We want the initial username to be generated for user.
Not an option.
Do not assign usernames
Refer to user profiles by their numeric ID until user picks a username (
We believe this makes the profile URLs feel lacking personality and it removes the guarantee that every user has a unique username (which is useful for simplifying the system design).
Generating a unique username using name + random ID
The next alternative we are considering is simply deriving user's username from their first name and last name (user already makes this information public) and adding a random ID to the end, i.e.
- If user's first name is Gajus and
- their last name is Kuizinas,
- their username is
where "dk1f" is a random ID.
(Logic for ensuring that the generated username is unique is outside of the scope of the question.)
This is the most simple to implement and easy to predict option.
Generating a unique username from components of supplied data + random ID as a fallback
Once again, user supplies their name as part of onboarding and consent to it being public. We therefore can attempt to assign user a "friendly" username, i.e. the kind of username that people would want to have in a professional network, e.g.
- and other combinations we think of
falling back to
gajus_dk1f (where "dk1f" is random ID).
The only downside of the latter implementation is that it adds unpredictability, i.e. if two users sign up and look at each others URLs, they might follow a different pattern, causing confusion about how the usernames were chosen.
Which of these provides the best user experience?