FrancyMak
Explore posts from serversBABetter Auth
•Created by Glen Kurio on 4/29/2025 in #help
useSession returns null for data in Next.js
Better solution for this, is to get the session from auth.api in your api route if you need some sort of data when the components mounts and you can't / don't want to wrap it
24 replies
BABetter Auth
•Created by Glen Kurio on 4/29/2025 in #help
useSession returns null for data in Next.js
Yes
24 replies
BABetter Auth
•Created by Glen Kurio on 4/29/2025 in #help
useSession returns null for data in Next.js
why nobody in the better auth discord has a solution for this
24 replies
BABetter Auth
•Created by Glen Kurio on 4/29/2025 in #help
useSession returns null for data in Next.js
the only way, from what i can see, is to fetch the session somewhere else and pass it as a prop
24 replies
BABetter Auth
•Created by Glen Kurio on 4/29/2025 in #help
useSession returns null for data in Next.js
but i recently switched to better-auth which is giving me this issue
24 replies
BABetter Auth
•Created by Glen Kurio on 4/29/2025 in #help
useSession returns null for data in Next.js
with next-auth it was working fine because their useSession is immediate
24 replies
BABetter Auth
•Created by Glen Kurio on 4/29/2025 in #help
useSession returns null for data in Next.js
This is my case, i think it's quite a common case, i have a sort of email reader which should give me the email list when the it mounts, but the user from useUser (bascially useSession > session.data.user) is null
24 replies
BABetter Auth
•Created by Glen Kurio on 4/29/2025 in #help
useSession returns null for data in Next.js
Yeah in a client component
24 replies
BABetter Auth
•Created by Glen Kurio on 4/29/2025 in #help
useSession returns null for data in Next.js
or please tell us how to use it
24 replies
BABetter Auth
•Created by Glen Kurio on 4/29/2025 in #help
useSession returns null for data in Next.js
i will get null when the page mount, so that hook is useless in this way
24 replies
BABetter Auth
•Created by Glen Kurio on 4/29/2025 in #help
useSession returns null for data in Next.js
in a client component
24 replies
BABetter Auth
•Created by Glen Kurio on 4/29/2025 in #help
useSession returns null for data in Next.js
That's the thing, if i need the user session
24 replies
BABetter Auth
•Created by FrancyMak on 4/20/2025 in #help
useSession weird behaviour
The argument of type ‘string | undefined’ is not assignable to the parameter of type ‘string’.
The type ‘undefined’ is not assignable to the type ‘string’.
16 replies
BABetter Auth
•Created by FrancyMak on 4/20/2025 in #help
useSession weird behaviour
No because user is null
16 replies
BABetter Auth
•Created by FrancyMak on 4/20/2025 in #help
useSession weird behaviour
so i can't conditionally call hooks
16 replies
BABetter Auth
•Created by FrancyMak on 4/20/2025 in #help
useSession weird behaviour
I already have that hook but the user returns null
16 replies
BABetter Auth
•Created by FrancyMak on 4/20/2025 in #help
useSession weird behaviour
export function Notifications() {
const user = useCurrentUser()
const { data: notifications, refetch } = useNotificationsQuery(user.id)
16 replies
BABetter Auth
•Created by FrancyMak on 4/20/2025 in #help
useSession weird behaviour
Ok but the user will be null anyway
16 replies
BABetter Auth
•Created by FrancyMak on 4/20/2025 in #help
useSession weird behaviour
Here you go 🙂
16 replies