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
Note that if you create [Next.js error.js files](https://nextjs.org/docs/app/building-your-application/routing/error-handling), these files will take precedence over the `global-error.js` file.
243
-
This means, that if you want to report errors that are caught by `error.js` files, you need to manually capture them:
244
-
245
-
```tsx {filename:error.tsx}
246
-
"use client";
247
-
248
-
import { useEffect } from"react";
249
-
import*asSentryfrom"@sentry/nextjs";
250
-
251
-
exportdefaultfunction ErrorPage({
252
-
error,
253
-
}: {
254
-
error:Error& { digest?:string };
255
-
}) {
256
-
useEffect(() => {
257
-
// Log the error to Sentry
258
-
Sentry.captureException(error);
259
-
}, [error]);
260
-
261
-
return (
262
-
<div>
263
-
<h2>Something went wrong!</h2>
264
-
</div>
265
-
);
266
-
}
267
-
```
268
-
269
-
```jsx {filename:error.jsx}
270
-
"use client";
271
-
272
-
import { useEffect } from"react";
273
-
import*asSentryfrom"@sentry/nextjs";
274
-
275
-
exportdefaultfunctionErrorPage({ error }) {
276
-
useEffect(() => {
277
-
// Log the error to Sentry
278
-
Sentry.captureException(error);
279
-
}, [error]);
280
-
281
-
return (
282
-
<div>
283
-
<h2>Something went wrong!</h2>
284
-
</div>
285
-
);
286
-
}
287
-
```
288
-
289
242
#### Errors from Nested React Server Components
290
243
291
244
_Requires `@sentry/nextjs` version `8.28.0` or higher and Next.js 15._
Copy file name to clipboardExpand all lines: platform-includes/capture-error/javascript.nextjs.mdx
+49Lines changed: 49 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -9,3 +9,52 @@ try {
9
9
Sentry.captureException(err);
10
10
}
11
11
```
12
+
13
+
### Capturing Errors in `error.js` Files
14
+
15
+
Note that if you create [Next.js error.js files](https://nextjs.org/docs/app/building-your-application/routing/error-handling), these files will take precedence over any global error handling.
16
+
This means, that if you want to report errors that are caught by `error.js` files, you need to manually capture them:
0 commit comments