Skip to content

Add section on how to set up the Next.js SDK with the Vercel Edge Runtime #5713

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

Closed
wants to merge 2 commits into from
Closed
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
35 changes: 35 additions & 0 deletions src/platforms/javascript/common/troubleshooting/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -449,3 +449,38 @@ export default defineConfig({
plugins: [react()]
})
```

<PlatformSection supported={["javascript.nextjs"]}>

## Vercel Experimental Edge Runtime

The Sentry Next.js SDK does not yet support the [Vercel Edge Runtime](https://vercel.com/docs/concepts/functions/edge-functions) which is used in Next.js middleware and Edge Routes when deployed on Vercel.
If you want to use the Edge Runtime in combination with the Sentry SDK you need to manually opt the API routes that use the Edge Runtime out of Sentry instrumentation via the `excludedServersideEntrypoints` option in your `next.config.js`.

For example: Opting out the route `/api/posts` and all the routes starting with `/api/users/` will work like the following.

```javascript {filename:next.config.js}
const { withSentryConfig } = require("@sentry/nextjs");

const nextConfig = {
// Next.js configuration options...

sentry: {
excludedServersideEntrypoints: [
"pages/api/posts",
/^pages\/api\/users\/.*/,
],
// Other optional Sentry build-time configuration options...
},
};

const sentryWebpackPluginOptions = {
// Sentry Webpack Plugin options...
};

module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions);
```

Please note that this will effectively disable the Sentry SDK for these API routes - removing all error and performance monitoring.
Comment on lines +457 to +484
Copy link
Contributor

@lizokm lizokm Nov 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The Sentry Next.js SDK does not yet support the [Vercel Edge Runtime](https://vercel.com/docs/concepts/functions/edge-functions) which is used in Next.js middleware and Edge Routes when deployed on Vercel.
If you want to use the Edge Runtime in combination with the Sentry SDK you need to manually opt the API routes that use the Edge Runtime out of Sentry instrumentation via the `excludedServersideEntrypoints` option in your `next.config.js`.
For example: Opting out the route `/api/posts` and all the routes starting with `/api/users/` will work like the following.
```javascript {filename:next.config.js}
const { withSentryConfig } = require("@sentry/nextjs");
const nextConfig = {
// Next.js configuration options...
sentry: {
excludedServersideEntrypoints: [
"pages/api/posts",
/^pages\/api\/users\/.*/,
],
// Other optional Sentry build-time configuration options...
},
};
const sentryWebpackPluginOptions = {
// Sentry Webpack Plugin options...
};
module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions);
```
Please note that this will effectively disable the Sentry SDK for these API routes - removing all error and performance monitoring.
The Sentry Next.js SDK doesn’t currently support [Vercel Edge Runtime](https://vercel.com/docs/concepts/functions/edge-functions) (which is used in Next.js middleware and Edge Routes when deployed on Vercel).
To use Edge Runtime in combination with the Sentry SDK, you'll need to manually opt out of the API routes that use the Edge Runtime in Sentry instrumentation using the `excludedServersideEntrypoints` option in your `next.config.js`.
For example: Opting out the route `/api/posts` and all the routes starting with `/api/users/` will work like this:
```javascript {filename:next.config.js}
const { withSentryConfig } = require("@sentry/nextjs");
const nextConfig = {
// Next.js configuration options...
sentry: {
excludedServersideEntrypoints: [
"pages/api/posts",
/^pages\/api\/users\/.*/,
],
// Other optional Sentry build-time configuration options...
},
};
const sentryWebpackPluginOptions = {
// Sentry Webpack Plugin options...
};
module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions);

Please note, this will effectively disable the Sentry SDK for these API routes and remove all error and performance monitoring.


</PlatformSection>