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: docs/platforms/javascript/guides/nextjs/manual-setup.mdx
+3-142Lines changed: 3 additions & 142 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -263,154 +263,15 @@ To capture React render errors, you need to add error components for the App Rou
263
263
264
264
### App Router
265
265
266
-
Create or update the `global-error.(tsx|jsx)` file to define a [custom Next.js GlobalError component](https://nextjs.org/docs/app/building-your-application/routing/error-handling):
267
-
268
-
```tsx {filename:global-error.tsx}
269
-
"use client";
270
-
271
-
import*asSentryfrom"@sentry/nextjs";
272
-
importNextErrorfrom"next/error";
273
-
import { useEffect } from"react";
274
-
275
-
exportdefaultfunction GlobalError({
276
-
error,
277
-
}: {
278
-
error:Error& { digest?:string };
279
-
}) {
280
-
useEffect(() => {
281
-
Sentry.captureException(error);
282
-
}, [error]);
283
-
284
-
return (
285
-
<html>
286
-
<body>
287
-
{/* `NextError` is the default Next.js error page component. Its type
288
-
definition requires a `statusCode` prop. However, since the App Router
289
-
does not expose status codes for errors, we simply pass 0 to render a
290
-
generic error message. */}
291
-
<NextErrorstatusCode={0} />
292
-
</body>
293
-
</html>
294
-
);
295
-
}
296
-
```
297
-
298
-
```jsx {filename:global-error.jsx}
299
-
"use client";
300
-
301
-
import*asSentryfrom"@sentry/nextjs";
302
-
importNextErrorfrom"next/error";
303
-
import { useEffect } from"react";
304
-
305
-
exportdefaultfunctionGlobalError({ error }) {
306
-
useEffect(() => {
307
-
Sentry.captureException(error);
308
-
}, [error]);
309
-
310
-
return (
311
-
<html>
312
-
<body>
313
-
{/* This is the default Next.js error component. */}
Requires `@sentry/nextjs` version `8.28.0` or higher and Next.js 15.
325
-
</Alert>
326
-
327
-
To capture errors from nested React Server Components, use the [`onRequestError`](https://nextjs.org/docs/app/api-reference/file-conventions/instrumentation#onrequesterror-optional) hook in `instrumentation.(js|ts)` and pass all arguments to the `captureRequestError` function:
Create or update the `_error.(tsx|jsx)` file to define a [custom Next.js error page](https://nextjs.org/docs/pages/building-your-application/routing/custom-error) for the Pages Router like so:
0 commit comments