Will React Server Components kill off React Query?
React Server Components are very new. The React ecosystem is fascinating with its unique features. Most developers need to learn more about everything we can do with Server Components, myself included.
One of the maintainers of the best libraries for handling async server state, React Query, has given his opinion about Server Components and React Query:
https://tkdodo.eu/blog/you-might-not-need-react-query
I want to share some thoughts about this, and I hope it can help.
React Query on React ecosystem
React Query is incredible. It is a beneficial library for handling async server state. It is straightforward to use and has many features for managing loading error states and caching server states.
Before libraries like React Query, handling and caching data fetched from the server was much more challenging. You had to use useEffects and libraries like Redux, this complicated and added a lot of boilerplate code, which was unsuitable for code maintainability in the long run.
I have used React Query on some projects, and the programming experience has been effortless, and the apps have reached excellent user experience and fluidity.
React Query combined with React Server Components
With the arrival of React Server Components, a significant dilemma appears about whether the library is needed anymore.
It is a complicated answer. Even Dominik, one of the React Query's maintainers, said:
He said that we have many use cases when both technologies can live together. We will better understand how to combine both and the instances where we can apply both approaches or even others when we have only SPAs using React Query, as the community take the needed experience with it.
Conclusion
We have a long time of discovering and working with React Server Components to understand how most React apps can be developed.
As Front-End developers, we have an exciting time with all the new stuff in the React ecosystem. In addition, we can try different approaches to building outstanding projects and see what happens! The future is promising and wonderful! :)
I was inspired to write this post thanks to Dominik's article on his blog talking about all this.
https://tkdodo.eu/blog/you-might-not-need-react-query
Also, thanks to Adrian Bogdan's daily Next.js posts and his post where he shared Dominik's article above.
Thank you both. You are great!
I recommend you review the links and their content if you want to delve deeper into all this.
I hope you enjoyed the article.
Join my weekly newsletter, where I share articles to help you become a better front-end developer. You'll receive them directly to your inbox.
If you have any questions, feel free to contact me on LinkedIn, Edi Rodriguez, or leave a comment in the post.
See you in the next post.
Have a great day!