Next.js Discord

Discord Forum

App router handle network request errors

Unanswered
Tonkinese posted this in #help-forum
Open in Discord
TonkineseOP
What are people using to handle error messages in app router?. I am thinking of having a global error state (maybe a context?) that I can trigger in a catch block of a failed network request. OR is there a better solution, maybe React Error Boundary.?

2 Replies

i just throw my errors from functions, and catch them and throw errors like notFound()
if i need to show it there, i just set a variable from the server component, which i listen for in a client component and toast it