You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: rum_nextjs/README.md
+47-53Lines changed: 47 additions & 53 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,31 +1,30 @@
1
1
# RUM Browser Monitoring - NEXTJS integration
2
2
3
-
> **Note**: This integration is in beta. Features and configuration may change.
4
-
5
3
## Overview
6
4
7
-
With the Datadog RUM Next.js integration, resolve performance issues quickly in Next.js applications by:
8
-
9
-
- Debugging the root cause of performance bottlenecks, such as a slow server response time, render-blocking resource, or an error inside a component
10
-
- Automatically correlating web performance data with user journeys, HTTP calls, and logs
11
-
- Alerting your engineering teams when crucial web performance metrics (such as Core Web Vitals) fall below a threshold that results in a poor user experience
5
+
The Datadog RUM Next.js integration provides framework-specific instrumentation to help you monitor and debug Next.js applications. This integration adds:
12
6
13
-
Monitor your Next.js applications from end-to-end by:
7
+
-**Automatic route change detection** for both the App Router and Pages Router
8
+
-**View name normalization** that converts dynamic route segments into parameterized names (e.g. `/users/123` becomes `/users/[id]`)
9
+
-**Error reporting** with built-in components for Next.js error boundaries
10
+
-**Full-stack visibility** by correlating frontend performance with backend traces and logs
14
11
15
-
- Tracking and visualizing user journeys across your entire stack with automatic route change detection for both the App Router and Pages Router
16
-
- Automatically normalizing dynamic route segments into parameterized view names (e.g. `/users/123` to `/users/[id]`)
17
-
- Analyzing and contextualizing every user session with attributes such as user ID, email, name, and more
18
-
- Unifying full-stack monitoring in one platform for frontend and backend development teams
12
+
Combined with Datadog RUM's core capabilities, you can debug performance bottlenecks, track user journeys, monitor Core Web Vitals, and analyze every user session with context.
19
13
20
14
## Setup
21
15
22
-
Start by setting up [Datadog RUM][2] in your Next.js application. If you're creating a new RUM application in the Datadog App, select Next.js as the application type. If you already have an existing RUM application, you can update its type to Next.js instead. Once configured, the Datadog App will provide instructions for integrating the [RUM-Next.js plugin][8] with the Browser SDK. If Next.js is not available as an option, select React and follow the steps below to integrate the plugin manually.
16
+
Start by setting up [Datadog RUM][1] in your Next.js application:
17
+
18
+
- If you are creating a RUM application, select **Next.js** as the application type.
19
+
- If Next.js is not available as an option, select **React** and follow the steps below to integrate the plugin manually.
20
+
21
+
After configuration, the Datadog App provides instructions for integrating the [RUM-Next.js plugin][2] with the Browser SDK.
23
22
24
-
Both routers require **Next.js v15.3+**, which supports the [`instrumentation-client`][1] file convention.
23
+
Both routers require **Next.js v15.3+**, which supports the [`instrumentation-client`][3] file convention.
25
24
26
-
# App Router Usage
25
+
##App router usage
27
26
28
-
## 1. Create an `instrumentation-client.js` file in the root of your Next.js project
27
+
###1. Create an `instrumentation-client.js` file in the root of your Next.js project
29
28
30
29
Initialize the Datadog RUM SDK with the `nextjsPlugin` and re-export `onRouterTransitionStart` so Next.js can call it on client-side navigations:
31
30
@@ -43,7 +42,7 @@ datadogRum.init({
43
42
})
44
43
```
45
44
46
-
## 2. Call the DatadogAppRouter component from your root layout.
45
+
###2. Call the DatadogAppRouter component from your root layout.
47
46
48
47
```tsx
49
48
// app/layout.tsx
@@ -61,7 +60,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
61
60
}
62
61
```
63
62
64
-
## 3. Report errors from error boundaries
63
+
###3. Report errors from error boundaries
65
64
66
65
Next.js uses [error boundaries](https://nextjs.org/docs/app/api-reference/file-conventions/error) (`error.tsx` files) to catch uncaught exceptions in each route segment. Use `addNextjsError` inside these boundaries to report errors to Datadog RUM.
The `DatadogPagesRouter` and `DatadogAppRouter` components automatically track route changes and normalize dynamic segments into parameterized view names:
0 commit comments