React Query or SWR with next js 13 or another?
Unanswered
American Sable posted this in #help-forum
American SableOP
Hello, I'm trying to learn React Query with Next JS 13, but it's a bit hard.
Is React Query the best way to work with fetch and fetching data with client and server components, so it will update in realtime from database to the site directly?
Or how do you guys work?
Is React Query the best way to work with fetch and fetching data with client and server components, so it will update in realtime from database to the site directly?
Or how do you guys work?
6 Replies
It's not related to using Next 13 or not, as using SWR or React Query is traditionnal SPA pattern. You have client-side code that sends requests to API. What Next 13 brings is the possibility to do the same in a "server component" that is basically a very smart HTML template.
The point of SWR or React Query is to manage complex stuff like caching for you client-side
which is best is up to you, I am totally fine with SWR that I find simple but smart enough.
Haven't had the chance to use React Query, it feels like a huge beast.
Some of those libraries support server-side rendering, meaning that in a Client Component, which is rendered both on the server and the client (their name is bad 🤷 ), some lib can fetch data during the server render, some only during the client render
but this is not really the spirit in Next.js, which provides it's own mechanism for server-side data fetching (RSC namely)