PluginBench
Skill
Official
Pass
Audit score 90

sentry-react-router-framework-sdk

getsentry/sentry-for-ai

Full Sentry SDK setup for React Router Framework v7 with error monitoring, tracing, profiling, and session replay.

What is sentry-react-router-framework-sdk?

Complete Sentry integration wizard and manual configuration guide for React Router Framework mode. Use this when setting up error monitoring, tracing, profiling, session replay, logs, or user feedback in a React Router v7 framework application with client and server entry points.

  • Scans React Router Framework project structure and detects existing Sentry packages
  • Guides setup of @sentry/react-router across client (entry.client.tsx) and server (entry.server.tsx) entry points
  • Configures error monitoring, distributed tracing, and session replay with framework-specific integrations
  • Enables optional server-side profiling with @sentry/profiling-node and structured logging
  • Provides both interactive wizard (npx @sentry/wizard) and manual step-by-step configuration paths
  • Handles source map upload setup and server instrumentation startup via NODE_OPTIONS --import

How to install sentry-react-router-framework-sdk

npx skills add https://github.com/getsentry/sentry-for-ai --skill sentry-react-router-framework-sdk
Prerequisites
  • React Router v7 framework project with entry.client.tsx and entry.server.tsx files
  • Node.js runtime with npm or yarn package manager
  • Sentry account and project DSN (obtain from sentry.io)
  • Optional: @sentry/profiling-node for server-side profiling support
Claude Code
Cursor
Windsurf
Cline

How to use sentry-react-router-framework-sdk

  1. 1.Run detection commands to check for existing @sentry/react-router, framework entry files, and optional dependencies
  2. 2.Review the recommendation table and decide which features to enable (error monitoring, tracing, session replay, profiling, logs, user feedback)
  3. 3.Either run the interactive wizard (npx @sentry/wizard@latest -i reactRouter) or follow manual setup steps
  4. 4.If using manual setup: install @sentry/react-router, run npx react-router reveal to expose entry files, configure client initialization in entry.client.tsx with integrations
  5. 5.Configure server instrumentation in instrument.server.mjs with Sentry.init and nodeProfilingIntegration if desired
  6. 6.Wrap server handlers in entry.server.tsx using Sentry.createSentryHandleRequest and Sentry.createSentryHandleError
  7. 7.Set NODE_OPTIONS='--import ./instrument.server.mjs' in dev and start scripts to load server instrumentation on startup
  8. 8.Run verification examples and test error/transaction capture in development before deploying

Use cases

Good for
  • Adding Sentry error monitoring and tracing to a new React Router v7 framework application
  • Enabling session replay and user feedback widgets in an existing React Router framework app
  • Setting up server-side profiling to investigate Node.js performance bottlenecks
  • Configuring cross-origin request tracing between React Router client and backend services
  • Integrating structured logging and error correlation in a full-stack React Router application
Who it's for
  • Full-stack developers building React Router v7 framework applications
  • DevOps and SRE teams setting up observability for isomorphic React applications
  • Teams needing client and server error tracking in a single Sentry project
  • Performance engineers investigating server-side bottlenecks with profiling data

sentry-react-router-framework-sdk FAQ

Should I use this skill or sentry-react-sdk?

Use this skill for React Router v7 framework mode with entry.client.tsx and entry.server.tsx. Use sentry-react-sdk for React Router v5/v6/v7 in non-framework/data/declarative mode with @sentry/react.

Is @sentry/react-router production-ready?

The SDK is currently in beta. It is functional for error monitoring and tracing but may have breaking changes in future releases.

Do I need to run the wizard or can I configure manually?

The wizard is recommended and interactive, but you can skip it and follow the manual setup steps provided. Both approaches result in the same configuration.

How do I enable server-side profiling?

Install @sentry/profiling-node, import nodeProfilingIntegration in instrument.server.mjs, add it to the integrations array, and set profileSessionSampleRate in Sentry.init.

What does NODE_OPTIONS --import do?

It loads instrument.server.mjs before the application starts, ensuring server-side Sentry initialization happens early and captures all errors and transactions from startup.

Full instructions (SKILL.md)

Source of truth, from getsentry/sentry-for-ai.


name: sentry-react-router-framework-sdk description: Full Sentry SDK setup for React Router Framework mode. Use when asked to "add Sentry to React Router Framework", "install @sentry/react-router", or configure error monitoring, tracing, profiling, session replay, logs, or user feedback for a React Router v7 framework app. license: Apache-2.0 category: sdk-setup parent: sentry-sdk-setup disable-model-invocation: true

