NeuhljebTihomir
NeuhljebTihomir
BABetter Auth
Created by Risatoga on 3/7/2025 in #bug-reports
useSession not reactive?
import { authClient } from "@/lib/auth-client"; import { useEffect, useRef } from "react"; function useAuthSession() { const { data, isPending, error, //error object refetch, } = authClient.useSession(); // Track the latest value of isPending const isPendingRef = useRef(isPending); useEffect(() => { isPendingRef.current = isPending; }, [isPending]); useEffect(() => { if (isPending) { const timerNotify = setTimeout(() => { if (isPendingRef.current) { refetch(); // sends another get-session request to the server //authClient.$store.notify("$sessionSignal"); // or this poke store to trigger a re-render } }, 2500); // after 2.5 seconds of pending, force resetting client store const timerReload = setTimeout(() => { if (isPendingRef.current) { window.location.reload(); } }, 5000); // after 5 seconds of pending, reload the page return () => { clearTimeout(timerNotify); clearTimeout(timerReload); }; } }, [isPending]); return { data, isPending, error, }; } export default useAuthSession;
14 replies
BABetter Auth
Created by Risatoga on 3/7/2025 in #bug-reports
useSession not reactive?
Solution is to replace authClient.useSession() with custom hook useAuthSession():
14 replies
BABetter Auth
Created by Risatoga on 3/7/2025 in #bug-reports
useSession not reactive?
This is issue a lot of people face: https://github.com/better-auth/better-auth/issues/1006
14 replies
BABetter Auth
Created by NeuhljebTihomir on 12/27/2024 in #help
What about old expired rows? Who should clean them?
Yeah, thank you
5 replies
BABetter Auth
Created by Sanjay Kholiya on 11/28/2024 in #bug-reports
In EmailOTP Plugin, the user is notVerified after signIn.
You mean emailVerified field?
5 replies