Docs

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:

  1. Records the new URL as a page change event
  2. Captures heatmap data against the new page path
  3. 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.pushState or history.replaceState

Hash-Based Routing

Hash-based routing (/#/page) is also detected via the hashchange event.

Troubleshooting

If page navigations aren’t being tracked:

  1. Ensure the SDK is initialized before your router. The history patching needs to happen early
  2. Check that your framework uses the standard History API (most do)
  3. If using a custom navigation system that bypasses history.pushState, page changes won’t be detected automatically