homeresume
 
   

Next.js app in production

Published March 6, 2022Last updated January 27, 20231 min read

The following things should be considered when Next.js app is running in production

  • Error tracking is crucial in the production environment, proactively fixing the errors leads to a better user experience. Sentry is one of the error tracking services, Next.js app can be easily integrated with it.
npm i @sentry/nextjs
npx @sentry/wizard -i nextjs

Set SENTRY_AUTH_TOKEN environment variable, token can be found at Settings Account API Auth Tokens.

User feedback can be collected via the report dialog.

// sentry.client.config.js
Sentry.init({
// ...
beforeSend(event, hint) {
// Check if it is an exception, and if so, show the report dialog
if (event.exception) {
Sentry.showReportDialog({
eventId: event.event_id,
// other fields can be overridden if they need to be localized
});
}
return event;
},
//...
});
  • Intl API is not supported in all browsers.

  • localStorage API is not available when cookies are blocked.

 

© 2023