cannot read undefined session.status
Answered
Hoopoe posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
HoopoeOP
Code:
const session = useSession({
required: true,
});
if (!data || session?.status !== "authenticated") return <>Loading...</>;
return (....)
17 Replies
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
HoopoeOP
this is in
next build
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
HoopoeOP
anyone
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Hook-billed Kite
need a larger code sample
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
HoopoeOP
welp, i found out that the issue was i didn't use SessionProvider
Answer
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Hook-billed Kite
https://github.com/nextauthjs/next-auth-v5-example/blob/main/app/client-example/page.tsx
Are you providing a Session provider to that component?
Are you providing a Session provider to that component?
check that repo out it has a bunch of helpful stuff to reference when setting up auth
i used that recetnly
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
HoopoeOP
im at v4
not v5
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Hook-billed Kite
ohh okay gotcha
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
HoopoeOP
i dont want to upgrade to a beta version rn though
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Hook-billed Kite
i dont blame u
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
HoopoeOP
is it stable enough?
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Hook-billed Kite
i guess we;ll find out 😂
i havent deployed yet im still developing my app
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
HoopoeOP
oh cool
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Hook-billed Kite
it was just kinda hard to figure out role based auth cuz its kinda sparse