authClient.signIn.email onSuccess behaviour

Hello,

I'm using better-auth with react+ vite and Hono. All the your documentation shows using authClient.signIn.email's onSuccess for redirect examples. but when I redirect to a page that checks for session it can fail and redirect back to login. AFAIK it takes a moment for the browser to save the cookie and this is causing the redirect.

on my App page I use this ( which is actually just ripped off from a Better-T-Stack's React Router/Hono/better-auth example)
 useEffect(() => {
    if (!session && !isPending) {
      navigate("/login");
    }
  }, [session, isPending, navigate]);


is this expected?

i've resorted to using callbackURL for now as this works consistently. I've added some screen shots of my code for examples. is this normal and someting i have to deal with, or bug?

thanks
image.png
image.png
Was this page helpful?