4 Replies
as far as I'm aware, this is a developer caused error, but i think your question is you want to have client errors to not disturb your page:
1. use something like sentry, you get the issues/problems when they happen so you can dedicate your time to fix them or find out what caused them
2. I'd look in here http://nextjs.org/docs/app/getting-started/error-handling for answers without having a third party option.
3. there's a package that I don't remember the name of it was, something react-error-boundary that might help!
4. to actually fix this error, don't use any types, you could pass the id as string in your query and do something like this:
but you need to have proper error handling on your client
Getting Started: Error Handling | Next.js
Learn how to display expected errors and handle uncaught exceptions.
Sentry
NextJS Error and Performance Monitoring
Detect & resolve errors in your Next.js application with Sentry. Learn how to get started with Next.js performance monitoring here.
handle error if no data in db with id
Pass “skip” instead of an args object when calling useQuery if the id is undefined. Or you can make the argument optional in your query function and just return early if no id is provided.