SSR with react query

Hey I’m trying to add SSR in my project created with react-query

What i have done so far is that I have created an functional method called beforeSSR and when defining each component we can attach this method for example

HomePage.beforeSSR()
export const HomePage

and when the server is called it first checks wether the route have this beforeSSR method defined if it is defined we call it

Inside this method I have added the prefetchLogic via react-query and the data I’m storing into schemas/resource

Im using @data-client library with a custom patch to store the initial state and using its DataProvider and useSuspense

Is this a good way to implement SSR using react-query or there are some better ways I can achieve it any guidance would be helpful

Thanks
Was this page helpful?