-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Rework Next.js quick start guide (wizard) #12291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2d668f7
Rework Next.js quick start guide (wizard)
inventarSarah 4712da1
Remove permalink prop from Expandable
inventarSarah 14aab2d
Merge branch 'master' of github.com:getsentry/sentry-docs into smi/qu…
inventarSarah e183e6a
integrate pr feedback
inventarSarah eddbdb0
Merge branch 'master' of github.com:getsentry/sentry-docs into smi/qu…
inventarSarah e7707fc
updated structure and put more content into expandables. Testing out …
inventarSarah 25b37d9
Expandable title update
inventarSarah abbeca1
minor text updates to improve clarity
inventarSarah 37d0c9e
Merge branch 'master' of github.com:getsentry/sentry-docs into smi/qu…
inventarSarah a832d7e
Merge branch 'master' into smi/quick-start/nextjs
inventarSarah 72bc602
Alex feedback
inventarSarah e85c74e
mini update Alex feedback
inventarSarah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 23 additions & 13 deletions
36
platform-includes/getting-started-install/javascript.nextjs.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,34 @@ | ||
| 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 then guides you through the setup process, asking you to enable additional (optional) Sentry features for your application beyond error monitoring. | ||
|
|
||
| - 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 | ||
| <Expandable title="Want to learn more about these features?"> | ||
|
|
||
| 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>. | ||
| - [**Issues**](/product/issues) (always enabled): Sentry's core error monitoring product that automatically reports errors, | ||
| uncaught exceptions, and unhandled rejections. If you have something that | ||
| looks like an exception, Sentry can capture it. | ||
| - [**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): | ||
| 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. | ||
|
|
||
| To learn how to connect your app to Sentry and deploy it on Vercel, see the [Vercel integration](/organization/integrations/deployment/vercel/). | ||
| </Expandable> | ||
|
|
||
| <Alert> | ||
| 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. | ||
|
|
||
| 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 title="What does the installation wizard change inside your application?"> | ||
|
|
||
| </Alert> | ||
| - Creates config files with the default `Sentry.init()` calls for all runtimes (Node.js, Browser, and Edge) | ||
| - Adds a Next.js instrumentation hook to your project (`instrumentation.ts`) | ||
| - Creates or updates your Next.js config with the default Sentry settings | ||
| - Creates `.sentryclirc` with an auth token to upload source maps (this file is automatically added to `.gitignore`) | ||
| - Adds an example page and route to your application to help verify your Sentry setup | ||
|
|
||
| </Expandable> |
18 changes: 18 additions & 0 deletions
18
platform-includes/getting-started-next-steps/javascript.nextjs.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| ## Next Steps | ||
|
|
||
| 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. | ||
|
|
||
| Now's a good time to customize your setup and look into more advanced topics. | ||
| Our next recommended steps for you are: | ||
|
|
||
| - Learn how to [manually capture errors](/platforms/javascript/guides/nextjs/usage/) | ||
| - Continue to [customize your configuration](/platforms/javascript/guides/nextjs/configuration/) | ||
| - Get familiar with [Sentry's product features](/product) like tracing, insights, and alerts | ||
| - Learn more about our [Vercel integration](/organization/integrations/deployment/vercel/) | ||
|
|
||
| <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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +0,0 @@ | ||
| Features: | ||
|
|
||
| - 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 | ||
|
|
||
| <Alert> | ||
|
|
||
| The Sentry SDK does not fully support `next dev --turbo` while Turbopack does not ship all the features required to run Sentry. | ||
|
|
||
| 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). | ||
|
|
||
| </Alert> | ||
58 changes: 27 additions & 31 deletions
58
platform-includes/getting-started-verify/javascript.nextjs.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,46 +1,42 @@ | ||
| Add a button to a frontend component that throws an error: | ||
| ## Step 2: Verify Your Setup | ||
|
|
||
| ```javascript {filename:pages/index.js} | ||
| <button | ||
| type="button" | ||
| onClick={() => { | ||
| throw new Error("Sentry Frontend Error"); | ||
| }} | ||
| > | ||
| Throw error | ||
| </button> | ||
| ``` | ||
| <Expandable level="warning" title="Are you developing with Turbopack?"> | ||
|
|
||
| And throw an error in an API route: | ||
| 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. | ||
|
|
||
| ```javascript {filename:pages/api/error.js} | ||
| export default (req, res) => { | ||
| throw new Error("API throw error test"); | ||
| res.status(200).json({ name: "John Doe" }); | ||
| }; | ||
| ``` | ||
| Check the latest information on [Sentry's support for Turbopack on GitHub](https://github.com/getsentry/sentry-javascript/issues/8105). | ||
|
|
||
| ```typescript {filename:pages/api/error.ts} | ||
| import type { NextApiRequest, NextApiResponse } from "next"; | ||
| </Expandable> | ||
|
|
||
| export default (req: NextApiRequest, res: NextApiResponse) => { | ||
| throw new Error("API throw error test"); | ||
| res.status(200).json({ name: "John Doe" }); | ||
| }; | ||
| ``` | ||
| 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: | ||
|
|
||
| <Alert> | ||
| 1. Open the example page `/sentry-example-page` in your browser. For most Next.js applications, this will be at localhost. | ||
| 2. Click the "Throw error" button. This triggers two errors: | ||
| - a frontend error | ||
| - an error within the API route | ||
|
|
||
| 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. | ||
| 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. | ||
|
|
||
| <Alert level="success" title="Tip"> | ||
|
|
||
| Don't forget to explore the example files' code in your project to understand what's happening after your button click. | ||
|
|
||
| </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 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 (i.e., the browser console) are sandboxed, so they will not trigger Sentry's error monitoring. | ||
|
|
||
| </Alert> | ||
|
|
||
| <Expandable title="Need help locating the captured errors in your Sentry project?"> | ||
|
|
||
| 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. | ||
|
|
||
| </Expandable> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.