Summary
This chapter taught us how React Query can complement our server-side-rendered applications.
You learned how React Query enables you to prefetch data on the server and send it to React Query on the client side. To do this, you got to know two patterns, initialData
and hydrate
. In the initialData
pattern, you prefetch the data on the server and pass it to the initialData
option in the useQuery
hook on the client side. In the hydrate
pattern, you prefetch your query on the server, dehydrate the query cache, and hydrate it on the client side.
In Chapter 8, Testing React Query Hooks and Components, we will focus on one of the things that will help you sleep better at night: testing. You will get to know how you can test your component, that is, using React Query, as well as some custom hooks for improving your developer experience.