Login data saved to database without explicit code - NextAuth, Prisma, and TRPC

I'm currently working on a T3 stack project, using NextAuth for authentication, Prisma as the ORM, and TRPC for API communication. I've set up the environment and Prisma client successfully. I encountered a peculiar issue while implementing the GitHub provider for login functionality. It seems like everything is working fine, as I can log in with GitHub successfully. However, when I checked the database using Prisma Studio, I noticed that the login information, including user, account, and session data, is being saved to the database. The confusing part is that I haven't explicitly written any code in the authentication configuration to save this data to the database. I expected NextAuth to handle the authentication process, but I didn't expect it to automatically persist the login data in the database. Has anyone else encountered a similar issue? How can I find out why this data is being saved without any explicit code to handle it? Is there any configuration or default behavior in NextAuth, Prisma, or TRPC that could be causing this? Any help or insights would be greatly appreciated! Thanks in advance.
1 Reply
cje
cje13mo ago
Create T3 App defaults to session/cookie auth, which requires a database because otherwise there is no way to check if the session is valid If you don’t want that, you can use JWT. But this comes with its own set of trade offs.