SPA Support
Single-page application navigation tracking
Last updated:
How It Works
The Insights SDK automatically detects page navigations in single-page applications (SPAs) by patching history.pushState and history.replaceState. No additional configuration is needed.
When a navigation occurs, the SDK:
- Records the new URL as a page change event
- Captures heatmap data against the new page path
- Tracks the navigation for funnel analysis
Supported Frameworks
SPA navigation is automatically detected in:
- React Router (v5 and v6)
- Next.js (App Router and Pages Router)
- SvelteKit
- Vue Router / Nuxt
- Angular Router
- Any framework that uses
history.pushStateorhistory.replaceState
Hash-Based Routing
Hash-based routing (/#/page) is also detected via the hashchange event.
Troubleshooting
If page navigations aren’t being tracked:
- Ensure the SDK is initialized before your router. The history patching needs to happen early
- Check that your framework uses the standard History API (most do)
- If using a custom navigation system that bypasses
history.pushState, page changes won’t be detected automatically