Crux vs RUM for SPA Route Performance
In this article
- Background: What CrUX and RUM Actually Measure
- How CrUX Works for SPAs
- How RUM Works for SPA Routes
- Key Differences and Why They Matter for SPAs
- How to Choose: When to Use Which
- Common Problems and Misconceptions
- Costs and Safety Considerations
- Alternatives and Complementary Tools
- Frequently Asked Questions
For measuring single page app (SPA) route performance, real user monitoring (RUM) is the more accurate and actionable choice, while Google's Core Web Vitals (CrUX) data is best used as a supplementary, aggregate benchmark. RUM captures every route change in your actual app with full context, whereas CrUX is a public dataset of aggregated field data that often lacks SPA route-level granularity.
Background: What CrUX and RUM Actually Measure
CrUX (Chrome User Experience Report) is a public dataset maintained by Google that collects real-world performance metrics from opted-in Chrome users. It aggregates data at the page origin or URL level, reporting metrics like Largest Contentful Paint (LCP), First Input Delay (FID), and Cumulative Layout Shift (CLS) for the initial page load. It does not track client-side route changes within a SPA because those do not trigger a full page load.
RUM (Real User Monitoring) is a broad category of tools (e.g., Datadog, New Relic, Sentry, or custom implementations) that instrument your application to capture performance data from every user session. RUM can be configured to measure route transitions, API calls, component render times, and custom user interactions. Unlike CrUX, RUM gives you full control over what you measure and how you segment the data.
How CrUX Works for SPAs
CrUX collects data from Chrome browsers that have opted into syncing their browsing history. It processes this data to produce monthly aggregates for URLs that meet a minimum traffic threshold (roughly 1,000 page loads per month). For SPAs, CrUX typically reports on the initial HTML document load, not on subsequent route changes. This means if your SPA loads a shell and then renders content via JavaScript, CrUX's LCP may reflect the time to render the initial view, but it will not capture the performance of navigating from /dashboard to /settings.
One nuance: if your SPA uses the History API to change the URL, CrUX may treat each route as a separate page, but only if the URL change triggers a full page load (which it usually does not). In practice, CrUX data for SPA routes is sparse and often not available for deep links.
How RUM Works for SPA Routes
RUM tools work by injecting a JavaScript snippet into your app. This snippet listens to navigation events, including History API changes and hash changes, and can be configured to start a performance timer on each route transition. You can then collect metrics like:
- Time to first paint after route change
- Time to first meaningful content (e.g., when the route's main component mounts)
- Time to interactive (TTI) for that route
- JavaScript errors and network failures during the transition
RUM also gives you the ability to filter by device type, browser, geographic region, and user attributes. For example, you can compare route performance for users on 4G vs. Wi-Fi, or for a specific A/B test cohort.
Key Differences and Why They Matter for SPAs
The most significant difference is granularity. CrUX gives you a single score per URL, typically for the initial load. RUM gives you per-route, per-user, and per-session data. For a SPA, where the majority of user interactions happen after the initial load, CrUX is essentially blind to the experience that matters most.
Another difference is timeliness. CrUX is updated on a rolling 28-day basis, so it reflects last month's data. RUM can give you real-time or near-real-time data, allowing you to detect regressions immediately after a deployment.
There is also a difference in control. With CrUX, you cannot add custom metrics or alter the sampling. With RUM, you can define exactly what a “route change” means, add custom marks (e.g., “data loaded”, “image carousel ready”), and correlate performance with business outcomes like conversion rate.
How to Choose: When to Use Which
Use CrUX as a high-level health check for your SPA's initial load. It is free, requires no instrumentation, and can alert you to major issues that affect a broad audience. For example, if your initial LCP drops from 2.0s to 4.0s, CrUX will show that, and you can investigate.
Use RUM for everything else. Specifically, you should use RUM when:
- You need to measure route transitions within your SPA.
- You need to segment performance by user demographics or behavior.
- You want to set custom performance budgets for specific routes.
- You need to debug a performance issue in real time (e.g., a spike in slow routes after a release).
- You want to track the performance of third-party scripts or API calls that happen during a route change.
In practice, most teams use both: CrUX for external benchmarking and RUM for internal optimization.
Common Problems and Misconceptions
A common misconception is that CrUX measures SPA route performance. It does not, unless you implement a workaround like forcing a full page reload on each route (which defeats the purpose of a SPA). Another misconception is that RUM is too heavy and slows down your app. While there is a small overhead, modern RUM tools use efficient sampling and can be configured to collect only essential data.
Another problem is that CrUX data can be misleading for SPAs because it may only include users who land on the page via a direct URL (e.g., from a link) and not those who navigate internally. This can skew your LCP numbers, as direct landings often involve a full page load, while internal navigations are faster.
Also, be aware that CrUX only includes Chrome users. If your audience is predominantly Safari or Firefox, CrUX data will not represent them. RUM can capture all browsers.
Costs and Safety Considerations
CrUX is completely free. RUM tools range from free tiers (e.g., Sentry's free tier, or open-source options like Grafana with Prometheus) to enterprise pricing based on the volume of data collected. For a small SPA, you can even build a lightweight RUM solution using the Performance API and send data to your own analytics endpoint.
When implementing RUM, be mindful of user privacy. Avoid collecting personally identifiable information (PII) in performance data. Anonymize user IDs and consider using sampling to reduce data volume. Also, be careful not to block rendering with your RUM script; load it asynchronously or defer it.
Alternatives and Complementary Tools
If you cannot use a full RUM tool, you can use the PerformanceNavigationTiming API and the PerformanceObserver API to collect route-level timings manually. Libraries like web-vitals (from Google) can help you measure Core Web Vitals in your SPA and send them to your analytics.
Synthetic monitoring (e.g., Lighthouse CI, Playwright scripts) is another alternative. It runs performance tests from a controlled environment, which is useful for catching regressions before users see them, but it does not reflect real user conditions.
For a comprehensive view, combine CrUX (for external benchmarking), RUM (for internal route-level data), and synthetic monitoring (for pre-release testing).
Frequently Asked Questions
Does CrUX support SPA route changes?
No, CrUX does not track client-side route changes. It only reports on full page loads. For SPA route performance, you need RUM.
Can I use CrUX data to set performance budgets for my SPA?
You can use CrUX for initial load budgets, but not for route-level budgets. Use RUM to set and enforce budgets for individual routes.
What is the difference between field data and lab data?
Field data is collected from real users (like CrUX and RUM). Lab data is collected in a controlled environment (like Lighthouse). Field data is more representative, but lab data is more reproducible.
How do I measure route performance in a SPA with RUM?
You need to instrument your router to start a timer on route change and stop it when the route's content is rendered. Most RUM tools have built-in SPA support; otherwise, you can use the Performance API to mark the start and end times.
Is RUM worth the cost for a small SPA?
Yes, because you can start with free or open-source tools. Even a simple custom RUM implementation can give you valuable insights into route performance that CrUX cannot provide.