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/react @bugsly/browser2. 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/browser";
import { BugslyErrorBoundary } from "@bugsly/react";
Bugsly.init({
dsn: "https://your-dsn@bugsly.dev/1",
environment: "production",
tracesSampleRate: 1.0,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});
function App() {
return (
<BugslyErrorBoundary fallback={<p>Something went wrong</p>}>
<YourApp />
</BugslyErrorBoundary>
);
}3. Verify It Works
Trigger a test error in your application and check your Bugsly dashboard. You should see the error appear within seconds, complete with stack trace, breadcrumbs, and AI-powered analysis.
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?
Yes. For React Server Components, use @bugsly/nextjs which handles 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?
Import BugslyErrorBoundary from @bugsly/react and wrap your component tree. Any errors caught by the boundary are automatically reported to Bugsly with component context.
Does Bugsly increase my React bundle size?
The @bugsly/react package adds approximately 15KB gzipped to your bundle. Session replay adds another 30KB but is loaded asynchronously and only when needed.
Start tracking errors in React for free
Get AI-powered error analysis, session replay, and performance monitoring — included free on every plan.
Start Free