You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**`sentry.client.config.ts|js` is still supported and encouraged for initializing the clientside SDK.**
873
+
Version 8 of the Next.js SDK will require an additional `instrumentation.ts` file to execute the `sentry.server.config.js|ts` and `sentry.edge.config.js|ts` modules to initialize the SDK for the server-side.
874
+
The `instrumentation.ts` file is a Next.js native API called [instrumentation hook](https://nextjs.org/docs/app/api-reference/file-conventions/instrumentation).
877
875
878
-
The following is an example of how to initialize the serverside SDK in a Next.js instrumentation hook:
876
+
To start using the Next.js instrumentation hook, follow these steps:
879
877
880
-
1. First, enable the Next.js instrumentation hook by setting the `experimental.instrumentationHook` to `true` in your
881
-
`next.config.js`.
882
-
2. Next, create a `instrumentation.ts|js` file in the root directory of your project (or in the `src` folder if you have
883
-
have one).
884
-
3. Now, export a `register` function from the `instrumentation.ts|js` file and call `Sentry.init()` inside of it:
878
+
1. First, enable the Next.js instrumentation hook by setting the [`experimental.instrumentationHook`](https://nextjs.org/docs/app/api-reference/next-config-js/instrumentationHook) to true in your `next.config.js`. (This step is no longer required with Next.js 15)
885
879
886
-
```ts
887
-
import*asSentryfrom'@sentry/nextjs';
888
-
889
-
exportfunctionregister() {
890
-
if (process.env.NEXT_RUNTIME==='nodejs') {
891
-
Sentry.init({
892
-
dsn:'YOUR_DSN',
893
-
// Your Node.js Sentry configuration...
894
-
});
895
-
}
896
-
897
-
if (process.env.NEXT_RUNTIME==='edge') {
898
-
Sentry.init({
899
-
dsn:'YOUR_DSN',
900
-
// Your Edge Runtime Sentry configuration...
901
-
});
902
-
}
880
+
```JavaScript {filename:next.config.js} {2-4}
881
+
module.exports= {
882
+
experimental: {
883
+
instrumentationHook:true, // Not required on Next.js 15+
884
+
},
903
885
}
904
886
```
905
887
906
-
If you need to import a Node.js specific integration (like for example `@sentry/profiling-node`), you will have to
907
-
import the package using a dynamic import to prevent Next.js from bundling Node.js APIs into bundles for other
908
-
runtime environments (like the Browser or the Edge runtime). You can do so as follows:
888
+
2. Next, create a `instrumentation.ts|js` file in the root directory of your project (or in the src folder if you have have one).
889
+
890
+
3. Now, export a register function from the `instrumentation.ts|js` file and import your `sentry.server.config.js|ts` and `sentry.edge.config.js|ts` modules:
0 commit comments