Recently, I delved into learning about authentication in Next.js using next-auth. Following the documentation diligently, I ended up with my
app/api/auth/[...nextauth]/route.ts
code snippet below:
import NextAuth, { type NextAuthOptions } from "next-auth";
import GithubProvider from "next-auth/providers/github";
import CredentialsProvider from "next-auth/providers/credentials";
export const authOptions: NextAuthOptions = {
providers: [
GithubProvider({
clientId: process.env.GITHUB_ID as string,
clientSecret: process.env.GITHUB_SECRET as string,
}),
CredentialsProvider({
name: "Credentials",
credentials: {
username: {
label: "Username",
type: "text",
placeholder: "John Smith",
},
password: {
label: "Password",
type: "password",
placeholder: "*******",
},
},
async authorize(credentials) {
// here data should come from the database
const user = { id: "1", name: "John", password: "pass" };
if (
credentials?.username === user.name &&
credentials.password === user.password
) {
return user;
} else {
return null;
}
},
}),
],
};
const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };
Encountering an error message within this file that states:
This expression is not callable.
Type 'typeof import("e:/Javascript/learnauth2/node_modules/next-auth/next")' has no call signatures.ts(2349)
The current version of next-auth
being used is 4.22.2
, while that of next
is 13.4.10
If anyone could offer assistance or guidance on this matter, it would be greatly appreciated.