Next.js Discord

Discord Forum

Can someone help me please???????

Answered
madbouy posted this in #help-forum
Open in Discord
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>
</>
)
}
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'
View full answer

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