Next.js enables a React application to be rendered on either the client-side or server-side, improving first-page load performance and capability. Integrating TrackJS will require an isomorphic adapter to inject either the browser agent or the node agent at runtime.
The pages/_app.js override of the Application enables us to attach the standard React componentDidCatch handler. The rest of the code is boilerplate from the Next.js documentation.
The pages/_error.js override allows us to attach a custom error handler for other classes of errors not caught by the _app.js handler. If this component initializes, an error has been caught by the Next.js framework, so we can capture it during getInitialProps. The rest of the code is boilerplate from the Next.js documentation, and can be customized to show the user friendly error messages.
Next.js is commonly augmented with Express for a data API. See the Express integration for details.