Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions docs/platforms/javascript/common/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ Check out the other SDKs we support in the left-hand dropdown.

## Prerequisites

* You need a Sentry [account](https://sentry.io/signup/) and [project](/product/projects/)
You need:

- A Sentry [account](https://sentry.io/signup/) and [project](/product/projects/)
- Your application up and running

</PlatformSection>

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

</PlatformSection>

<PlatformSection supported={["javascript.nextjs"]}>

## Step 1: Choose Your Sentry Features (Optional)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would honestly remove this entire section. It's irrelevant to the setup in the docs since it's pretty much always gonna be the same because the wizard will already let you choose.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my response to a similar comment here: #12291 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are very conflicting opinions on adding a paragraph like this. IIRC we flipped back and fourth 4 times on having this paragraph vs not having it in the last 2 years.

I personally, don't think SDK onboarding is the place to go into that stuff. I do however see the value behind capturing people who know nothing about Sentry yet. How about instead of having a 3 point paragraph, we do a simple sentence like, "This guide will tell you how to hook up your application with the Sentry SDK. If you want to know more about Sentry itself go here."

Copy link
Collaborator Author

@inventarSarah inventarSarah Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's a hot topic, as I've learned :)! There are already discussions about moving these features to another location (e.g. an SDK landing page). And then, as you wrote, for example, link to it from the quick start page.
However, since we currently don't yet have a place for it, I'd like to leave the information here.
Or do you know of a page we could link to?
If not, is it okay for you to leave it like this for the time being?

I'm also working on the Next.js quick start guide for manual setup -> this page will also need to communicate the features to the user (including onboarding option checkboxes). How we will solve this in detail will probably also influence the quick start guide for the wizard setup (and vice versa).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, we can keep it for now!


During setup, you'll have the option to enable specific Sentry features for your application.
Here's a quick overview of what's what:

- [**Error Monitoring**](/product/issues) (always enabled): Automatically report errors, uncaught exceptions, and unhandled rejections. If you have something that looks like an exception, Sentry can capture it.
- **Tunneling**: Route browser requests to Sentry through a Next.js rewrite to bypass ad-blockers that might interfere with Sentry's data collection.
- [**Tracing**](/product/tracing): Track software performance while seeing the impact of errors across multiple systems. For example, distributed tracing allows you to follow a request from the frontend to the backend and back.
- [**Session Replay**](/product/explore/session-replay/web/getting-started/): Get to the root cause of an issue faster by viewing a video-like reproduction of what was happening in the user's browser before, during, and after the problem.

## Step 2: Install

</PlatformSection>

<PlatformSection notSupported={["javascript.nextjs"]}>

## Install

</PlatformSection>

<PlatformCategorySection notSupported={["server"]}>
<PlatformSection notSupported={["javascript", "javascript.cordova"]}>
<OnboardingOptionButtons options={["error-monitoring", "performance", "session-replay"]} />
<OnboardingOptionButtons
options={["error-monitoring", "performance", "session-replay"]}
/>
</PlatformSection>
</PlatformCategorySection>

Expand Down Expand Up @@ -64,12 +89,17 @@ Select which Sentry features you'd like to install in addition to Error Monitori
</PlatformSection>
</PlatformCategorySection>

<PlatformSection notSupported={["javascript.nextjs"]}>

Sentry captures data by using an SDK within your application’s runtime.

</PlatformSection>

<PlatformContent includePath="getting-started-install" />

</PlatformSection>

<PlatformSection notSupported={["javascript.nextjs"]}>
## Configure

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

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

</PlatformSection>

<PlatformContent includePath="getting-started-sourcemaps" />

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

</PlatformSection>

<PlatformSection supported={["javascript.nextjs"]}>

<PlatformContent includePath="getting-started-verify" />

</PlatformSection>

<PlatformSection notSupported={["javascript.nextjs"]}>

## Verify

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

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.

</PlatformSection>

<PlatformContent includePath="getting-started-next-steps" />
4 changes: 2 additions & 2 deletions docs/platforms/javascript/guides/nextjs/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
title: Next.js
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.
title: 'Next.js'
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.
sdk: sentry.javascript.nextjs
categories:
- javascript
Expand Down
27 changes: 14 additions & 13 deletions platform-includes/getting-started-install/javascript.nextjs.mdx
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
We recommend installing the SDK through our installation wizard:
To install Sentry using the installation wizard, run the following command within your project:

```bash
npx @sentry/wizard@latest -i nextjs
```

The wizard will prompt you to log in to Sentry. It will then automatically do the following steps for you:
The wizard starts guiding you through the setup process, which also includes enabling the Sentry features listed above.

- create config files with the default `Sentry.init()` calls for each runtime (node, browser, edge)
- add a Next.js instrumentation hook to your project (`instrumentation.ts`)
- create or update your Next.js config with the default Sentry configuration
- create `.sentryclirc` with an auth token to upload source maps (this file is automatically added to `.gitignore`)
- add an example page to your app to verify your Sentry setup
<Alert level="warning" title="Important">

After the wizard setup is completed, the SDK will automatically capture unhandled errors, and monitor performance.
You can also <PlatformLink to="/usage/">manually capture errors</PlatformLink>.
This guide assumes you enable all Sentry features during the wizard setup and allow it to create an example page and route. If you make different choices, you can still follow along, but you may need to make adjustments as you proceed.

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

<Note>
You can always add or remove config options manually later if needed. Though, the earlier you set these up, the better.

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

</Note>
- Create config files with the default `Sentry.init()` calls for each runtime (node, browser, edge)
- Add a Next.js instrumentation hook to your project (`instrumentation.ts`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Add a Next.js instrumentation hook to your project (`instrumentation.ts`)
- Addition of Next.js instrumentation hook to your project (`instrumentation.ts`)

- Create or update your Next.js config with the default Sentry settings
- Create `.sentryclirc` with an auth token to upload source maps (this file is automatically added to `.gitignore`)
- Add an example page and route to your application to help verify your Sentry setup

</Expandable>
18 changes: 18 additions & 0 deletions platform-includes/getting-started-next-steps/javascript.nextjs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Next Steps

You should now have integrated Sentry into your Next.js application and should already be sending error and performance data to your Sentry project.

Now's a good time to customize your setup and look into more advanced topics.
Our next recommended steps for you are:

- Learn more about our [Vercel integration](/organization/integrations/deployment/vercel/)
- Continue to [customize your configuration](/platforms/javascript/guides/nextjs/configuration/)
- Learn how to [manually capture errors](/platforms/javascript/guides/nextjs/usage/)
- Get familiar with [Sentry's product features](/product) like tracing, insights, and alerts

<Expandable permalink={false} title="Did you experience any issues with this guide?">

- If you encountered issues with our installation wizard, try [setting up Sentry manually](/platforms/javascript/guides/nextjs/manual-setup/)
- [Get support](https://sentry.zendesk.com/hc/en-us/)

</Expandable>
25 changes: 5 additions & 20 deletions platform-includes/getting-started-primer/javascript.nextjs.mdx
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
Features:
<Expandable title="Are you developing with Turbopack?">

- Automatic [Error Tracking](/product/issues/) with source maps for both JavaScript and TypeScript
- Automatic [Tracing](/product/performance/) for both the client and server
- 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)
- Events [enriched](/platforms/javascript/enriching-events/context/) with device data
- [Breadcrumbs](/platforms/javascript/enriching-events/breadcrumbs/) created for outgoing HTTP request with XHR and Fetch, and console logs
- [Release health](/product/releases/health/) for tracking crash-free users and sessions
The Sentry SDK doesn't fully support `next dev --turbo` as Turbopack is still under development.

<Note>
However, Sentry will work fine in your production builds.

The Sentry SDK does not fully support `next dev --turbo` while Turbopack does not ship all the features required to run Sentry.
Check the latest information on [Sentry's support for Turbopack on GitHub](https://github.com/getsentry/sentry-javascript/issues/8105).

Currently, when you run your devserver with Turbopack, the Sentry Next.js SDK will not be loaded in the browser.
Keep this in mind when configuring the SDK.

Note that this only affects the devserver.
The Sentry SDK will run without issues when you do a production build, even if you develop locally with Turbopack.

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).

You can track Sentry's Turbopack support in the [GitHub Issue in the Sentry SDK repository](https://github.com/getsentry/sentry-javascript/issues/8105).

</Note>
</Expandable>
52 changes: 18 additions & 34 deletions platform-includes/getting-started-verify/javascript.nextjs.mdx
Original file line number Diff line number Diff line change
@@ -1,46 +1,30 @@
Add a button to a frontend component that throws an error:
## Step 3: Verify Your Setup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this section because the wizard will tell you to do this. We should avoid putting information in multiple places. If the wizard is missing information that we would have added here, we should add it to the wizard instead. My working theory is that once people run the wizard command, they will not look back into the docs until they are done with looking at the error in Sentry. At which point all of this text is already irrelevant. What's more important in that moment is the Next Steps.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand you're suggesting we simplify the guide to only include "Prerequisites," "Install," and "Next Steps." -- Did I get this right?

This is a new idea, and I'd like to share it with the others to get their input as well (hopefully tomorrow).

I see the advantages of having a shorter guide and relying more on the wizard.
However, there are a few points we need to be mindful about:

  • once the terminal window in which the wizard ran is closed, all its information is gone; the quick start guide is always accessible
  • "they will not look back into the docs until they are done with looking at the error in Sentry" - on the other hand, we probably also have users who don't read all the text in the terminal (I'm such a candidate, for example). Especially everything that comes after the green Success message may be perceived as "not important"; ideally, we can make both of these user types happy
  • many users who use this type of guide are probably new and don't know much about Sentry yet. So the quick start guide is a great place to introduce them to features beyond error monitoring and provide links to more information -> but we have also talked about providing this info somewhere else (eg. on a landing page Have quick start as a menu item #12289)

this is also relevant to your comment on the features: /#discussion_r1910162943

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These points make sense. We can keep it, but I would advocate for half a sentence like "If you haven't done so through the setup wizard, go through the following steps to....". That way people will know not to do the same thing twice.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you -- I'll rewrite this section for sure because I now see that it can be misleading!


```javascript {filename:pages/index.js}
<button
type="button"
onClick={() => {
throw new Error("Sentry Frontend Error");
}}
>
Throw error
</button>
```
Let's 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.

And throw an error in an API route:
1. Open the example page at [http://localhost:3000/sentry-example-page](http://localhost:3000/sentry-example-page)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another problem: it may not always be localhost:3000 depending on the app

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated this to be more like what we currently have in the wizard

2. Click the "Throw error" button. This triggers two errors:
- a frontend error
- an error within the API route

```javascript {filename:pages/api/error.js}
export default (req, res) => {
throw new Error("API throw error test");
res.status(200).json({ name: "John Doe" });
};
```
Sentry will capture 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.

```typescript {filename:pages/api/error.ts}
import type { NextApiRequest, NextApiResponse } from "next";
<Alert level="success" title="Tip">

export default (req: NextApiRequest, res: NextApiResponse) => {
throw new Error("API throw error test");
res.status(200).json({ name: "John Doe" });
};
```
Make sure to explore the example files' code in your project to understand what's happening after your button click.

<Note>

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.

</Note>
</Alert>

<Alert title="Nested React Server Components" level="warning">
### View Captured Data in Sentry

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.
Now head over to your Sentry project on [Sentry.io](https://sentry.io) to view the collected data (it takes a couple of moments for the data to appear).

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

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

</Alert>

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).
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).
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.
Loading