From 5523afc67b00bdbb7c292ba1351e87e0c2f46b4a Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Fri, 30 Jan 2026 11:36:22 +0100 Subject: [PATCH] feat(cloudflare,nextjs): Move NextJS on CF instructions directly to CF --- .../guides/cloudflare/frameworks/nextjs.mdx | 56 +++++++++++++++++ .../javascript/guides/cloudflare/index.mdx | 1 + .../deploying-on-cloudflare.mdx | 60 +------------------ 3 files changed, 58 insertions(+), 59 deletions(-) create mode 100644 docs/platforms/javascript/guides/cloudflare/frameworks/nextjs.mdx diff --git a/docs/platforms/javascript/guides/cloudflare/frameworks/nextjs.mdx b/docs/platforms/javascript/guides/cloudflare/frameworks/nextjs.mdx new file mode 100644 index 00000000000000..a236d8204effa9 --- /dev/null +++ b/docs/platforms/javascript/guides/cloudflare/frameworks/nextjs.mdx @@ -0,0 +1,56 @@ +--- +title: Next.js on Cloudflare +description: "Learn how to configure Sentry for your Next.js application deployed on Cloudflare Workers." +--- + +The Sentry Next.js SDK supports Next.js applications deployed on Cloudflare Workers, but requires additional configuration to run in this environment. + +## Prerequisites + +Before you begin, make sure you have: + +- A Sentry [account](https://sentry.io/signup/) and [project](/product/projects/) +- A [Cloudflare Workers project](https://dash.cloudflare.com/workers/overview) +- A Next.js application configured for Cloudflare Workers with [OpenNext](https://opennext.js.org/cloudflare) +- The Sentry SDK [installed and configured](/platforms/javascript/guides/nextjs/) in your Next.js application + + + If you haven't deployed a Next.js app to Cloudflare Workers before, follow + Cloudflare's [Next.js deployment + guide](https://developers.cloudflare.com/workers/framework-guides/web-apps/nextjs/) + to get started. + + +## Configure Wrangler + +Once you've set up Sentry in your Next.js application following the [installation guide](/platforms/javascript/guides/nextjs/), you'll need to configure Wrangler with the required compatibility settings. + +First, add the `nodejs_compat` [compatibility flag](https://developers.cloudflare.com/workers/runtime-apis/nodejs/) to configure the Cloudflare Workers runtime to provide the Node.js APIs required by the Sentry SDK. + +```json {tabTitle:wrangler.jsonc} +{ + "compatibility_flags": ["nodejs_compat"] +} +``` + +```toml {tabTitle:wrangler.toml} +compatibility_flags = ["nodejs_compat"] +``` + +Then, set the [compatibility date](https://developers.cloudflare.com/workers/configuration/compatibility-dates/) to `2025-08-16` or later. This is required to introduce `https.request` to the Cloudflare Workers runtime, which the Sentry SDK needs to send data. + +Your final configuration should look like this: + +```json {tabTitle:wrangler.jsonc} +{ + "compatibility_flags": ["nodejs_compat"], + "compatibility_date": "2025-08-16" +} +``` + +```toml {tabTitle:wrangler.toml} +compatibility_flags = ["nodejs_compat"] +compatibility_date = "2025-08-16" +``` + +After adding these settings, build and deploy your Next.js application to Cloudflare Workers. You should start seeing error events, traces, and logs appear in Sentry. diff --git a/docs/platforms/javascript/guides/cloudflare/index.mdx b/docs/platforms/javascript/guides/cloudflare/index.mdx index 46d8ff82bcf8bb..d089182dd1f765 100644 --- a/docs/platforms/javascript/guides/cloudflare/index.mdx +++ b/docs/platforms/javascript/guides/cloudflare/index.mdx @@ -14,6 +14,7 @@ Use this guide for general instructions on using the Sentry SDK with Cloudflare. - **[Astro](/platforms/javascript/guides/cloudflare/frameworks/astro/)** - **[Hono](/platforms/javascript/guides/cloudflare/frameworks/hono/)** - **[Hydrogen](/platforms/javascript/guides/cloudflare/frameworks/hydrogen-react-router/)** +- **[Next.js](/platforms/javascript/guides/cloudflare/frameworks/nextjs/)** - **[Nuxt](/platforms/javascript/guides/cloudflare/frameworks/nuxt/)** - **[Remix](/platforms/javascript/guides/cloudflare/frameworks/remix/)** - **[SvelteKit](/platforms/javascript/guides/cloudflare/frameworks/sveltekit/)** diff --git a/docs/platforms/javascript/guides/nextjs/best-practices/deploying-on-cloudflare.mdx b/docs/platforms/javascript/guides/nextjs/best-practices/deploying-on-cloudflare.mdx index eb6d1edbd19457..2fc24a86298069 100644 --- a/docs/platforms/javascript/guides/nextjs/best-practices/deploying-on-cloudflare.mdx +++ b/docs/platforms/javascript/guides/nextjs/best-practices/deploying-on-cloudflare.mdx @@ -4,62 +4,4 @@ description: "Learn how to configure Sentry for your Next.js application deploye sidebar_section: configuration --- -The Sentry Next.js SDK supports Next.js applications deployed on Cloudflare Workers, but requires additional configuration to run in this environment. - -## Prerequisites - -Before you begin, make sure you have: - -- A Sentry [account](https://sentry.io/signup/) and [project](/product/projects/) -- A [Cloudflare Workers project](https://dash.cloudflare.com/workers/overview) -- A Next.js application configured for Cloudflare Workers with [OpenNext](https://opennext.js.org/cloudflare) -- The Sentry SDK [installed and configured](/platforms/javascript/guides/nextjs/) in your Next.js application - - - If you haven't deployed a Next.js app to Cloudflare Workers before, follow - Cloudflare's [Next.js deployment - guide](https://developers.cloudflare.com/workers/framework-guides/web-apps/nextjs/) - to get started. - - -## Configure Wrangler - -Once you've set up Sentry in your Next.js application following the [installation guide](/platforms/javascript/guides/nextjs/), you'll need to configure Wrangler with the required compatibility settings. - -First, add the `nodejs_compat` [compatibility flag](https://developers.cloudflare.com/workers/runtime-apis/nodejs/) to configure the Cloudflare Workers runtime to provide the Node.js APIs required by the Sentry SDK. - -```json {tabTitle:wrangler.jsonc} -{ - "compatibility_flags": ["nodejs_compat"] -} -``` - -```toml {tabTitle:wrangler.toml} -compatibility_flags = ["nodejs_compat"] -``` - -Then, set the [compatibility date](https://developers.cloudflare.com/workers/configuration/compatibility-dates/) to `2025-08-16` or later. This is required to introduce `https.request` to the Cloudflare Workers runtime, which the Sentry SDK needs to send data. - -Your final configuration should look like this: - -```json {tabTitle:wrangler.jsonc} -{ - "compatibility_flags": ["nodejs_compat"], - "compatibility_date": "2025-08-16" -} -``` - -```toml {tabTitle:wrangler.toml} -compatibility_flags = ["nodejs_compat"] -compatibility_date = "2025-08-16" -``` - -After adding these settings, build and deploy your Next.js application to Cloudflare Workers. You should start seeing error events, traces, and logs appear in Sentry. - -## Known Limitations - -### Server-Side Span Durations - -Server-side spans will display `0ms` for their durations due to a security measure Cloudflare Workers implements to prevent timing attacks. This is expected behavior in the Cloudflare Workers environment. - -For more information about this limitation, see the [Cloudflare Workers documentation on Performance APIs](https://developers.cloudflare.com/workers/runtime-apis/performance/). +For instructions on deploying your Next.js application with Sentry on Cloudflare Workers, see the [Next.js on Cloudflare](/platforms/javascript/guides/cloudflare/frameworks/nextjs/) guide.