Can someone help me please???????
Answered
madbouy posted this in #help-forum
madbouyOP
Urgent
"use client";
import { useSession, signIn, signOut } from "next-auth/react"
export default function Component() {
const { data: session } = useSession()
//const { status, data} = useSession()
if (session) {
return (
#Unknown Channel
Signed in as {session.user.email} <br />
<button onClick={() => signOut()}>Sign out</button>
</>
)
}
return (
#Unknown Channel
Not signed in <br />
<button onClick={() => signIn()}>Sign in</button>
</>
)
}
"use client";
import { useSession, signIn, signOut } from "next-auth/react"
export default function Component() {
const { data: session } = useSession()
//const { status, data} = useSession()
if (session) {
return (
#Unknown Channel
Signed in as {session.user.email} <br />
<button onClick={() => signOut()}>Sign out</button>
</>
)
}
return (
#Unknown Channel
Not signed in <br />
<button onClick={() => signIn()}>Sign in</button>
</>
)
}
Answered by New Guinea Singing Dog
I think you'll need to pass it to useEffect() so it renders on the client side, a lot of the component is still rendered on the server even when using 'use client'
4 Replies
New Guinea Singing Dog
I think you'll need to pass it to useEffect() so it renders on the client side, a lot of the component is still rendered on the server even when using 'use client'
Answer
New Guinea Singing Dog
It's requesting it from the server but it doesn't exist server side
Also i think it should be
const {data: {session}} to properly deconstruct it