Replies: 1 comment
-
There is a loading state, when Your two options: // 1.
const { data: session } = useSession();
const userEmail = session?.user.email; // <-- Notice the question mark. This is optional chaining
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining
// 2.
const { data: session, status } = useSession()
const userEmail = status === "authenticated" ? session.email : "" In both cases, you have to handle that loading state in your UI. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Question 💬
I am trying to access the user email with useSession() hook v4:
but I got this error:
Before upgrading to v4, I managed to get the email with v3 syntax
const {session} = useSession()
What's the correct way to get the user email with useSession() v4?
How to reproduce ☕️
n/a
Contributing 🙌🏽
No, I am afraid I cannot help regarding this
Beta Was this translation helpful? Give feedback.
All reactions