Next.js Discord

Discord Forum

How to redirect user from default mutation options with react-query v5 and nextjs 14?

Unanswered
Brown bear posted this in #help-forum
Open in Discord
Brown bearOP
Everytime any mutation or query fails on my application, I need to check for an specific error and then redirect my user accordingly.

I'm wrapping my layout.tsx with the queryClient and redirecting the user on the onError handler of the mutation options, but that doesn't seem to work. How can I achieve that?

0 Replies