blogr-nextjs-prisma
blogr-nextjs-prisma copied to clipboard
Next-auth/client not found
I think Next-auth change the way it work.
https://github.com/nextauthjs/next-auth#add-react-hook
You have to replace the import with this :
// import { useSession, signIn, signOut } from "next-auth/client"
import { useSession, signOut } from "next-auth/react"
So you got the session with this :
const { data : session, status } = useSession();
And you have to setup a session provider on the top component.
import { AppProps } from "next/app";
import { SessionProvider } from "next-auth/react"
const App = ({ Component, pageProps: { session, ...pageProps } }: AppProps) => {
return (
<SessionProvider session={session}>
<Component {...pageProps} />
</SessionProvider>
);
};
export default App;
Tell me if i am wrong but it work for me
I ran into this on windows as soon as Next-Auth was integrated
./components/Header.tsx:5:0 Module not found: Can't resolve 'next-auth/client' 3 | import Link from 'next/link'; 4 | import { useRouter } from 'next/router';
5 | import { signOut, useSession } from 'next-auth/client'; 6 | 7 | const Header: React.FC = () => { 8 | const router = useRouter();
Hey man did you read what I post ? I said to import from
import { useSession, signOut } from "next-auth/react"
You have to replace the import with this :
This all worked for me. Saw one more notice, need to update this line to be if (status) {
now.