You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b9eafdf
Browse filesBrowse the repository at this point in the historyBrowse files
feat(onboarding): Update TanStack Start setup to match the docs (#132137)
Update the TanStack Start React onboarding to match the new setup in the
docs (getsentry/sentry-docs#20910).
- With Nitro, the Vite plugin loads `instrument.server` at startup, so
the `--import` flag is only needed for `vite dev`
- Fix the dead docs link for setups without `--import`
- Forward `opts` in `src/server.ts`
- Add `createCsrfMiddleware` to `src/start.ts`
- Replace the outdated error boundary, `errorComponent` and tunneling
snippets with a link to the docs, like Astro and SolidStart do
Refs JSSDK-59
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
"If you can't use the [code:--import] flag (e.g. in serverless environments like Vercel or Netlify), follow the [link:TanStack Start React guide] for alternative setup instructions.",
text: tct('Create a [code:src/server.ts] file in your project:',{
242
-
code: <code/>,
243
-
}),
227
+
text: tct(
228
+
"Create a [code:src/server.ts] file in your project. Pass [code:opts] on to the handler, so the request context that TanStack Start passes to it isn't lost:",
229
+
{code: <code/>}
230
+
),
244
231
},
245
232
{
246
233
type: 'code',
@@ -250,15 +237,18 @@ ${
250
237
language: 'typescript',
251
238
filename: 'src/server.ts',
252
239
code: `import { wrapFetchWithSentry } from "@sentry/tanstackstart-react";
253
-
import handler, { createServerEntry } from "@tanstack/react-start/server-entry";
240
+
import handler, {
241
+
createServerEntry,
242
+
} from "@tanstack/react-start/server-entry";
243
+
import type { ServerEntry } from "@tanstack/react-start/server-entry";
'For production monitoring, you need to move the Sentry server config file to your build output. Since [hostingLink:TanStack Start is designed to work with any hosting provider], the exact location will depend on where your build artifacts are deployed (for example, [code:/dist], [code:.output/server] or a platform-specific directory).',
'If your app builds with [nitroLink:Nitro] for a Node.js runtime, the [code:sentryTanstackStart] Vite plugin bundles [code:instrument.server.mjs] into the server build and loads it when the server starts. You start your production build as usual, without the [code:--import] flag.',
"[code:vite dev] doesn't create a server build, so in development, load the file with the [code:--import] flag in the [code:NODE_OPTIONS] environment variable:",
"dev": "NODE_OPTIONS='--import ./instrument.server.mjs' vite dev --port 3000",
312
+
"start": "node .output/server/index.mjs",
325
313
}
326
314
}`,
327
315
},
328
316
],
329
317
},
330
318
{
331
-
type: 'text',
319
+
type: 'alert',
320
+
alertType: 'info',
321
+
showIcon: true,
332
322
text: tct(
333
-
'Add a [code:--import] flag directly or to the [code:NODE_OPTIONS] environment variable wherever you run your application to import [code:instrument.server.mjs]:',
334
-
{code: <code/>}
335
-
),
336
-
},
337
-
{
338
-
type: 'code',
339
-
tabs: [
323
+
"If you deploy to Node.js without Nitro, or to Cloudflare, the plugin doesn't load the server config for you. Follow the [link:TanStack Start React guide] for these setups.",
"To capture server-side errors from HTTP requests and server function invocations, add Sentry's global middlewares to [code:createStart()] in your [code:src/start.ts] file:",
334
+
"To capture server-side errors from HTTP requests and server function invocations, add Sentry's global middlewares to [code:createStart()] in your [code:src/start.ts] file. A custom [code:src/start.ts] turns off the CSRF protection that TanStack Start adds to server functions by default, so the snippet adds it back with [code:createCsrfMiddleware]:",
'The Sentry middleware should be the first middleware in the arrays to ensure all errors are captured. SSR rendering exceptions are not captured by the middleware. Use captureException to manually capture those errors.'
371
+
'The Sentry middleware should be the first middleware in the arrays to ensure all errors are captured.'
389
372
),
390
373
},
391
374
{
392
375
type: 'text',
393
376
text: tct(
394
-
"Errors caught by your own error boundaries aren't captured unless you report them manually. Wrap your custom [code:ErrorBoundary] component with [code:withErrorBoundary]:",
395
-
{code: <code/>}
396
-
),
397
-
},
398
-
{
399
-
type: 'code',
400
-
tabs: [
377
+
'To capture errors from route loaders, error boundaries and [code:errorComponent]s, and to send events through a tunnel to avoid ad blockers, follow the [link:TanStack Start React guide].',
401
378
{
402
-
label: 'TypeScript',
403
-
language: 'tsx',
404
-
code: `import React from "react";
405
-
import * as Sentry from "@sentry/tanstackstart-react";
'If you defined [code:errorComponents] in your Code-Based TanStack Router routes, capture the [code:error] argument with [code:captureException] inside a [code:useEffect] hook:',
code: `import { createRoute } from "@tanstack/react-router";
434
-
import * as Sentry from "@sentry/tanstackstart-react";
435
-
436
-
const route = createRoute({
437
-
errorComponent: ({ error }) => {
438
-
useEffect(() => {
439
-
Sentry.captureException(error)
440
-
}, [error])
441
-
442
-
return (
443
-
// ...
444
-
)
445
-
}
446
-
})`,
447
-
},
448
-
],
449
-
},
450
386
],
451
387
},
452
388
{
@@ -473,39 +409,6 @@ const route = createRoute({
473
409
],
474
410
collapsible: true,
475
411
},
476
-
{
477
-
title: t('Avoid Ad Blockers With Tunneling (Optional)'),
478
-
content: [
479
-
{
480
-
type: 'text',
481
-
text: tct(
482
-
'You can prevent ad blockers from blocking Sentry events using tunneling. Use the [code:tunnel] option to add an API endpoint in your application that forwards Sentry events to Sentry servers.',
483
-
{code: <code/>}
484
-
),
485
-
},
486
-
{
487
-
type: 'text',
488
-
text: tct(
489
-
'To enable tunneling, update [code:Sentry.init] with the following option:',
0 commit comments