Next.js Discord

Discord Forum

How to enable Next.js error handler in Production Deployment

Unanswered
Turkish Angora posted this in #help-forum
Open in Discord
Avatar
Turkish AngoraOP
Next.js has this awesome feature, where it displays thrown errors in a closeable toast which can be opened up in a dialog.
The problem that it only works in dev mode. Is it possible to use this feature in prod?
Image

2 Replies

Avatar
Turkish AngoraOP
Image
Avatar
not-milo.tsx
No, that's meant to be shown only during development cause it might contain sensitive data. If you want to catch errors and show some useful information about them in production you have to use some kind of error boundary. The easiest option would be to use the error.js file convention that's part of Next since v13.

See: https://nextjs.org/docs/app/api-reference/file-conventions/error