-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there! I'm Liza, the new docs manager. Apologies for this taking me a while to look over. I've made a few tweaks. Please let me know if you have any questions!
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Superseded by #5789 |
ATTENTION: Do not merge before this feature has shipped in the SDK
This PR adds a section to the Next.js troubleshooting guide on how to set up the SDK if you have API routes running on the Vercel Edge runtime.