Set Up Bugsly for React
Catch and debug errors in your React components with automatic component tree tracking, error boundaries, and real-time AI analysis.
1. Install the SDK
npm install @bugsly/react2. Configure Bugsly
Add the following to your application entry point. Replace the DSN with your project DSN from the Bugsly dashboard.
import * as Bugsly from "@bugsly/react";
Bugsly.init({
dsn: "https://your-dsn@bugsly.dev/1",
environment: "production",
tracesSampleRate: 1.0,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
integrations: [Bugsly.browserTracingIntegration(), Bugsly.replayIntegration()],
});
function App() {
return (
<Bugsly.ErrorBoundary fallback={<p>Something went wrong</p>}>
<YourApp />
</Bugsly.ErrorBoundary>
);
}3. Verify It Works
Trigger a test error in your application and check your Bugsly dashboard. The error should show up as an issue within a few seconds.
Want to check your DSN before touching any code? From a macOS, Linux or WSL terminal, this sends one real error without any SDK (replace your-dsn with the key from your DSN):
curl -sS -X POST "https://bugsly.dev/api/1/envelope/" \
-H "X-Sentry-Auth: Sentry sentry_version=7, sentry_key=your-dsn" \
--data-binary $'{}\n{"type":"event"}\n{"level":"error","platform":"other","exception":{"values":[{"type":"CurlTestError","value":"Hello from my terminal"}]}}'Choosing between tools? Our React error tracking comparison covers error boundaries, source maps and session replay.
What You Get with React
- Automatic React component tree in error reports
- Error Boundaries integration with fallback UI
- Hook-aware stack traces
- Session replay to see exactly what users did
- AI-powered analysis explains errors in plain English
- Source map support for readable stack traces
Frequently Asked Questions
Does Bugsly work with React Server Components?
For React Server Components, use @bugsly/nextjs which wraps the Sentry Next.js SDK and covers both server and client error tracking. For client-side React apps (Vite, CRA), use @bugsly/react.
How do I set up error boundaries with Bugsly?
Wrap your component tree in the ErrorBoundary exported by @bugsly/react (Bugsly.ErrorBoundary in the snippet above). Errors caught by the boundary are reported to Bugsly and your fallback UI is rendered.
Does Bugsly increase my React bundle size?
@bugsly/react is a thin wrapper over @sentry/react, so the size you ship is that of the Sentry browser SDK and whichever integrations you enable. Tracing and session replay are optional integrations; leave them out of the init call if you want a smaller bundle, and measure with your own bundler.
Start tracking errors in React for free
The free plan includes 100 issues per month, 7-day retention and 10 AI requests per month. Paid plans start at $19/mo.
Start Free