Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 10 additions & 12 deletions docs/platforms/javascript/guides/nextjs/manual-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ export default withSentryConfig(nextConfig, {

### Initialize Sentry Client-Side and Server-Side SDKs

Create three files in your application's root directory: `sentry.server.config.(js|ts)`, `sentry.edge.config.(js|ts)`, and `instrumentation-client.(js|ts)`. Add the following initialization code into each respective file:
Create three files in your application's root directory:
- `sentry.server.config.(js|ts)`
- `sentry.edge.config.(js|ts)`
- `instrumentation-client.(js|ts)`
- If you previously had a file called `sentry.client.config.(js|ts)`, you can safely rename this to `instrumentation-client.(js|ts)` for all Next.js versions.

Add the following initialization code into each respective file:

<Alert level="info" title="Note">
These files run in different environments (browser, server, edge) and are
Expand All @@ -112,8 +118,8 @@ Sentry.init({
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
tracesSampleRate: 1.0,
// ___PRODUCT_OPTION_END___ performance
// Replay may only be enabled for the client-side
// ___PRODUCT_OPTION_START___ session-replay
// Replay may only be enabled for the client-side
integrations: [Sentry.replayIntegration()],

// Capture Replay for 10% of all sessions,
Expand Down Expand Up @@ -188,10 +194,8 @@ Sentry.init({
});
```

<Alert level="success" title="Tip">
Include your [Data Source Name](/concepts/key-terms/dsn-explainer/) (DSN)
directly in these files, or use a _public_ environment variable like
`NEXT_PUBLIC_SENTRY_DSN`.
<Alert title="Tip">
Include your DSN directly in these files, or use a _public_ environment variable like `NEXT_PUBLIC_SENTRY_DSN`.
</Alert>

### Register Sentry Server-Side SDK Initialization
Expand All @@ -210,12 +214,6 @@ export async function register() {
}
```

<Alert level="warning" title="Next.js version <15 only">
You need to enable the instrumentation hook by setting the
`experimental.instrumentationHook` to `true` in your `next.config.(js|mjs)`
file.
</Alert>

<Expandable title="Opt out of Sentry SDK bundling on client- or server-side.">
If you want the Sentry SDK to be available on the server side and not on the
client side, simply delete `instrumentation-client.(js|ts)`. This will prevent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,45 @@
Set `tracesSampleRate` in your config files, `instrumentation-client.js`, `sentry.server.config.js`, and `sentry.edge.config.js`:
Set `tracesSampleRate` in your config files:
- `sentry.server.config.js`
- `sentry.edge.config.js`:
- `instrumentation-client.js`
- If you previously had a file called `sentry.client.config.(js|ts)`, you can safely rename this to `instrumentation-client.(js|ts)` for all Next.js versions.

```javascript
```javascript {tabTitle:Client} {filename:instrumentation-client.(js|ts)}
import * as Sentry from "@sentry/nextjs";

Sentry.init({
dsn: "___PUBLIC_DSN___",
// We recommend adjusting this value in production, or using `tracesSampler`
// for finer control
tracesSampleRate: 1.0,
// ... rest of your config
});

// This export will instrument router navigations, and is only relevant if you enable tracing.
// `captureRouterTransitionStart` is available from SDK version 9.12.0 onwards
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;
```

```javascript {tabTitle:Server} {filename:sentry.server.config.(js|ts)}
import * as Sentry from "@sentry/nextjs";

Sentry.init({
dsn: "___PUBLIC_DSN___",
// We recommend adjusting this value in production, or using `tracesSampler`
// for finer control
tracesSampleRate: 1.0,
// ... rest of your config
});
```

```javascript {tabTitle:Edge} {filename:sentry.edge.config.(js|ts)}
import * as Sentry from "@sentry/nextjs";

Sentry.init({
dsn: "___PUBLIC_DSN___",
// We recommend adjusting this value in production, or using `tracesSampler`
// for finer control
tracesSampleRate: 1.0,
// ... rest of your config
});
```