Handling tRPC or React Query errors on the client side.

Hey everyone,

I wanted to get prespective on how would you handle errors on the client side side when you're doing a query or mutation.

Let's say, it's a login form and the user somehow bypassed the built in input validation in HTML and browsers. How do I handle the error that has been thrown by zod on the server side and do some effect on the client side.

Do I catch the error inside
javascript onError(){}
and update some state with the error returned and then make the user know that the input value was wrong. What are other approaches to this?
Was this page helpful?