Next.js
Server-Side Monitoring for Next.js Applications
What it is for
The official DockRay integration for Next.js lets you monitor errors and performance in Next.js applications. It automatically reports server-side, Edge Runtime, and middleware errors, with optional JavaScript error reporting from the browser.
The integration supports Next.js 14 and 15 and applications using both the App Router and Pages Router.
Next.js Error Monitoring
DockRay integrates with Next.js error reporting and lets you collect issues occurring across different parts of your application.
Errors can be monitored in areas including:
- Server Components,
- Route Handlers,
- Server Actions,
- streaming rendering,
- Pages Router and API Routes,
- middleware and Edge Runtime.
Events can include information about the router, route pattern, route type, and rendering source, making it easier to identify where an issue occurred.
Performance Monitoring
DockRay lets you monitor request processing times and transactions in your Next.js application. The frequency of data collection can be controlled using a sampling rate.
JavaScript Error Monitoring
You can optionally enable reporting of JavaScript errors that occur in the user's browser. Events are first sent to an endpoint in your own Next.js application and then forwarded to DockRay.
This ensures that your project's private key remains exclusively on the server and is never exposed in the application's public code.
Edge Runtime and Middleware
The integration provides a separate entry point designed for the Edge Runtime environment. This allows errors occurring in middleware and other parts of the application running on the Edge to be reported.
Privacy and Security
Sensitive headers such as Authorization, Cookie, Set-Cookie, and X-Api-Key are removed from reported data.
Sending the IP address and user agent is optional and must be enabled separately in the configuration.
Vercel Integration
For applications deployed on Vercel, DockRay can automatically use deployment environment and application version information, making it easier to distinguish production from preview deployments.
Installation
How to use it
The integration reports exceptions on its own. This is for the reports you send deliberately.
import { withRay } from '@dockcodes/dock-ray-next';
export default withRay(async function handler(req, res) {
const order = await processOrder(req.body);
res.status(200).json({
success: true,
order
});
});
Knowledge base articles
Other integrations
All integrationsWordPress and WooCommerce Plugin
Explore integrationModule for PrestaShop 1.7.8+, 8.x, and 9.x
Explore integrationPlugin for Joomla 4, 5, and 6
Explore integrationModule for Drupal 10.2+ and 11
Explore integrationModule for Magento 2.4 and Adobe Commerce
Explore integrationPackage for Laravel 10+
Explore integrationBundle for Symfony 6.4+
Explore integrationLibrary for PHP Applications
Explore integrationStart Monitoring
Connect your first application and get full visibility into what’s happening in production.