can't get session after verify magic link token

React.useEffect(() => {
    const handleTokenVerification = async (token: string) => {
      const { error, data } = await verifyToken(token);

      if (data) {
        console.log({ data });

        // Force a fresh session check after successful verification
        const freshSession = await getSession();
        if (freshSession) {
          session.refetch();
        }
      } else if (error?.status === 0) {
        setError(true);
      }
    };

    if (token && !session.data && !session.isPending) {
      handleTokenVerification(token);
    }
  }, [token, session]);

this is my config. the console.log shows that I get the data, but when i try to getSession or refetch.session, it always return null. Im using bun as runner
Was this page helpful?