Reputation: 1715
I'm creating my first project in React/Next.js, using NextAuth.js for Auth-N. I'm loosely following along with the Getting Started guide on the NextAuth website, and I've created a [...nextauth].js page that contains the following code:
import NextAuth from 'next-auth';
import GoogleProvider from 'next-auth/providers/google';
export default NextAuth({
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
})
]
})
I'm using the Provider in a Header.js page that contains the following code:
...
import {useSession, signIn, signOut} from 'next-auth/react';
const Header = () => {
const { data: session } = useSession()
...
return (
<header className="border-b border-gray-100 dark:border-gray-700">
<div className="container mx-auto px-4 sm:px-6 py-4 flex justify-between items-center">
<Logo />
<div className={"flex items-center space-x-1 sm:space-x-2"}>
{!session ? (
<button type="button" onClick={() => signIn()} className="bg-blue-700 text-white px-4 py-2 rounded-md focus:outline-none focus:ring-4 focus:ring-blue-600 focus:ring-opacity-50 whitespace-nowrap">Sign in</button>
) : (
<button type="button" onClick={() => signOut()} className="bg-blue-700 text-white px-4 py-2 rounded-md focus:outline-none focus:ring-4 focus:ring-blue-600 focus:ring-opacity-50 whitespace-nowrap">Sign out</button>
)}
</div>
</div>
</header>
)
};
export default Header;
However, when I spin up my site with 'npm run dev' and try to login, I get the following error:
Server Error
Error: Package subpath './providers/google' is not defined by "exports" in /Users/tysont/Workspace/brightnote/node_modules/next-auth/package.json
I'm using NextAuth 4.0.6 and I don't see a /google specific export mentioned anywhere in the NextAuth package.json locally or on GitHub. Should there be? What am I missing?
Upvotes: 0
Views: 763
Reputation: 24
Upvotes: 0