|
1 | 1 | --- |
2 | 2 | title: Remix on Cloudflare |
3 | | -description: "Learn how to add Cloudflare instrumentation to your Remix app." |
| 3 | +description: "Learn how to instrument your Remix app on Cloudflare Workers and Pages and capture your first errors with Sentry." |
4 | 4 | --- |
5 | 5 |
|
6 | | -If you're running your Remix app on Cloudflare Pages, you can use the Sentry Remix SDK in combination with the Sentry Cloudflare SDK to add Sentry instrumentation. |
7 | | - |
8 | | -## Install |
9 | | - |
10 | | -First, install the Sentry Remix SDK in your application. We recommend using the Sentry wizard to automatically install the SDK: |
11 | | - |
12 | | -```bash |
13 | | -npx @sentry/wizard@latest -i remix |
14 | | -``` |
15 | | - |
16 | | -If the setup through the wizard doesn't work for you, you can also [set up the Remix SDK manually](/platforms/javascript/guides/remix/manual-setup/). |
17 | | - |
18 | | -After installing the Sentry Remix SDK, delete the newly generated `instrumentation.server.mjs` file. This instrumentation is not needed when using the Cloudflare SDK. |
19 | | - |
20 | | -Now you can install the Sentry Cloudflare SDK. First, install the SDK with your package manager: |
21 | | - |
22 | | -<PlatformContent includePath="getting-started-install" /> |
23 | | - |
24 | | -## Setup |
25 | | - |
26 | | -The main Sentry configuration should happen as early as possible in your app's lifecycle. |
27 | | - |
28 | | -<PlatformContent includePath="getting-started-config" /> |
29 | | - |
30 | | -Then create a `_middleware.js` file in your `functions` directory and add the following code: |
31 | | - |
32 | | -```javascript {filename:functions/_middleware.js} |
33 | | -import * as Sentry from "@sentry/cloudflare"; |
34 | | - |
35 | | -export const onRequest = [ |
36 | | - // Make sure Sentry is the first middleware |
37 | | - Sentry.sentryPagesPlugin((context) => ({ |
38 | | - dsn: "___PUBLIC_DSN___", |
39 | | - // Set tracesSampleRate to 1.0 to capture 100% of spans for tracing. |
40 | | - tracesSampleRate: 1.0, |
41 | | - })), |
42 | | - // Add more middlewares here |
43 | | -]; |
44 | | -``` |
| 6 | +<PlatformContent |
| 7 | + includePath="getting-started-complete" |
| 8 | + platform="javascript.remix" |
| 9 | +/> |
0 commit comments