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
Note that you can initialize the SDK differently depending on which server runtime is being used.
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).
875
+
876
+
To start using the Next.js instrumentation hook, follow these steps:
877
+
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)
879
+
880
+
```JavaScript {filename:next.config.js} {2-4}
881
+
module.exports= {
882
+
experimental: {
883
+
instrumentationHook:true, // Not required on Next.js 15+
884
+
},
885
+
}
886
+
```
887
+
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:
891
+
892
+
```JavaScript {filename:instrumentation.js}
893
+
import*asSentryfrom'@sentry/nextjs';
894
+
895
+
exportasyncfunctionregister() {
896
+
if (process.env.NEXT_RUNTIME==='nodejs') {
897
+
awaitimport('./sentry.server.config');
898
+
}
899
+
900
+
if (process.env.NEXT_RUNTIME==='edge') {
901
+
awaitimport('./sentry.edge.config');
902
+
}
903
+
}
904
+
```
905
+
906
+
Note that you can initialize the SDK differently depending on which server runtime is being used.
925
907
926
908
If you are using a
927
909
[Next.js custom server](https://nextjs.org/docs/pages/building-your-application/configuring/custom-server), the
0 commit comments