Next.js Discord

Discord Forum

Tanstack Query or Fetch?

Unanswered
StilauGamer posted this in #help-forum
Open in Discord
So before when working with plain React, I've used to work with Tanstack Query or React Query as some people might know it as.

In NextJS, I can tell that the fetch has async/await... Is there any point in using Tanstack Query or?
I know it is really good when it comes to mutations?

Basically:
- Click add, it adds an element.
- If failed, it will remove the element.
- If passed, it will keep the element.

I believe thats somewhat how it works, but what is the recommended choice?

7 Replies

@!=tgt nextjs is good with mutations
With Server Actions I believe?
yeah
@!=tgt yeah
Would you say its better to just use Server Actions and asynced fetching than using Tanstack Query? 🤔
I found tanstack query still useful when doing a infinite loading or fetching something after user interaction
@LuiGee I found tanstack query still useful when doing a infinite loading or fetching something after user interaction
From what I've seen...
Things I really like about how Tanstack Query works is the following:
- Getting the values, isLoading, error and data, etc
- Mutations
- Invalidating the cache and it auto refetches


Those are some things I really like about it, not sure how you would do it as simply as Tanstack Query does it..