Login in with credentials with next auth

Hello! I'm trying to learn how to use next auth with credentials. So i got this next auth settings:
export const authOptions: NextAuthOptions = {
  session: {
    strategy: "jwt",
  },
  providers: [
    CredentialsProvider({
      type: "credentials",
      credentials: {},
      async authorize(credentials, req) {
        const { email, password } = credentials as {
          email: string;
          password: string;
        };
        // perform you login logic
        // find out user from db
        const user = await prisma.user.findFirst({
          where: {
            email: email,
            password: password,
          },
        });
        if (!user) {
          throw new Error("bad user");
        }
        return user;
      },
    }),
  ],
};

export default NextAuth(authOptions);
And i'm using this function to login
  const handleSubmit = () => {
    try {
      signIn("credentials", {
        email: emailValue,
        password: passwordValue,
        redirect: false,
      });
    } catch (error) {
      console.log(error);
    }
  };
, signIn is imported from next-auth. And everything seems to be okay, but that authentication is not persisting. I mean, when i login and go to index file and again to login page, I'm again unauthenticated. Whats the problem?
Was this page helpful?