Cascade is based on T3 app meaning that it uses NextAuth.js under the hood. Docs are here.
This documentation is a brief overview of what is put on top of NextAuth.js to make it work with Cascade. We will focus on interesting parts!We extend the Session object with some additional types to make it work with Cascade. We need to add role and planId to the user object.
In callbacks we need to fetch the user from the database and add the role and planId to the session object. This is done to make sure that whenever you are working with Session from NextAuth.js you have all the necessary information about the user.
Cascade comes with Discord & Google providers out of the box. You can easily add more providers by following the NextAuth.js documentation.
providers: [ DiscordProvider({ clientId: env.DISCORD_CLIENT_ID!, clientSecret: env.DISCORD_CLIENT_SECRET!, }), GoogleProvider({ clientId: env.GOOGLE_CLIENT_ID!, clientSecret: env.GOOGLE_CLIENT_SECRET!, }), /** * ...add more providers here. * * Most other providers require a bit more work than the Discord provider. For example, the * GitHub provider requires you to add the `refresh_token_expires_in` field to the Account * model. Refer to the NextAuth.js docs for the provider you want to use. Example: * * @see https://next-auth.js.org/providers/github */ ],