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;
No description
No description
5 Replies
dev_codebug
dev_codebugโ€ข7d ago
Yes same issuell!
Amit Sharma
Amit Sharmaโ€ข2d ago
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.
joseph013318
joseph013318OPโ€ข16h ago
@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...
Amit Sharma
Amit Sharmaโ€ข15h ago
@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
joseph013318
joseph013318OPโ€ข14h ago
Yes @Amit Sharma that would be better. I too was facing the issue but implement the above hack to solve for the time being!

Did you find this page helpful?