Introduction
Monitoring a React application in production is about continuously tracking the application’s health, performance, and user experience to identify issues before they significantly impact users. Unlike development, where errors can be reproduced locally, production applications are used by thousands of users across different browsers, devices, and network conditions. Therefore, it’s important to collect real-time telemetry, analyze it, and configure alerts so the development team can respond quickly.
To effectively monitor a React application, we focus on four key areas:
- Errors – Monitor JavaScript exceptions, React Error Boundary errors, unhandled promise rejections, and API failures to detect application crashes and bugs.
- Performance – Track page load time, Core Web Vitals (LCP, INP, CLS), component render time, bundle size, and memory usage to ensure the application remains fast and responsive.
- Network Activity – Monitor API response times, failed requests, HTTP status codes, and timeout rates to identify backend or connectivity issues affecting the frontend.
- User Experience (UX) – Analyze user interactions, navigation flow, session duration, and real user performance metrics to understand how users experience the application.
Based on these metrics, we can configure dashboards and alerting using tools such as Splunk, Grafana, Sentry, or Datadog, so that when predefined thresholds are exceeded (for example, a spike in JavaScript errors, high API latency, or degraded Core Web Vitals), notifications are automatically sent through slack , email or any other communication tool enabling the team to investigate and resolve issues quickly.
Monitoring Architecture
Users
│
▼
React Application
│
┌───────────────┬───────────────┬────────────────┐
│ │ │ │
▼ ▼ ▼ ▼
Errors Performance Network User Experience
(JS Errors) (LCP, INP, CLS) (API Calls) (Navigation, Clicks)
│ │ │ │
└───────────────┴───────────────┴────────────────┘
│
▼
Telemetry Collection
(OpenTelemetry / Browser SDK / Custom Logs)
│
▼
Monitoring & Analytics Platform
(Splunk / Grafana / Datadog / New Relic / Sentry)
│
┌──────────────────┼──────────────────┐
│ │ │
▼ ▼ ▼
Dashboards Log Analysis Performance Reports
│
▼
Alert Engine
│
┌───────────────────┼───────────────────┐
▼ ▼ ▼
Slack Email PagerDuty
What should be monitored?
| S.No | Monitoring Area | What to Monitor | Why It Matters |
|---|---|---|---|
| 1 | Error Monitoring | JavaScript exceptions, React Error Boundary errors, unhandled promise rejections, API failures | Detect application crashes and bugs quickly. |
| 2 | Performance Monitoring | Page load time, Core Web Vitals (LCP, INP, CLS), component render time | Ensure the application remains fast and responsive. |
| 3 | API & Network Monitoring | API latency, failed requests, HTTP status codes, timeout rate | Identify backend or network-related issues. |
| 4 | React Rendering Monitoring | Slow renders, frequent re-renders, component mount time | Detect unnecessary re-renders and improve UI performance. |
| 5 | Memory Monitoring | JavaScript heap size, detached DOM nodes, event listener leaks | Prevent memory leaks and browser slowdowns. |
| 6 | Session Replay Monitoring | User clicks, scrolls, navigation flow, console errors | Reproduce and debug real user issues. |
| 7 | Bundle Monitoring | JavaScript bundle size, lazy-loaded chunks, download time | Reduce application load time and improve performance. |
| 8 | Real User Monitoring (RUM) | Browser, device, network speed, page load time, user interactions | Measure the actual experience of real users. |
| 9 | Alerting Strategy | Error rate, API latency, Core Web Vitals, memory usage, crash rate | Notify the team when application health degrades. |
1. Error Monitoring
Capture:
- Runtime errors
- React Error Boundaries
- Promise rejections
- API failures
Example –
try {
await api.getUsers();
}
catch(error){
Sentry.captureException(error);
}
2. Measure Web Vitals
What are Web Vitals?
Web Vitals are a set of user-centric performance metrics that measure how fast, responsive, and visually stable a web application is. They help evaluate the real user experience and identify performance issues that can impact usability.
The three Core Web Vitals are:
| S.No | Metric | Full Form | Measures | Good Value | Common Issues | Optimization Techniques |
|---|---|---|---|---|---|---|
| 1 | LCP | Largest Contentful Paint | Time taken to render the largest visible element (image, heading, video, etc.) in the viewport. Measures loading performance. | ≤ 2.5 s | Large images, slow server response, render-blocking CSS/JS | Optimize images, lazy load assets, enable caching/CDN, minimize render-blocking resources |
| 2 | INP | Interaction to Next Paint | Measures the delay between a user interaction (click, tap, keyboard input) and the next visual update. Measures responsiveness. | ≤ 200 ms | Long JavaScript tasks, expensive React re-renders, synchronous processing | Code splitting, memoization (React.memo, useMemo, useCallback), defer non-critical work |
| 3 | CLS | Cumulative Layout Shift | Measures unexpected movement of page elements while loading. Measures visual stability. | ≤ 0.1 | Images without dimensions, dynamic content insertion, late-loading fonts | Reserve space for media, preload fonts, avoid inserting content above existing elements |
Why are Core Web Vitals important?
| Benefit | Description |
|---|---|
| Improved User Experience | Faster loading, smoother interactions, and stable layouts increase user satisfaction. |
| Better Performance Monitoring | Provides measurable KPIs to evaluate frontend performance over time. |
| SEO Benefits | Core Web Vitals are part of Google’s Page Experience signals and can influence search rankings. |
| Higher User Engagement | Faster websites typically have lower bounce rates and better conversion rates. |
| Early Performance Detection | Helps identify performance regressions before they affect a large number of users. |
React App:
import { onLCP, onCLS, onINP } from 'web-vitals';
onLCP(console.log);
onCLS(console.log);
onINP(console.log);
These metrics are sent to:
- Google Analytics
- Datadog
- New Relic
3. API Monitoring
Track:
- API latency
- HTTP errors
- Timeout
- Retry count
Example Axios Interceptor:
axios.interceptors.response.use(
response => response,
error => {
Sentry.captureException(error);
return Promise.reject(error);
}
);
Dashboard
Average API latency
95th percentile latency
500 errors
404 errors
Timeout rate
4. React Rendering Performance
React DevTools Profiler helps during development.
In production monitor:
- Slow renders
- Frequent re-renders
- Component mount time
Example:
ProductList rendered 120 times
Should only render 10 times
Performance issue detected
5. Memory Monitoring
Monitor:
- JS Heap Size
- Detached DOM nodes
- Event listener leaks
Symptoms:
Memory 100 MB -> 250 MB -> 500 MB -> Browser crash
Possible causes:
- Missing cleanup in
useEffect - Timers not cleared
- WebSocket not disconnected
6. Network Monitoring
Track:
- Failed requests
- Slow requests
- Offline users
- Retry attempts
Useful metrics:
Average latency
P95 latency
P99 latency
Failure %
Bandwidth
7. Session Replay
Sometimes logs aren’t enough.
Use:
- LogRocket
- FullStory
- Microsoft Clarity
They record:
- Clicks
- Scrolls
- Mouse movement
- Console errors
- Network requests
You can replay exactly what the user experienced.
8. Bundle Monitoring
Monitor:
- Bundle size
- Lazy loaded chunks
- Download time
Example:
Previous Bundle420 KB -> Current Bundle900 KB -> Alert!
Tools:
- Webpack Bundle Analyzer
- Source Map Explorer
9. Real User Monitoring (RUM)
Instead of lab testing, monitor actual users.
Popular tools:
- Datadog RUM
- New Relic Browser
- Dynatrace
- Elastic APM
Metrics collected:
- Device
- Browser
- Country
- Network speed
- Load time
- API latency
- Errors
10. Alerting Strategy
Alerts should be actionable.
| Condition | Alert |
|---|---|
| JS Errors > 100/min | Slack |
| API Failure Rate > 5% | PagerDuty |
| LCP > 4 sec | Slack |
| INP > 300 ms | |
| CLS > 0.25 | Slack |
| Memory > 400 MB | |
| Crash Rate > 2% | PagerDuty |
Best Practices
| Practice | Benefit |
|---|---|
| Implement React Error Boundaries | Prevent the entire app from crashing due to a component error. |
| Capture unhandled exceptions and promise rejections | Detect unexpected failures in production. |
| Monitor Core Web Vitals (LCP, INP, CLS) | Measure real user performance and UX quality. |
| Use Real User Monitoring (RUM) | Collect performance data from actual users across devices and networks. |
| Track API latency and failure rates | Identify backend or network bottlenecks affecting the UI. |
| Monitor memory usage and clean up resources | Prevent memory leaks caused by timers, subscriptions, or event listeners. |
| Record user sessions for critical errors | Reproduce issues faster with session replay tools. |
| Track JavaScript bundle size in CI/CD | Prevent performance regressions due to oversized bundles. |
| Define meaningful alert thresholds | Reduce alert fatigue by notifying only on significant issues. |
| Correlate frontend telemetry with backend logs using trace IDs | Speed up root-cause analysis across distributed systems. |
