NextAuth add additional property to session

Hi, I am trying to add "plan" to the session object that I can receive with the useSession() hook.

I am using create-t3-app

...
export const authOptions: NextAuthOptions = {
  callbacks: {
    session: ({ session, user }) => {
      console.log({ user, session });
      return {
        ...session,
        user: {
          ...session.user,
          plan: user.plan,
          id: user.id,
        },
      };
    },
  },
...


But it is throwing an typescript error: TS2339: Property 'plan' does not exist on type 'AdapterUser'.

It is working fine tough. Any tips?
Solution
import NextAuth from "next-auth"

declare module "next-auth" {
  /**
   * Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context
   */
  interface Session {}
}


This already exists somewhere in a t3 app
Was this page helpful?