Skip to content
Open
Show file tree
Hide file tree
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
56 changes: 56 additions & 0 deletions docs/platforms/javascript/guides/cloudflare/frameworks/nextjs.mdx
Original file line number Diff line number Diff line change
@@ -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

<Alert type="info">
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.
</Alert>

## 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.
1 change: 1 addition & 0 deletions docs/platforms/javascript/guides/cloudflare/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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/)**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

<Alert type="info">
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.
</Alert>

## 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.