Next.js Discord

Discord Forum

Type Error for Google Providers (and providers in general)

Answered
Mud-daubers posted this in #help-forum
Open in Discord
Mud-daubersOP
I've been looking at many different tutorials and docs online, however for some reason keep getting the error: "TypeError: next_auth_providers_googleWEBPACK_IMPORTED_MODULE_1 is not a function". For reference, the code for my handler is:
import NextAuth from "next-auth/next";
import GoogleProvider from "next-auth/providers/google";
import connectDB from '../../../utils/database'

const handler = NextAuth({
    providers: [
        GoogleProvider ({
            clientId: process.env.GOOGLE_ID,
            clientSecret: process.env.GOOGLE_SECRET
        })
    ],
    callbacks: {
        async session({session}) {
            return session
        },
        async signIn({profile}){
            console.log(profile)
            try {
                await connectDB();
                return true;
            } catch (error) {
                console.log(error)
                return false
            }
            
        }
    }
})

export {handler as GET, handler as POST};
. Ive been trying to fix this for a while now ;/ any help will be very much appreciated! 🙂
Answered by Mud-daubers
the solution was to put .default in front of both "NextAuth" and "GoogleProvider". ;o
View full answer

1 Reply

Mud-daubersOP
the solution was to put .default in front of both "NextAuth" and "GoogleProvider". ;o
Answer