How to Track Errors in My App
Use Sentry (free for up to 5,000 errors/month) to automatically capture and report errors in your app. Install the SDK, initialize it with your project DSN, and Sentry will alert you when errors occur — with full stack traces, browser details, and the exact line of code that failed.
Why this matters
Your users are hitting errors you do not know about. Browser console errors are invisible to you once your app is deployed. Without error tracking, you rely on users reporting problems — and most users do not report bugs, they just leave.
What's at stake
Silent errors erode trust. A user who encounters an error and sees no fix assumes the app is abandoned. Error tracking turns invisible problems into actionable notifications, letting you fix issues before they drive users away.
Step by step.
Create a Sentry account
Sign up at sentry.io and create a new project for your framework (React, Next.js, Node.js, etc.). The free tier includes 5,000 errors/month, which is more than enough for an early-stage app.
Install the Sentry SDK
Install the appropriate Sentry package for your framework. For React apps, install @sentry/react. For Next.js, use @sentry/nextjs which includes both client and server error tracking.
npm install @sentry/react
# or for Next.js
npm install @sentry/nextjsInitialize Sentry in your app
Add the Sentry initialization code to your app entry point. Replace YOUR_SENTRY_DSN with the DSN from your Sentry project settings. This captures all unhandled errors automatically.
import * as Sentry from "@sentry/react";
Sentry.init({
dsn: "YOUR_SENTRY_DSN",
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration(),
],
tracesSampleRate: 1.0,
replaysOnErrorSampleRate: 1.0,
});Configure alert rules
In your Sentry dashboard, go to Alerts and create a rule that emails you when a new error occurs. Set it to notify on first occurrence of a new issue, not on every error — this prevents alert fatigue while ensuring you know about new problems.
Test with a deliberate error
Add a temporary button that throws an error to verify Sentry is working. Click it, then check your Sentry dashboard. You should see the error with a full stack trace. Remove the test button after confirming.
<button onClick={() => { throw new Error("Sentry test error"); }}>
Test Error Tracking
</button>Catch errors before your users notice them
- Automated error detection across your entire app
- Real-time alerts when something breaks
- Error history showing patterns and trends over time
Frequently asked questions.
Sentry is the most popular and has the best free tier (5,000 errors/month). Bugsnag offers 7,500 free errors/month with similar features. LogRocket combines error tracking with session replay (1,000 sessions/month free) so you can see exactly what users did before an error occurred. For most builders, Sentry is the best starting point.
No. Modern error tracking SDKs are designed to be lightweight. Sentry adds approximately 30-50KB to your bundle and captures errors asynchronously, so it does not block your UI. The performance impact is negligible compared to the value of knowing about errors.
Read the error message and stack trace to understand what failed. Check if the error is happening for many users or just one. Prioritize errors that affect core functionality (login, payments, data saving) over cosmetic issues. Fix, deploy, and verify the error stops recurring.
Yes. Sentry has SDKs for frontend frameworks (React, Vue, Angular) and backend runtimes (Node.js, Python, Go). For a full-stack app, install both and link them using trace IDs so you can follow errors across your entire stack.