Currently working on a Nextjs Project version 15.0.3 where I am utilizing next-auth.js for Authentication. During the setup of my app/api/auth/[...nextauth].ts
page, encountering the following ERROR:
Module '"next-auth"' has no exported member 'AuthOptions'. Did you mean to use 'import AuthOptions from "next-auth"' instead?
Binding element 'user' implicitly has an 'any' type.
Binding element 'account' implicitly has an 'any' type.
Binding element 'profile' implicitly has an 'any' type.
This appears to be a Typescript compatibility issue. Below is my [...nextauth.ts] code:
import NextAuth from "next-auth";
import GoogleProvider from "next-auth/providers/google";
export const authOptions = {
providers :
[
GoogleProvider({clientId : process.env.GOOGLE_CLIENT_ID , clientSecret : process.env.GOOGLE_CLIENT_SECRET}),
],
callbacks :{
async signIn({ user, account, profile }
{ return true; },
async redirect({ url, baseUrl }
{ return "/details" }
},
};
const handler = NextAuth(authOptions);
export {handler as GET , handler as POST};
Attempted importing Type {AuthOptions}from nextauth, however, the error persists. Additionally, have defined Types of SignIn and redirect as Promise<Boolean>
and Promise<String>
respectively.