All Skills > SDK Setup > React Router Framework SDK

Sentry React Router Framework SDK

Opinionated wizard that scans your React Router Framework project and guides you through complete Sentry setup across client and server entry points.

Invoke This Skill When

  • User asks to "add Sentry to React Router Framework" or "set up Sentry in React Router v7 framework mode"
  • User wants to install or configure @sentry/react-router
  • User uses React Router framework entry files (entry.client.tsx, entry.server.tsx) and wants tracing/error capture
  • User asks about reactRouterTracingIntegration, sentryOnError, createSentryHandleRequest, or React Router wizard setup

Important: This SDK is currently beta. For React Router non-framework/data/declarative mode (v5/v6/v7), use sentry-react-sdk with @sentry/react integrations instead.


Phase 1: Detect

Run these commands to understand the project before making any recommendations:

# Detect React Router Framework indicators and versions
cat package.json | grep -E '"react-router"|"@react-router/"|"react-router-dev"|"react-router-serve"'

# Detect Sentry package choice
cat package.json | grep -E '"@sentry/react-router"|"@sentry/react"|"@sentry/profiling-node"'

# Check entry point visibility and server instrumentation files
ls entry.client.tsx entry.server.tsx instrument.server.mjs react-router.config.ts vite.config.ts 2>/dev/null

# Check if React Router files are still hidden (framework mode helper command available)
cat package.json | grep -E '"reveal"|react-router'

# Detect runtime startup scripts and import strategy
cat package.json | grep -E '"dev"|"start"|NODE_OPTIONS|--import'

# Detect optional logging/profile-related dependencies
cat package.json | grep -E '"pino"|"winston"|"@sentry/profiling-node"'

# Detect companion backend directories
ls ../backend ../server ../api 2>/dev/null
cat ../go.mod ../requirements.txt ../Gemfile ../pom.xml 2>/dev/null | head -3

What to determine:

QuestionImpact
@sentry/react-router already installed?Skip install and move to feature setup
Framework entry files exposed?Need npx react-router reveal before manual config
Using @sentry/react instead?This is likely non-framework routing; redirect to sentry-react-sdk
react-router.config.ts + Vite config present?Source map upload and build-end hook setup path
NODE_OPTIONS --import available?Preferred server instrumentation startup path
@sentry/profiling-node desired/available?Enable server profiling integration
Backend directory found?Trigger Phase 4 cross-link suggestion

Phase 2: Recommend

Present a concrete recommendation based on what you found. Do not ask open-ended questions — lead with a proposal:

Recommended (core coverage):

  • ✅ Error Monitoring — always; captures client and server errors with framework hooks
  • ✅ Tracing — recommended baseline in framework apps with client/server request flow
  • ✅ Session Replay — recommended for user-facing applications

Optional (enhanced observability):

  • ⚡ Profiling — server-side profiling with @sentry/profiling-node
  • ⚡ Logs — structured Sentry.logger.* ingestion and correlation
  • ⚡ User Feedback — in-app feedback widget/reporting flows

Recommendation logic:

FeatureRecommend when...
Error MonitoringAlways — non-negotiable baseline
TracingUsually yes in framework apps; route and request timing is high-value
Session ReplayUser-facing product or difficult UX debugging
ProfilingServer performance investigations needed; Node runtime compatibility verified
LogsTeam wants log-search and trace correlation in Sentry
User FeedbackProduct/support teams need direct in-app issue reports

Propose: "I recommend Error Monitoring + Tracing + Session Replay first. Want me to also enable Profiling, Logs, and User Feedback?"


Phase 3: Guide

Option 1: Wizard (Recommended)

You need to run this yourself — the wizard is interactive and may require browser login:

npx @sentry/wizard@latest -i reactRouter

It installs @sentry/react-router, exposes React Router entry files, creates instrumentation files, updates root error handling, configures source map upload, and adds verification examples.

Once it finishes, continue at Verification.

If the user skips wizard setup, continue with manual setup below.


Option 2: Manual Setup

Install packages

npm install @sentry/react-router --save

If profiling is needed:

npm install @sentry/profiling-node --save

Expose framework entry files

npx react-router reveal

Configure client in entry.client.tsx

import * as Sentry from "@sentry/react-router";
import { startTransition, StrictMode } from "react";
import { hydrateRoot } from "react-dom/client";
import { HydratedRouter } from "react-router/dom";

