Skip to content

Commit 53fdd4d

Browse files
author
Luca Forstner
authored
docs(nextjs): Update Next.js readme (#13185)
1 parent 988d8e7 commit 53fdd4d

File tree

1 file changed

+23
-69
lines changed

1 file changed

+23
-69
lines changed

packages/nextjs/README.md

Lines changed: 23 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -10,96 +10,50 @@
1010
[![npm dm](https://img.shields.io/npm/dm/@sentry/nextjs.svg)](https://www.npmjs.com/package/@sentry/nextjs)
1111
[![npm dt](https://img.shields.io/npm/dt/@sentry/nextjs.svg)](https://www.npmjs.com/package/@sentry/nextjs)
1212

13-
## Links
14-
15-
- [Official SDK Docs](https://docs.sentry.io/platforms/javascript/guides/nextjs/)
16-
- [TypeDoc](http://getsentry.github.io/sentry-javascript/)
13+
> See the [Official Sentry Next.js SDK Docs](https://docs.sentry.io/platforms/javascript/guides/nextjs/) to get started.
1714
1815
## Compatibility
1916

20-
Currently, the minimum Next.js supported version is `11.2.0`.
21-
22-
## General
23-
24-
This package is a wrapper around `@sentry/node` for the server and `@sentry/react` for the client, with added
25-
functionality related to Next.js.
26-
27-
To use this SDK, initialize it in the Next.js configuration, in the `sentry.client.config.ts|js` file, and in the
28-
[Next.js Instrumentation Hook](https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation)
29-
(`instrumentation.ts|js`).
17+
Currently, the minimum supported version of Next.js is `13.2.0`.
3018

31-
```javascript
32-
// next.config.js
19+
## Installation
3320

34-
const { withSentryConfig } = require('@sentry/nextjs');
21+
To get started installing the SDK, use the Sentry Next.js Wizard by running the following command in your terminal or
22+
read the [Getting Started Docs](https://docs.sentry.io/platforms/javascript/guides/nextjs/):
3523

36-
const nextConfig = {
37-
experimental: {
38-
// The instrumentation hook is required for Sentry to work on the serverside
39-
instrumentationHook: true,
40-
},
41-
};
42-
43-
// Wrap the Next.js configuration with Sentry
44-
module.exports = withSentryConfig(nextConfig);
24+
```sh
25+
npx @sentry/wizard@latest -i nextjs
4526
```
4627

47-
```javascript
48-
// sentry.client.config.js or .ts
49-
50-
import * as Sentry from '@sentry/nextjs';
28+
The wizard will prompt you to log in to Sentry. After the wizard setup is completed, the SDK will automatically capture
29+
unhandled errors, and monitor performance.
5130

52-
Sentry.init({
53-
dsn: '__DSN__',
54-
// Your Sentry configuration for the Browser...
55-
});
56-
```
31+
## Custom Usage
5732

58-
```javascript
59-
// instrumentation.ts
33+
To set context information or to send manual events, you can use `@sentry/nextjs` as follows:
6034

61-
import * as Sentry from '@sentry/nextjs';
62-
63-
export function register() {
64-
if (process.env.NEXT_RUNTIME === 'nodejs') {
65-
Sentry.init({
66-
dsn: '__DSN__',
67-
// Your Node.js Sentry configuration...
68-
});
69-
}
70-
71-
if (process.env.NEXT_RUNTIME === 'edge') {
72-
Sentry.init({
73-
dsn: '__DSN__',
74-
// Your Edge Runtime Sentry configuration...
75-
});
76-
}
77-
}
78-
```
79-
80-
To set context information or send manual events, use the exported functions of `@sentry/nextjs`.
81-
82-
```javascript
35+
```ts
8336
import * as Sentry from '@sentry/nextjs';
8437

8538
// Set user information, as well as tags and further extras
86-
Sentry.setExtra('battery', 0.7);
8739
Sentry.setTag('user_mode', 'admin');
8840
Sentry.setUser({ id: '4711' });
41+
Sentry.setContext('application_area', { location: 'checkout' });
8942

9043
// Add a breadcrumb for future events
9144
Sentry.addBreadcrumb({
92-
message: 'My Breadcrumb',
45+
message: '"Add to cart" clicked',
9346
// ...
9447
});
9548

96-
// Capture exceptions, messages or manual events
49+
// Capture exceptions or messages
50+
Sentry.captureException(new Error('Oh no.'));
9751
Sentry.captureMessage('Hello, world!');
98-
Sentry.captureException(new Error('Good bye'));
99-
Sentry.captureEvent({
100-
message: 'Manual',
101-
stacktrace: [
102-
// ...
103-
],
104-
});
10552
```
53+
54+
## Links
55+
56+
- [Official SDK Docs](https://docs.sentry.io/platforms/javascript/guides/nextjs/)
57+
- [Sentry.io](https://sentry.io/?utm_source=github&utm_medium=npm_nextjs)
58+
- [Sentry Discord Server](https://discord.gg/Ww9hbqr)
59+
- [Stack Overflow](https://stackoverflow.com/questions/tagged/sentry)

0 commit comments

Comments
 (0)