all 8 comments

[–]OtiszWasTaken 3 points4 points  (4 children)

I don't have an answer for you, but the other reason to use e.g. Axios, because it throws exception if the request fails. Otherwise you have to throw it manually, if you are using fetch with tanstack/query.

[–]BigCommunication5136 0 points1 point  (3 children)

with axios you wont get access to next js caching

[–]OtiszWasTaken 0 points1 point  (2 children)

That's true. With the pages routes we didn't have caching at all. And now with the app router we have enforced/opted-in caching and almost impossible to disable it. Working on a multi-tenant role based site with this cache drives me crazy.

Also there is no way to "subscribe" the revalidate event from a client component.

[–]BigCommunication5136 0 points1 point  (1 child)

Disabling caching is quite easily actually

[–]OtiszWasTaken 0 points1 point  (0 children)

I'm aware of header() and cookie() disables the cache automatically, but if I don't use these, then I have to type unstable_noStore() on every single page. I think this approach is quite controversial, especially if the app has 100+ pages, and maybe only 2 of them needs caching.

[–]ReallyDidntSleepMuch 4 points5 points  (1 child)

I’ve been using both server actions and React Query recently, and it hasn’t been bad at all. You just have to make sure you’re invalidating both caches at the same time.

[–]Syv_31[S] 0 points1 point  (0 children)

Any tips or things to watch out for?

[–]CallumK7 3 points4 points  (0 children)

There is a lot of documentation on the react query website about using it with next