Sentry.init({
  dsn: "___PUBLIC_DSN___",
  dataCollection: {
    // To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit:
    // https://docs.sentry.io/platforms/javascript/guides/react-router/configuration/options/#dataCollection
    // userInfo: false,
    // httpBodies: [],
  },
  integrations: [
    Sentry.reactRouterTracingIntegration(),
    Sentry.replayIntegration(),
    Sentry.feedbackIntegration({ colorScheme: "system" }),
  ],
  enableLogs: true,
  tracesSampleRate: 1.0,
  tracePropagationTargets: [/^\//, /^https:\/\/yourserver\.io\/api/],
  replaysSessionSampleRate: 0.1,
  replaysOnErrorSampleRate: 1.0,
});

startTransition(() => {
  hydrateRoot(
    document,
    <StrictMode>
      <HydratedRouter onError={Sentry.sentryOnError} />
    </StrictMode>,
  );
});

Configure server in instrument.server.mjs

import * as Sentry from "@sentry/react-router";
import { nodeProfilingIntegration } from "@sentry/profiling-node";

Sentry.init({
  dsn: "___PUBLIC_DSN___",
  dataCollection: {
    // To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit:
    // https://docs.sentry.io/platforms/javascript/guides/react-router/configuration/options/#dataCollection
    // userInfo: false,
    // httpBodies: [],
  },
  enableLogs: true,
  integrations: [nodeProfilingIntegration()],
  tracesSampleRate: 1.0,
  profileSessionSampleRate: 1.0,
});

Wrap server handlers in entry.server.tsx

import * as Sentry from "@sentry/react-router";
import { createReadableStreamFromReadable } from "@react-router/node";
import { renderToPipeableStream } from "react-dom/server";
import { ServerRouter } from "react-router";

const handleRequest = Sentry.createSentryHandleRequest({
  ServerRouter,
  renderToPipeableStream,
  createReadableStreamFromReadable,
});

export default handleRequest;

export const handleError = Sentry.createSentryHandleError({
  logErrors: false,
});

For custom server logic, use wrapSentryHandleRequest, getMetaTagTransformer, and manual Sentry.captureException in your custom handleError.

Load server instrumentation on startup

Prefer NODE_OPTIONS --import:

{
  "scripts": {
    "dev": "NODE_OPTIONS='--import ./instrument.server.mjs' react-router dev",
    "start": "NODE_OPTIONS='--import ./instrument.server.mjs' react-router-serve ./build/server/index.js"
  }
}

Fallback for platforms where runtime flags are restricted:

import "./instrument.server.mjs";

This direct-import method can result in incomplete auto-instrumentation compared to --import.

Configure source maps

vite.config.ts:

import { reactRouter } from "@react-router/dev/vite";
import {
  sentryReactRouter,
  type SentryReactRouterBuildOptions,
} from "@sentry/react-router";
import { defineConfig } from "vite";

const sentryConfig: SentryReactRouterBuildOptions = {
  org: "___ORG_SLUG___",
  project: "___PROJECT_SLUG___",
  authToken: process.env.SENTRY_AUTH_TOKEN,
};

export default defineConfig((config) => {
  return {
    plugins: [reactRouter(), sentryReactRouter(sentryConfig, config)],
  };
});

react-router.config.ts:

import type { Config } from "@react-router/dev/config";
import { sentryOnBuildEnd } from "@sentry/react-router";

export default {
  ssr: true,
  buildEnd: async ({ viteConfig, reactRouterConfig, buildManifest }) => {
    await sentryOnBuildEnd({ viteConfig, reactRouterConfig, buildManifest });
  },
} satisfies Config;

For Each Agreed Feature

Walk through features one at a time. Load the reference file, follow steps exactly, and verify before moving on:

FeatureReferenceLoad when...
Error Monitoring${SKILL_ROOT}/references/error-monitoring.mdAlways
Tracing${SKILL_ROOT}/references/tracing.mdRoute/request performance visibility needed
Profiling${SKILL_ROOT}/references/profiling.mdServer performance analysis needed
Session Replay${SKILL_ROOT}/references/session-replay.mdUser-facing app
Logs${SKILL_ROOT}/references/logging.mdStructured logs/correlation needed
User Feedback${SKILL_ROOT}/references/user-feedback.mdIn-app feedback flows needed
Framework Features${SKILL_ROOT}/references/react-router-framework-features.mdEntry files, wrappers, source maps, startup import strategy

For each feature: Read ${SKILL_ROOT}/references/<feature>.md, follow steps exactly, verify it works.


Configuration Reference

Key Sentry.init() options

OptionTypeDefaultNotes
dsnstring—Required; SDK disabled when empty
dataCollectionobject—Controls what data is collected (userInfo, cookies, httpHeaders, etc.)
dataCollection.userInfobooleantrueIncludes IP-derived user context
dataCollection.cookiesCollectBehaviortrueControls cookie collection and filtering
dataCollection.httpHeadersobject{ request: true, response: true }Controls HTTP header collection
sendDefaultPiibooleanfalseDeprecated: Use dataCollection instead; removed in v11
integrationsIntegration[]SDK defaultsAdd tracing/replay/feedback/profiling integrations
enableLogsbooleanfalseEnables Sentry.logger.* ingestion
tracesSampleRatenumber—Usually 1.0 in testing, lower in production
tracePropagationTargets`(stringRegExp)[]`SDK defaults
replaysSessionSampleRatenumber—Fraction of all sessions recorded
replaysOnErrorSampleRatenumber—Fraction of error sessions recorded
profileSessionSampleRatenumber—Fraction of transactions profiled (server profiling)
tunnelstring—Optional ad-blocker bypass endpoint
debugbooleanfalseVerbose SDK diagnostics

Framework-specific APIs

APIPurpose
reactRouterTracingIntegration()Client-side tracing integration for framework mode
sentryOnErrorHooks into React Router HydratedRouter error reporting
createSentryHandleRequest(...)Server request wrapper for framework entry server
createSentryHandleError(...)Server error handler wrapper
wrapServerLoader(...) / wrapServerAction(...)Manual wrapping for server loaders/actions
sentryReactRouter(...)Vite plugin for source maps/build integration
sentryOnBuildEnd(...)React Router build-end hook for source map processing

Verification

Wizard-generated path

If wizard examples were generated, open /sentry-example-page and trigger test actions.

Manual error test

export async function loader() {
  throw new Error("My first Sentry error!");
}

Manual tracing test

import * as Sentry from "@sentry/react-router";

export async function loader() {
  return Sentry.startSpan(
    { op: "test", name: "My First Test Transaction" },
    () => {
      throw new Error("My first Sentry error!");
    },
  );
}

Logs test

Sentry.logger.info("User example action completed");
Sentry.logger.warn("Slow operation detected", { operation: "data_fetch", duration: 3500 });
Sentry.logger.error("Validation failed", { field: "email", reason: "Invalid email" });

Confirm in Sentry:

  • Issues: errors appear
  • Traces: transaction/span data appears
  • Profiles: profiles appear when profiling enabled
  • Replays: replay entries appear when enabled
  • Logs: log events appear when enableLogs: true
  • User Feedback: submissions appear when feedback enabled

Phase 4: Cross-Link

After completing React Router Framework setup:

  1. Check whether the app is actually non-framework routing (v5/v6/v7 data/declarative with @sentry/react).
  2. If yes, redirect to sentry-react-sdk for non-framework routing integrations.

Then check companion backend coverage:

ls ../backend ../server ../api ../go ../python 2>/dev/null
cat ../go.mod ../requirements.txt ../pyproject.toml ../Gemfile ../pom.xml 2>/dev/null | head -5
Backend detectedSuggest skill
Gosentry-go-sdk
Pythonsentry-python-sdk
Rubysentry-ruby-sdk
Node backend servicessentry-node-sdk
Java servicesUse @sentry/java docs

Troubleshooting

IssueSolution
entry.client.tsx / entry.server.tsx missingRun npx react-router reveal first
Client errors missingEnsure HydratedRouter includes onError={Sentry.sentryOnError}
Server errors missingUse createSentryHandleRequest and createSentryHandleError wrappers
Custom server handlers bypass SentryUse wrapSentryHandleRequest and manual captureException in custom handleError
Source maps not uploadedVerify sentryReactRouter plugin config and sentryOnBuildEnd hook
SENTRY_AUTH_TOKEN undefined in Vite configLoad env vars in config or use .env.sentry-build-plugin
Incomplete server auto-instrumentationPrefer NODE_OPTIONS='--import ./instrument.server.mjs' startup
Profiling data missingConfirm @sentry/profiling-node installed and nodeProfilingIntegration enabled
Running unsupported Node auto-instrumentation versionUse instrumentation API/manual wrappers as documented
Non-framework app configured with @sentry/react-routerSwitch to sentry-react-sdk + @sentry/react for v5/v6/v7 non-framework routes