Skip to content

Commit ea34e1a

Browse files
docs(js): Use split layout in Astro & Hydrogen with React Router quick start guides (#17315)
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## DESCRIBE YOUR PR This branch updates the following quick start guides to use the new split layout: - Astro - Astro on Cloudflare - Hydrogen with React Router (Cloudflare) Closes: #17314 ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)
1 parent 2670036 commit ea34e1a

File tree

4 files changed

+337
-58
lines changed

4 files changed

+337
-58
lines changed

docs/platforms/javascript/guides/astro/index.mdx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ You need:
1919
- If you're using Astro's Netlify adapter (`@astrojs/netlify`), you need version `5.0.0` or above
2020

2121
<Alert level="warning" title="What runtime do you use?">
22-
This SDK currently only works on Node runtimes, such as Node adapter or Vercel
23-
with Lambda functions. If you use Cloudflare Workers or Cloudflare Pages, refer to our [Astro on
24-
Cloudflare guide](/platforms/javascript/guides/cloudflare/frameworks/astro/).
25-
Other non-Node runtimes, like Vercel's Edge runtime, are currently **not
26-
supported**.
22+
23+
This SDK currently only works on Node runtimes, such as Node adapter or Vercel
24+
with Lambda functions. If you use Cloudflare Workers or Cloudflare Pages, refer to our [Astro on
25+
Cloudflare guide](/platforms/javascript/guides/cloudflare/frameworks/astro/).
26+
Other non-Node runtimes, like Vercel's Edge runtime, are currently **not
27+
supported**.
28+
2729
</Alert>
2830

29-
## Step 1: Install
31+
<StepConnector selector="h2" showNumbers={true}>
32+
33+
## Install
3034

3135
Choose the features you want to configure, and this guide will show you how:
3236

@@ -44,3 +48,5 @@ Choose the features you want to configure, and this guide will show you how:
4448
<Include name="quick-start-features-expandable" />
4549

4650
<PlatformContent includePath="getting-started-complete" />
51+
52+
</StepConnector>

docs/platforms/javascript/guides/cloudflare/frameworks/astro.mdx

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@ Sentry integration and full feature support.
1919

2020
<Expandable level="info" title="Using Astro on Cloudflare Pages?">
2121

22+
<SplitLayout>
23+
2224
For Cloudflare Pages, you need to manually set up the `@sentry/cloudflare` SDK using the Pages middleware.
2325

26+
<SplitSection>
27+
<SplitSectionText>
28+
2429
1. Install both SDKs:
2530

31+
</SplitSectionText>
32+
<SplitSectionCode>
33+
2634
```bash {tabTitle:npm}
2735
npm install @sentry/astro @sentry/cloudflare
2836
```
@@ -35,8 +43,17 @@ yarn add @sentry/astro @sentry/cloudflare
3543
pnpm add @sentry/astro @sentry/cloudflare
3644
```
3745

46+
</SplitSectionCode>
47+
</SplitSection>
48+
49+
<SplitSection>
50+
<SplitSectionText>
51+
3852
2. Add the Sentry Astro integration to your `astro.config.mjs`:
3953

54+
</SplitSectionText>
55+
<SplitSectionCode>
56+
4057
```javascript {filename:astro.config.mjs}
4158
import { defineConfig } from "astro/config";
4259
import cloudflare from "@astrojs/cloudflare";
@@ -48,8 +65,17 @@ export default defineConfig({
4865
});
4966
```
5067

68+
</SplitSectionCode>
69+
</SplitSection>
70+
71+
<SplitSection>
72+
<SplitSectionText>
73+
5174
3. <Include name="cloudflare-pages-middleware-intro.mdx" />
5275

76+
</SplitSectionText>
77+
<SplitSectionCode>
78+
5379
```javascript {filename:functions/_middleware.js}
5480
import * as Sentry from "@sentry/cloudflare";
5581

@@ -64,11 +90,22 @@ export const onRequest = [
6490
];
6591
```
6692

93+
</SplitSectionCode>
94+
</SplitSection>
95+
96+
<SplitSection>
97+
<SplitSectionText>
98+
6799
4. Make sure to [configure Cloudflare for Sentry](/platforms/javascript/guides/cloudflare/#wrangler-configuration).
68100

101+
</SplitSectionText>
102+
</SplitSection>
103+
</SplitLayout>
69104
</Expandable>
70105

71-
## Step 1: Install
106+
<StepConnector selector="h2" showNumbers={true}>
107+
108+
## Install
72109

73110
<OnboardingOptionButtons
74111
options={[
@@ -86,3 +123,5 @@ export const onRequest = [
86123
includePath="getting-started-complete"
87124
platform="javascript.astro"
88125
/>
126+
127+
</StepConnector>

docs/platforms/javascript/guides/cloudflare/frameworks/hydrogen-react-router.mdx

Lines changed: 115 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ You need:
1616
- A Sentry [account](https://sentry.io/signup/) and [project](/product/projects/)
1717
- Your Hydrogen application (v2025.5.0+), you want to host on Shopify Oxygen
1818

19-
## Step 1: Install
19+
<StepConnector selector="h2" showNumbers={true}>
20+
21+
## Install
2022

2123
Choose the features you want to configure, and this guide will show you how:
2224

@@ -34,8 +36,15 @@ Choose the features you want to configure, and this guide will show you how:
3436

3537
### Install the Sentry SDK
3638

39+
<SplitLayout>
40+
<SplitSection>
41+
<SplitSectionText>
42+
3743
Run the command for your preferred package manager to add the React Router and Cloudflare SDK:
3844

45+
</SplitSectionText>
46+
<SplitSectionCode>
47+
3948
```bash {tabTitle:npm}
4049
npm install @sentry/react-router @sentry/cloudflare --save
4150
```
@@ -48,11 +57,24 @@ yarn add @sentry/react-router @sentry/cloudflare
4857
pnpm add @sentry/react-router @sentry/cloudflare
4958
```
5059

51-
## Step 2: Configure
60+
</SplitSectionCode>
61+
</SplitSection>
62+
</SplitLayout>
63+
64+
## Configure
5265

5366
### Configure Client-side Sentry
5467

55-
Initialize Sentry in your `entry.client.tsx` file:
68+
<SplitLayout>
69+
<SplitSection>
70+
<SplitSectionText>
71+
72+
Initialize Sentry in your `entry.client.tsx` file.
73+
74+
The `sentryOnError` handler integrates with React Router's [`onError` hook](https://reactrouter.com/how-to/error-reporting) to automatically capture and report client-side errors to Sentry.
75+
76+
</SplitSectionText>
77+
<SplitSectionCode>
5678

5779
```tsx {filename: app/entry.client.tsx}
5880
import { HydratedRouter } from "react-router/dom";
@@ -121,12 +143,21 @@ startTransition(() => {
121143
});
122144
```
123145

124-
The `sentryOnError` handler integrates with React Router's [`onError` hook](https://reactrouter.com/how-to/error-reporting) to automatically capture and report client-side errors to Sentry.
146+
</SplitSectionCode>
147+
</SplitSection>
148+
</SplitLayout>
125149

126150
### Configure Server-side Sentry
127151

152+
<SplitLayout>
153+
<SplitSection>
154+
<SplitSectionText>
155+
128156
First, create an `instrument.server.mjs` file to initialize Sentry on the server:
129157

158+
</SplitSectionText>
159+
<SplitSectionCode>
160+
130161
```js {filename:instrument.server.mjs}
131162
import * as Sentry from "@sentry/react-router";
132163

@@ -153,8 +184,17 @@ Sentry.init({
153184
});
154185
```
155186

187+
</SplitSectionCode>
188+
</SplitSection>
189+
190+
<SplitSection>
191+
<SplitSectionText>
192+
156193
Next, update your `server.ts` file to use the `wrapRequestHandler` method from `@sentry/cloudflare`:
157194

195+
</SplitSectionText>
196+
<SplitSectionCode>
197+
158198
```ts {filename:server.ts}
159199
import { wrapRequestHandler } from "@sentry/cloudflare";
160200
// ...other imports
@@ -201,12 +241,23 @@ export default {
201241
};
202242
```
203243

244+
</SplitSectionCode>
245+
</SplitSection>
246+
</SplitLayout>
247+
204248
<OnboardingOption optionId="performance">
205249

206250
### Enable Distributed Tracing
207251

252+
<SplitLayout>
253+
<SplitSection>
254+
<SplitSectionText>
255+
208256
Update your `entry.server.tsx` file to inject trace meta tags:
209257

258+
</SplitSectionText>
259+
<SplitSectionCode>
260+
210261
```tsx {filename:app/entry.server.tsx}
211262
import "./instrument.server";
212263
import { HandleErrorFunction, ServerRouter } from "react-router";
@@ -248,13 +299,24 @@ export const handleError: HandleErrorFunction = (error, { request }) => {
248299
export default Sentry.wrapSentryHandleRequest(handleRequest);
249300
```
250301

302+
</SplitSectionCode>
303+
</SplitSection>
304+
</SplitLayout>
305+
251306
</OnboardingOption>
252307

253-
## Step 3: Add Readable Stack Traces With Source Maps (Optional)
308+
### Add Readable Stack Traces With Source Maps (Optional)
309+
310+
<SplitLayout>
311+
<SplitSection>
312+
<SplitSectionText>
254313

255314
The stack traces in your Sentry errors probably won't look like your actual code without unminifying them. To fix this, upload your source maps to Sentry.
256315

257-
First, update `vite.config.ts` to include the `sentryReactRouter` plugin, making sure to pass both the Vite and Sentry configurations to it:
316+
First, update `vite.config.ts` to include the `sentryReactRouter` plugin, making sure to pass both the Vite and Sentry configurations to it.
317+
318+
</SplitSectionText>
319+
<SplitSectionCode>
258320

259321
```ts {filename:vite.config.ts}
260322
import { reactRouter } from "@react-router/dev/vite";
@@ -284,7 +346,16 @@ export default defineConfig((config) => ({
284346
}));
285347
```
286348

287-
Since the `buildEnd` hook will not be executed for Hydrogen, you need to manually upload source maps using the [Sentry CLI](/cli/) instead:
349+
</SplitSectionCode>
350+
</SplitSection>
351+
352+
<SplitSection>
353+
<SplitSectionText>
354+
355+
Since the `buildEnd` hook will not be executed for Hydrogen, you need to manually upload source maps using the [Sentry CLI](/cli/) instead.
356+
357+
</SplitSectionText>
358+
<SplitSectionCode>
288359

289360
```bash
290361
# Inject debug IDs
@@ -293,13 +364,28 @@ sentry-cli sourcemaps inject /path/to/build/dir
293364
sentry-cli sourcemaps upload /path/to/build/dir
294365
```
295366

296-
## Step 4: Verify Your Setup
367+
</SplitSectionCode>
368+
</SplitSection>
369+
</SplitLayout>
370+
371+
## Verify Your Setup
297372

298373
Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project.
299374

300375
### Issues
301376

302-
To verify that Sentry captures errors and creates issues in your Sentry project, throw an error in a loader:
377+
<SplitLayout>
378+
<SplitSection>
379+
<SplitSectionText>
380+
381+
<PlatformContent includePath="getting-started-browser-sandbox-warning" />
382+
383+
To verify that Sentry captures errors and creates issues in your Sentry project, throw an error in a loader.
384+
385+
Next, open the `/sentry-test` route in your browser, and you should trigger an error.
386+
387+
</SplitSectionText>
388+
<SplitSectionCode>
303389

304390
```tsx {filename: app/routes/sentry-test.tsx}
305391
import type { Route } from "./+types/sentry-test";
@@ -313,16 +399,23 @@ export default function SentryTestPage() {
313399
}
314400
```
315401

316-
<OnboardingOption optionId="performance" hideForThisOption>
317-
Open the `/sentry-test` route in your browser, and you should trigger an
318-
error.
319-
</OnboardingOption>
320-
321-
<PlatformContent includePath="getting-started-browser-sandbox-warning" />
402+
</SplitSectionCode>
403+
</SplitSection>
404+
</SplitLayout>
322405

323406
<OnboardingOption optionId="performance">
324407
### Tracing
325-
To test your tracing configuration, update the previous code snippet by starting a trace to measure the time it takes for the execution of your code:
408+
409+
<SplitLayout>
410+
<SplitSection>
411+
<SplitSectionText>
412+
413+
To test your tracing configuration, update the previous code snippet by starting a trace to measure the time it takes for the execution of your code.
414+
415+
Open the `/sentry-test` route in your browser. You should start a trace and trigger an error.
416+
417+
</SplitSectionText>
418+
<SplitSectionCode>
326419

327420
```tsx {filename: app/routes/sentry-test.tsx}
328421
import * as Sentry from "@sentry/react-router/cloudflare";
@@ -345,13 +438,15 @@ export default function SentryTestPage() {
345438
}
346439
```
347440

348-
Open the `/sentry-test` route in your browser. You should start a trace and trigger an error.
441+
</SplitSectionCode>
442+
</SplitSection>
443+
</SplitLayout>
349444

350445
</OnboardingOption>
351446

352447
<OnboardingOption optionId="logs">
353448

354-
<Include name="logs/javascript-quick-start-verify-logs" />
449+
<Include name="logs/javascript-quick-start-verify-logs-splitlayout" />
355450

356451
</OnboardingOption>
357452

@@ -380,3 +475,5 @@ Our next recommended steps for you are:
380475
- [Get support](https://sentry.zendesk.com/hc/en-us/)
381476

382477
</Expandable>
478+
479+
</StepConnector>

0 commit comments

Comments
 (0)