Getting no session from useSession() with NextAuth
I'm trying to implement a simple "username, password"-CredentialsProvider in my app. I'm using the standard prisma schema from create-t3-app, and just added a "password" prop to the User model.
Im am using the authorize function in the authOptions of NextAuth (
If that's true, I create a new session like
and return the user object afterwards.
In my custom login page I trigger NextAuth's signIn function like:
If given correct credentials, it's resolved without any errors, and a new session gets created in my db.
Still when I check for session data using
I am also missing the session cookie. I only have
Yes, I am providing the session using
Why is the useSession hook not getting my data? What am I missing?
My head is smoking...
Im am using the authorize function in the authOptions of NextAuth (
[...nextauth].ts) to check if a user with that username exists in my db, and also check if the password matches.If that's true, I create a new session like
and return the user object afterwards.
In my custom login page I trigger NextAuth's signIn function like:
If given correct credentials, it's resolved without any errors, and a new session gets created in my db.
Still when I check for session data using
useSession() I always end up getting null.I am also missing the session cookie. I only have
next-auth.csrf-token and next-auth.callback-url.Yes, I am providing the session using
SessionProvider in my pages/_app.tsx.Why is the useSession hook not getting my data? What am I missing?
My head is smoking...