sentry-react-sdk▌
getsentry/sentry-agent-skills · updated Apr 8, 2026
MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.
Opinionated wizard that scans your React project and guides you through complete Sentry setup.
Sentry React SDK
Opinionated wizard that scans your React project and guides you through complete Sentry setup.
Invoke This Skill When
- User asks to "add Sentry to React" or "set up Sentry" in a React app
- User wants error monitoring, tracing, session replay, profiling, or logging in React
- User mentions
@sentry/react, React Sentry SDK, or Sentry error boundaries - User wants to monitor React Router navigation, Redux state, or component performance
Note: SDK versions and APIs below reflect current Sentry docs at time of writing (
@sentry/react≥8.0.0). Always verify against docs.sentry.io/platforms/javascript/guides/react/ before implementing.
Phase 1: Detect
Run these commands to understand the project before making any recommendations:
# Detect React version
cat package.json | grep -E '"react"|"react-dom"'
# Check for existing Sentry
cat package.json | grep '"@sentry/'
# Detect router
cat package.json | grep -E '"react-router-dom"|"@tanstack/react-router"'
# Detect state management
cat package.json | grep -E '"redux"|"@reduxjs/toolkit"'
# Detect build tool
ls vite.config.ts vite.config.js webpack.config.js craco.config.js 2>/dev/null
cat package.json | grep -E '"vite"|"react-scripts"|"webpack"'
# Detect logging libraries
cat package.json | grep -E '"pino"|"winston"|"loglevel"'
# Check for companion backend in adjacent directories
ls ../backend ../server ../api 2>/dev/null
cat ../go.mod ../requirements.txt ../Gemfile ../pom.xml 2>/dev/null | head -3
What to determine:
| Question | Impact |
|---|---|
| React 19+? | Use reactErrorHandler() hook pattern |
| React <19? | Use Sentry.ErrorBoundary |
@sentry/react already present? |
Skip install, go straight to feature config |
react-router-dom v5 / v6 / v7? |
Determines which router integration to use |
@tanstack/react-router? |
Use tanstackRouterBrowserTracingIntegration() |
| Redux in use? | Recommend createReduxEnhancer() |
| Vite detected? | Source maps via sentryVitePlugin |
CRA (react-scripts)? |
Source maps via @sentry/webpack-plugin in CRACO |
| Backend directory found? | Trigger Phase 4 cross-link suggestion |
Phase 2: Recommend
Present a concrete recommendation based on what you found. Don't ask open-ended questions — lead with a proposal:
Recommended (core coverage):
- ✅ Error Monitoring — always; captures unhandled errors, React error boundaries, React 19 hooks
- ✅ Tracing — React SPAs benefit from page load, navigation, and API call tracing
- ✅ Session Replay — recommended for user-facing apps; records sessions around errors
Optional (enhanced observability):
- ⚡ Logging — structured logs via
Sentry.logger.*; recommend when structured log search is needed - ⚡ Profiling — JS Self-Profiling API (⚠️ experimental; requires cross-origin isolation headers)
Recommendation logic:
| Feature | Recommend when... |
|---|---|
| Error Monitoring | Always — non-negotiable baseline |
| Tracing | Always for React SPAs — page load + navigation spans are high-value |
| Session Replay | User-facing app, login flows, or checkout pages |
| Logging | App needs structured log search or log-to-trace correlation |
| Profiling | Performance-critical app; server sends Document-Policy: js-profiling header |
React-specific extras:
- React 19 detected → set up
reactErrorHandler()oncreateRoot - React Router detected → configure matching router integration (see Phase 3)
- Redux detected → add
createReduxEnhancer()to Redux store - Vite detected → configure
sentryVitePluginfor source maps (essential for readable stack traces)
Propose: "I recommend setting up Error Monitoring + Tracing + Session Replay. Want me to also add Logging or Profiling?"
Phase 3: Guide
Install
npm install @sentry/react --save
Create src/instrument.ts
Sentry must initialize before any other code runs. Put Sentry.init() in a dedicated sidecar file:
import * as Sentry from "@sentry/react";
Sentry.init({
dsn: import.meta.env.VITE_SENTRY_DSN, // Adjust per build tool (see table below)
environment: import.meta.env.MODE,
release: import.meta.env.VITE_APP_VERSION, // inject at build time
sendDefaultPii: true,
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration({
maskAllText: true,
blockAllMedia: true,
}),
],
// Tracing
tracesSampleRate: 1.0, // lower to 0.1–0.2 in production
tracePropagationTargets: ["localhost", /^https:\/\/yourapi\.io/],
// Session Replay
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
enableLogs: true,
});
DSN environment variable by build tool:
| Build Tool | Variable Name | Access in code |
|---|---|---|
| Vite | VITE_SENTRY_DSN |
import.meta.env.VITE_SENTRY_DSN |
| Create React App | REACT_APP_SENTRY_DSN |
process.env.REACT_APP_SENTRY_DSN |
| Custom webpack | SENTRY_DSN |
process.env.SENTRY_DSN |
Entry Point Setup
Import instrument.ts as the very first import in your entry file:
// src/main.tsx (Vite) or src/index.tsx (CRA/webpack)
import "./instrument"; // ← MUST be first
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App";
createRoot(document.getElementById("root")!).render(
<StrictMode>
<App />
</StrictMode>
);
React Version-Specific Error Handling
React 19+ — use reactErrorHandler() on createRoot:
import { reactErrorHandler } from "@sentry/react";
createRoot(document.getElementById("root")!, {
onUncaughtError: reactErrorHandler(),
onCaughtError: reactErrorHandler(),
onRecoverableError: reactErrorHandler(),
}).render(<App />);
React <19 — wrap your app in Sentry.ErrorBoundary:
import * as Sentry from "@sentry/react";
createRoot(document.getElementById("root")!).render(
<Sentry.ErrorBoundary fallback={<p>Something went wrong</p>} showDialog>
<App />
</Sentry.ErrorBoundary>
);
Use <Sentry.ErrorBoundary> for any sub-tree that should catch errors independently (route sections, widgets, etc.).
Router Integration
Configure the matching integration for your router:
| Router | Integration | Notes |
|---|---|---|
| React Router v7 | reactRouterV7BrowserTracingIntegration |
useEffect, useLocation, useNavigationType, createRoutesFromChildren, matchRoutes from react-router |
| React Router v6 | reactRouterV6BrowserTracingIntegration |
useEffect, useLocation, useNavigationType, createRoutesFromChildren, matchRoutes from react-router-dom |
| React Router v5 | reactRouterV5BrowserTracingIntegration |
Wrap routes in withSentryRouting(Route) |
| TanStack Router | tanstackRouterBrowserTracingIntegration(router) |
Pass router instance — no hooks required |
| No router / custom | browserTracingIntegration() |
Names transactions by URL path |
React Router v6/v7 setup:
// in instrument.ts integrations array:
import React from How to use sentry-react-sdk on Cursor
AI-first code editor with Composer
Prerequisites
Before installing skills in Cursor, ensure your development environment meets these requirements:
- ›Cursor installed and configured on your development machine
- ›Node.js version 16.0+ with npm package manager (verify with
node --version) - ›Active project directory or workspace where you want to add sentry-react-sdk
Execute installation command
Execute the skills CLI command in your project's root directory to begin installation:
The skills CLI fetches sentry-react-sdk from GitHub repository getsentry/sentry-agent-skills and configures it for Cursor.
Select Cursor when prompted
The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:
Verify installation
Confirm successful installation by checking the skill directory location:
Reload or restart Cursor to activate sentry-react-sdk. Access the skill through slash commands (e.g., /sentry-react-sdk) or your agent's skill management interface.
Security & Verification Notice
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.
List & Monetize Your Skill
Submit your Claude Code skill and start earning
Use Cases▌
Task Automation & Efficiency
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Knowledge Enhancement
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Quality Improvement
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
Implementation Guide▌
Prerequisites
- ›Claude Desktop or compatible AI client with skill support
- ›Clear understanding of task or problem to solve
- ›Willingness to iterate and refine outputs
Time Estimate
15-45 minutes depending on use case complexity
Installation Steps
- 1.Install skill using provided installation command
- 2.Test with simple use case relevant to your work
- 3.Evaluate output quality and relevance
- 4.Iterate on prompts to improve results
- 5.Integrate into regular workflow if valuable
Common Pitfalls
- ⚠Expecting perfect results without iteration
- ⚠Not providing enough context in prompts
- ⚠Using skill for tasks outside its intended scope
- ⚠Accepting outputs without review and validation
Best Practices▌
✓ Do
- +Start with clear, specific prompts
- +Provide relevant context and constraints
- +Review and refine all outputs before using
- +Iterate to improve output quality
- +Document successful prompt patterns
✗ Don't
- −Don't use without understanding skill limitations
- −Don't skip validation of outputs
- −Don't share sensitive information in prompts
- −Don't expect skill to replace human judgment
💡 Pro Tips
- ★Be specific about desired format and style
- ★Ask for multiple options to choose from
- ★Request explanations to understand reasoning
- ★Combine AI efficiency with human expertise
When to Use This▌
✓ Use When
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid When
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
Learning Path▌
- 1Familiarize yourself with skill capabilities and limitations
- 2Start with low-risk, non-critical tasks
- 3Progress to more complex and valuable use cases
- 4Build expertise through regular use and experimentation
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
Ratings
4.4★★★★★25 reviews- ★★★★★Fatima Reddy· Dec 8, 2024
sentry-react-sdk has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Arya Singh· Nov 27, 2024
sentry-react-sdk fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- ★★★★★Neel Torres· Oct 18, 2024
We added sentry-react-sdk from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- ★★★★★Tariq Flores· Sep 13, 2024
sentry-react-sdk has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Piyush G· Sep 5, 2024
sentry-react-sdk has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Shikha Mishra· Aug 24, 2024
Solid pick for teams standardizing on skills: sentry-react-sdk is focused, and the summary matches what you get after install.
- ★★★★★Amina Li· Aug 4, 2024
Solid pick for teams standardizing on skills: sentry-react-sdk is focused, and the summary matches what you get after install.
- ★★★★★Evelyn Perez· Jul 23, 2024
We added sentry-react-sdk from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- ★★★★★Rahul Santra· Jul 15, 2024
We added sentry-react-sdk from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- ★★★★★Anaya Mehta· Jul 15, 2024
sentry-react-sdk reduced setup friction for our internal harness; good balance of opinion and flexibility.
showing 1-10 of 25