Hey Max!
If the user-related data is not sensitive, you can utilize app_metadata
inside your user’s profile (see here). This can eliminate the need for another database. But if the data is sensitive, here is some information regarding your questions.
- Using
sub
as the external ID is a good approach, as the sub/user_id is guaranteed to be unique, as mentioned here in the Auth0 docs and from another community post. - If I understand your question correctly, do you want the user who has logged in/signed up also to have an entry inside your database? If so, you can utilize Auth0 Actions to accomplish this:
- Login / Post Login
- This action will run after a user authenticates into your application.
- You can utilize this in the following manner:
- The
event
parameter is used to acquire the user’ssub
. - Use it to query your database
- If there are no results, then proceed to create this user entity in your database
- The
- Login / Post Login
Let me know if this helps!