Skip to content

docs: Clarify Node.js specific imports in Next.js register hook migration guide #11878

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
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
18 changes: 18 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,24 @@ The following is an example of how to initialize the serverside SDK in a Next.js
}
```

If you need to import a Node.js specific integration (like for example `@sentry/profiling-node`), you will have to
import the package using a dynamic import to prevent Next.js from bundling Node.js APIs into bundles for other
runtime environments (like the Browser or the Edge runtime). You can do so as follows:

```ts
import * as Sentry from '@sentry/nextjs';

export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
const { nodeProfilingIntegration } = await import('@sentry/profiling-node');
Sentry.init({
dsn: 'YOUR_DSN',
integrations: [nodeProfilingIntegration()],
});
}
}
```

Note that you can initialize the SDK differently depending on which server runtime is being used.

If you are using a
Expand Down
Loading