Skip to content

Commit faf1e71

Browse files
inventarSarahchargomemydea
authored
Rework Next.js quick start guide (wizard) (#12291)
* Rework Next.js quick start guide (wizard) * Remove permalink prop from Expandable Co-authored-by: Charly Gomez <[email protected]> * integrate pr feedback * updated structure and put more content into expandables. Testing out some ideas. * Expandable title update Co-authored-by: Francesco Gringl-Novy <[email protected]> * minor text updates to improve clarity * Alex feedback * mini update Alex feedback --------- Co-authored-by: Charly Gomez <[email protected]> Co-authored-by: Francesco Gringl-Novy <[email protected]>
1 parent 09db0a2 commit faf1e71

File tree

6 files changed

+104
-72
lines changed

6 files changed

+104
-72
lines changed

docs/platforms/javascript/common/index.mdx

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ Check out the other SDKs we support in the left-hand dropdown.
1616

1717
## Prerequisites
1818

19-
* You need a Sentry [account](https://sentry.io/signup/) and [project](/product/projects/)
19+
You need:
20+
21+
- A Sentry [account](https://sentry.io/signup/) and [project](/product/projects/)
22+
- Your application up and running
2023

2124
</PlatformSection>
2225

@@ -32,11 +35,23 @@ Select which Sentry features you'd like to install in addition to Error Monitori
3235

3336
</PlatformSection>
3437

38+
<PlatformSection supported={["javascript.nextjs"]}>
39+
40+
## Step 1: Install
41+
42+
</PlatformSection>
43+
44+
<PlatformSection notSupported={["javascript.nextjs"]}>
45+
3546
## Install
3647

48+
</PlatformSection>
49+
3750
<PlatformCategorySection notSupported={["server"]}>
3851
<PlatformSection notSupported={["javascript", "javascript.cordova"]}>
39-
<OnboardingOptionButtons options={["error-monitoring", "performance", "session-replay"]} />
52+
<OnboardingOptionButtons
53+
options={["error-monitoring", "performance", "session-replay"]}
54+
/>
4055
</PlatformSection>
4156
</PlatformCategorySection>
4257

@@ -64,12 +79,17 @@ Select which Sentry features you'd like to install in addition to Error Monitori
6479
</PlatformSection>
6580
</PlatformCategorySection>
6681

82+
<PlatformSection notSupported={["javascript.nextjs"]}>
83+
6784
Sentry captures data by using an SDK within your application’s runtime.
6885

86+
</PlatformSection>
87+
6988
<PlatformContent includePath="getting-started-install" />
7089

7190
</PlatformSection>
7291

92+
<PlatformSection notSupported={["javascript.nextjs"]}>
7393
## Configure
7494

7595
<PlatformSection notSupported={["javascript.nextjs", "javascript.astro", "javascript.react", "javascript.react-router"]}>
@@ -86,6 +106,8 @@ Sentry supports multiple versions of React Router. To learn how to configure the
86106

87107
<PlatformContent includePath="getting-started-config" />
88108

109+
</PlatformSection>
110+
89111
<PlatformContent includePath="getting-started-sourcemaps" />
90112

91113
<PlatformSection supported={["javascript.bun"]}>
@@ -96,6 +118,14 @@ Sentry supports multiple versions of React Router. To learn how to configure the
96118

97119
</PlatformSection>
98120

121+
<PlatformSection supported={["javascript.nextjs"]}>
122+
123+
<PlatformContent includePath="getting-started-verify" />
124+
125+
</PlatformSection>
126+
127+
<PlatformSection notSupported={["javascript.nextjs"]}>
128+
99129
## Verify
100130

101131
This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.
@@ -110,4 +140,6 @@ Learn more about manually capturing an error or message in our <PlatformLink to=
110140

111141
To view and resolve the recorded error, log into [sentry.io](https://sentry.io) and select your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.
112142

143+
</PlatformSection>
144+
113145
<PlatformContent includePath="getting-started-next-steps" />

docs/platforms/javascript/guides/nextjs/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
title: Next.js
2-
description: Next.js is a flexible React framework that gives you building blocks to create fast, full-stack web applications. Learn how to set it up with Sentry.
1+
title: 'Next.js'
2+
description: Learn how to set up and configure Sentry in your Next.js application using the installation wizard, capture your first errors, and view them in Sentry.
33
sdk: sentry.javascript.nextjs
44
categories:
55
- javascript
Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
1-
We recommend installing the SDK through our installation wizard:
1+
To install Sentry using the installation wizard, run the following command within your project:
22

33
```bash
44
npx @sentry/wizard@latest -i nextjs
55
```
66

7-
The wizard will prompt you to log in to Sentry. It will then automatically do the following steps for you:
7+
The wizard then guides you through the setup process, asking you to enable additional (optional) Sentry features for your application beyond error monitoring.
88

9-
- create config files with the default `Sentry.init()` calls for each runtime (node, browser, edge)
10-
- add a Next.js instrumentation hook to your project (`instrumentation.ts`)
11-
- create or update your Next.js config with the default Sentry configuration
12-
- create `.sentryclirc` with an auth token to upload source maps (this file is automatically added to `.gitignore`)
13-
- add an example page to your app to verify your Sentry setup
9+
<Expandable title="Want to learn more about these features?">
1410

15-
After the wizard setup is completed, the SDK will automatically capture unhandled errors, and monitor performance.
16-
You can also <PlatformLink to="/usage/">manually capture errors</PlatformLink>.
11+
- [**Issues**](/product/issues) (always enabled): Sentry's core error monitoring product that automatically reports errors,
12+
uncaught exceptions, and unhandled rejections. If you have something that
13+
looks like an exception, Sentry can capture it.
14+
- [**Tracing**](/product/tracing): Track software performance while seeing the
15+
impact of errors across multiple systems. For example, distributed tracing
16+
allows you to follow a request from the frontend to the backend and back.
17+
- [**Session Replay**](/product/explore/session-replay/web):
18+
Get to the root cause of an issue faster by viewing a video-like reproduction
19+
of what was happening in the user's browser before, during, and after the
20+
problem.
1721

18-
To learn how to connect your app to Sentry and deploy it on Vercel, see the [Vercel integration](/organization/integrations/deployment/vercel/).
22+
</Expandable>
1923

20-
<Alert>
24+
This guide assumes that you enable all features and allow the wizard to create an example page and route. You can add or remove features at any time, but setting them up now will save you the effort of configuring them manually later.
2125

22-
If the setup through the wizard doesn't work for you, you can also <PlatformLink to="/manual-setup/">set up the SDK manually</PlatformLink>.
26+
<Expandable title="What does the installation wizard change inside your application?">
2327

24-
</Alert>
28+
- Creates config files with the default `Sentry.init()` calls for all runtimes (Node.js, Browser, and Edge)
29+
- Adds a Next.js instrumentation hook to your project (`instrumentation.ts`)
30+
- Creates or updates your Next.js config with the default Sentry settings
31+
- Creates `.sentryclirc` with an auth token to upload source maps (this file is automatically added to `.gitignore`)
32+
- Adds an example page and route to your application to help verify your Sentry setup
33+
34+
</Expandable>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## Next Steps
2+
3+
At this point, you should have integrated Sentry into your Next.js application and should already be sending error and performance data to your Sentry project.
4+
5+
Now's a good time to customize your setup and look into more advanced topics.
6+
Our next recommended steps for you are:
7+
8+
- Learn how to [manually capture errors](/platforms/javascript/guides/nextjs/usage/)
9+
- Continue to [customize your configuration](/platforms/javascript/guides/nextjs/configuration/)
10+
- Get familiar with [Sentry's product features](/product) like tracing, insights, and alerts
11+
- Learn more about our [Vercel integration](/organization/integrations/deployment/vercel/)
12+
13+
<Expandable permalink={false} title="Did you experience any issues with this guide?">
14+
15+
- If you encountered issues with our installation wizard, try [setting up Sentry manually](/platforms/javascript/guides/nextjs/manual-setup/)
16+
- [Get support](https://sentry.zendesk.com/hc/en-us/)
17+
18+
</Expandable>
Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +0,0 @@
1-
Features:
2-
3-
- Automatic [Error Tracking](/product/issues/) with source maps for both JavaScript and TypeScript
4-
- Automatic [Tracing](/product/performance/) for both the client and server
5-
- Errors and Performance support for [Middleware](https://vercel.com/docs/concepts/functions/edge-middleware) and [Edge routes](https://vercel.com/docs/concepts/functions/edge-functions) in Vercel's edge runtime. Due to complexities with the runtime, some features of errors like stack traces may not be as expected. Requires <code>sentry.edge.config.js</code>, more info [here](/platforms/javascript/guides/nextjs/manual-setup/#create-initialization-config-files)
6-
- Events [enriched](/platforms/javascript/enriching-events/context/) with device data
7-
- [Breadcrumbs](/platforms/javascript/enriching-events/breadcrumbs/) created for outgoing HTTP request with XHR and Fetch, and console logs
8-
- [Release health](/product/releases/health/) for tracking crash-free users and sessions
9-
10-
<Alert>
11-
12-
The Sentry SDK does not fully support `next dev --turbo` while Turbopack does not ship all the features required to run Sentry.
13-
14-
Currently, when you run your devserver with Turbopack, the Sentry Next.js SDK will not be loaded in the browser.
15-
Keep this in mind when configuring the SDK.
16-
17-
Note that this only affects the devserver.
18-
The Sentry SDK will run without issues when you do a production build, even if you develop locally with Turbopack.
19-
20-
To support the SDK in the browser with Turbopack, [follow the feature request for client-side instrumentation in the Next.js repository](https://github.com/vercel/next.js/discussions/69294).
21-
22-
You can track Sentry's Turbopack support in the [GitHub Issue in the Sentry SDK repository](https://github.com/getsentry/sentry-javascript/issues/8105).
23-
24-
</Alert>
Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,42 @@
1-
Add a button to a frontend component that throws an error:
1+
## Step 2: Verify Your Setup
22

3-
```javascript {filename:pages/index.js}
4-
<button
5-
type="button"
6-
onClick={() => {
7-
throw new Error("Sentry Frontend Error");
8-
}}
9-
>
10-
Throw error
11-
</button>
12-
```
3+
<Expandable level="warning" title="Are you developing with Turbopack?">
134

14-
And throw an error in an API route:
5+
The Sentry SDK doesn't fully support `next dev --turbo` as Turbopack is still under development. This means that the Sentry SDK will not capture any data from your frontend. Other than that, your dev server should be fully operational.
156

16-
```javascript {filename:pages/api/error.js}
17-
export default (req, res) => {
18-
throw new Error("API throw error test");
19-
res.status(200).json({ name: "John Doe" });
20-
};
21-
```
7+
Check the latest information on [Sentry's support for Turbopack on GitHub](https://github.com/getsentry/sentry-javascript/issues/8105).
228

23-
```typescript {filename:pages/api/error.ts}
24-
import type { NextApiRequest, NextApiResponse } from "next";
9+
</Expandable>
2510

26-
export default (req: NextApiRequest, res: NextApiResponse) => {
27-
throw new Error("API throw error test");
28-
res.status(200).json({ name: "John Doe" });
29-
};
30-
```
11+
If you haven't tested your Sentry configuration yet, let's do it now. You can confirm that Sentry is working properly and sending data to your Sentry project by using the example page and route created by the installation wizard:
3112

32-
<Alert>
13+
1. Open the example page `/sentry-example-page` in your browser. For most Next.js applications, this will be at localhost.
14+
2. Click the "Throw error" button. This triggers two errors:
15+
- a frontend error
16+
- an error within the API route
3317

34-
Errors triggered from within Browser DevTools are sandboxed, so they will not trigger error monitoring. Keep this in mind when verifying your Sentry SDK installation.
18+
Sentry captures both of these errors for you. Additionally, the button click starts a performance trace to measure the time it takes for the API request to complete.
19+
20+
<Alert level="success" title="Tip">
21+
22+
Don't forget to explore the example files' code in your project to understand what's happening after your button click.
3523

3624
</Alert>
3725

38-
<Alert title="Nested React Server Components" level="warning">
26+
### View Captured Data in Sentry
3927

40-
Prior to Next.js version 15, errors thrown in nested React Server Components were not exposed by the framework, preventing the SDK from capturing them.
28+
Now, head over to your project on [Sentry.io](https://sentry.io) to view the collected data (it takes a couple of moments for the data to appear).
4129

42-
Next.js 15 introduced an `onRequestError` hook in `instrumentation.ts` that allows capturing and reporting these errors.
30+
<Alert level="warning" title="Important">
4331

44-
Refer to <PlatformLink to="/manual-setup/#errors-from-nested-react-server-components">Capturing Errors From Nested React Server Components</PlatformLink> for detailed setup instructions.
32+
Errors triggered from within your browser's developer tools (i.e., the browser console) are sandboxed, so they will not trigger Sentry's error monitoring.
4533

4634
</Alert>
35+
36+
<Expandable title="Need help locating the captured errors in your Sentry project?">
37+
38+
1. Open the [**Issues**](https://sentry.io/orgredirect/organizations/:orgslug/issues) page and select an error from the issues list to view the full details and context of this error. For an interactive UI walkthrough, click [here](/product/sentry-basics/integrate-frontend/generate-first-error/#ui-walkthrough).
39+
2. Open the [**Traces**](https://sentry.io/orgredirect/organizations/:orgslug/traces) page and select a trace to reveal more information about each span, its duration, and any errors. For an interactive UI walkthrough, click [here](/product/sentry-basics/distributed-tracing/generate-first-error/#ui-walkthrough).
40+
3. Open the [**Replays**](https://sentry.io/orgredirect/organizations/:orgslug/replays) page and select an entry from the list to get a detailed view where you can replay the interaction and get more information to help you troubleshoot.
41+
42+
</Expandable>

0 commit comments

Comments
 (0)