© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Theo's Typesafe CultTTC
Theo's Typesafe Cult•3y ago•
4 replies
alts

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,
        },
      };
    },
  },
...
...
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'.
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 {}
}
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
Jump to solution
Theo's Typesafe Cult banner
Theo's Typesafe CultJoin
26,131Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

NextAuth session injection
Theo's Typesafe CultTTCTheo's Typesafe Cult / questions
2y ago
NextAuth session storage
Theo's Typesafe CultTTCTheo's Typesafe Cult / questions
4y ago
NextAuth Session Typescript checks
Theo's Typesafe CultTTCTheo's Typesafe Cult / questions
2y ago