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 ([...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
// lifespan of session: 1 day
const expires = new Date();
expires.setDate(expires.getDate() + 1);

await prisma.session.create({
  data: {
    userId: user.id,
    expires,
    sessionToken: await hash(`${Math.random()}`),
  },
});

and return the user object afterwards.

In my custom login page I trigger NextAuth's signIn function like:
signIn("credentials", {
  redirect: false,
  username,
  password,
});

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...
Was this page helpful?