yornaath / batshit

A batch manager that will deduplicate and batch requests for a certain data type made within a window. Useful to batch requests made from multiple react components that uses react-query
https://batshit-example.vercel.app/
MIT License
129 stars 4 forks source link

useSuspenseQuery only fetches on client side #15

Open TommySorensen opened 6 months ago

TommySorensen commented 6 months ago

It seems like that when using the Tanstack Query hook useSuspenseQuery it only fetches on client side and streaming actually never happens. Would it not be possible to make an option in Batshit to use the cache (https://react.dev/reference/react/cache) in React instead of the windowMs so you know on serverside what need to be batched? An example of streaming with Tanstack Query would be https://tanstack.com/query/latest/docs/framework/react/examples/nextjs-suspense-streaming

yornaath commented 2 months ago

Hmmm will have to take a closer look to see what is happening there.

yornaath commented 2 months ago

But do you want to batch requests on the server when streaming since you want low time to first byte? Meaning you want suspense wrapped components to stream in as soon as the request is done, but with batching you would get some overhead. Im not entirely sure thats a good fit for this library.