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: src/wizard/javascript/nextjs.md
+8-21
Original file line number
Diff line number
Diff line change
@@ -21,35 +21,19 @@ npx @sentry/wizard -i nextjs
21
21
```
22
22
23
23
Sentry wizard will automatically patch your application:
24
+
24
25
- create `sentry.client.config.js` and `sentry.server.config.js` with the default `Sentry.init`.
25
26
- create `next.config.js` with the default configuration.
26
27
- create `sentry.properties` with configuration for sentry-cli (which is used when automatically uploading source maps).
27
28
28
-
29
29
You can also [configure it manually](https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/).
30
30
31
-
32
-
## Nextjs API routes
33
-
While `@sentry/nextjs` will enable Sentry for your nextjs application, files under the `pages/api` require one additional installing step.
34
-
35
-
Wrap your API handlers with a `withSentry` function to capture [Next.js API route errors](https://nextjs.org/docs/api-routes/introduction):
36
-
37
-
```javascript
38
-
import { withSentry } from'@sentry/nextjs';
39
-
40
-
consthandler=async (req, res) => {
41
-
// ...
42
-
}
43
-
44
-
exportdefaultwithSentry(handler);
45
-
```
46
-
47
31
Configure the Sentry initialization:
48
32
49
33
```javascript
50
34
Sentry.init({
51
35
dsn:"___PUBLIC_DSN___",
52
-
36
+
53
37
// Set tracesSampleRate to 1.0 to capture 100%
54
38
// of transactions for performance monitoring.
55
39
// We recommend adjusting this value in production
@@ -62,10 +46,13 @@ The above configuration has automatic error tracking with source maps for both J
62
46
Then create an intentional error, so you can test that everything is working from your development environment. For example, a button whose `onClick` handler throws an error:
0 commit comments