React Query / Better Auth / Next js

I have a doubt, I'm using better auth on next js, and I'm using react query, and Hono for the backend, where I have the middleware working, and all the queries made client side (react-query), are working, as I believe that cookies and tokens are automatically sent in the request,
but now I'm learning how to use prefetch queries, on server side, and all requests fail because of lack of authentication. what would be the correct way to pass the cookie, or the session (whichever is necessary), through the server action to the middleware catch session and user
functions to useGetRentProperties

import { useQuery } from "@tanstack/react-query";
import { client } from "@/lib/hono";

export const useGetRentProperties = () => {
  const query = useQuery({
    queryKey: ["properties"],
    queryFn: async () => {
      const response = await client.api.properties.$get();

      if (!response.ok) {
        throw new Error("Failed to fetch transactions!");
      }

      const { data } = await response.json();
      return data;
    },
  });
  return query;
};


server action
export async function getProperties() {
  const response = await client.api.properties.$get();

  if (!response.ok) {
    throw new Error("Failed to fetch properties!");
  }

  const { data } = await response.json();
  console.log(data);

  return data;
}


const RentPage = async () => {
  // const { onOpen } = useNewRentHouse();
  const queryClient = new QueryClient();

  await queryClient.prefetchQuery({
    queryKey: ["properties"],
    queryFn: getProperties,
  });

  return (
          <HydrationBoundary state={dehydrate(queryClient)}>
            <PropertiesGrid />
          </HydrationBoundary>
  );
};

export default RentPage;
Was this page helpful?