Search code examples
next.jsnext-auth

Does Next-Auth allow for users who sign in through socials to get a unique username?


While I would like to implement both a regular username and password sign in, I would also like to allow users to signup/signin with a social account like Google.

I am planning on using NextAuth

If they sign up with Google, is there a way to make them add a unique username and have it tied in with NextAuth?

My app would require users to have unique usernames for profile reference


Solution

  • There is no ability to directly connect a username to the GoogleProvider in NextAuth.

    You should store your account information in your database as generic accounts. Subsequently, the user would have the ability to specify a username no matter how they signed in. For example a pseudo database may look like:

    User Database
         - Accounts
                   - <ID>
                         - username: "x"
                         -{"SignInProvider": "GoogleProvider", "clientId": "x", "clientSecret": "x"}