Pending state not resolving!
When I am refreshing, the pending state of useSession hook is not resolving! Please if any one could help ๐
const {
data: session,
isPending, //loading state
} = authClient.useSession();
auth-client.js
import { createAuthClient } from "better-auth/react"
export const authClient = createAuthClient({
baseURL: process.env.NEXT_PUBLIC_APP_URL, // the base url of your auth server
})
export const { signIn, signOut, useSession, getSession } = authClient;


5 Replies
Yes same issuell!
I am dealing with a similar issue, after signIn the auth cookies is getting set immediately but the useSession stays null.
I am redirecting to home page after sigin and have a simple logic in client side header that if (session) then display user profile icon but that too not working, only when I do a hard refresh the the session object gets updated.
@Amit Sharma Yes same issue, but the update should fix the issue I guess. Check with better-auth 1.2.0 update, if still the same then you can try this code
https://github.com/better-auth/better-auth/issues/1006#:~:text=last%20week-,I%20have%20solution.,-When%20component%20with
GitHub
useSession()
not always triggering a state change ยท Issue #1006 ยท...Is this suited for github? Yes, this is suited for github To Reproduce Sign in with email and password Use useSession() in the following component: export function AuthLayout({ children }: AppLayou...
@joseph013318 Will try upgrading and then test again.
It didn't work. It has been asked on the github to share a screen recording of the issue so will record one and share to help them understand. Thanks @joseph013318
Yes @Amit Sharma that would be better. I too was facing the issue but implement the above hack to solve for the time being!