Next.js Discord

Discord Forum

Help Needed with NextAuth

Unanswered
Basset Bleu de Gascogne posted this in #help-forum
Open in Discord
Avatar
Basset Bleu de GascogneOP
I am adding Github provider . I have added the folder structure
In my github login a a different route I created where I added the sessionProvider code
"use client"
import CamperVanPage from "../../../components/profiles"
import { SessionProvider } from "next-auth/react"
import { AppProps } from 'next/app'

export default function GithubLogin({
  Component,
  pageProps: { session, ...pageProps },
}: AppProps)

{
  <SessionProvider session={session}>
     <Component {...pageProps} />    
    </SessionProvider> 
}
Image

2 Replies

Avatar
Basset Bleu de GascogneOP
I created a component for login
import { useSession, signIn, signOut } from "next-auth/react"

export default function CamperVanPage() {
  const { data: session, status } = useSession()
  const userEmail = session?.user?.email

  if (status === "loading") {
    return <p>Hang on there...</p>
  }

  if (status === "authenticated") {
    return (
      <>
        <p>Signed in as {userEmail}</p>
        <button onClick={() => signOut()}>Sign out</button>
        <img src="https://cdn.pixabay.com/photo/2017/08/11/19/36/vw-2632486_1280.png" />
      </>
    )
  }

  return (
    <>
      <p>Not signed in.</p>
      <button onClick={() => signIn("github")}>Sign in</button>
    </>
  )
}
The error I am getting
Image