# Single-page apps

> How the widget follows client-side navigation in React, Vue, Next.js and other single-page apps, and what to do about a missed route.

In a single-page app the URL changes without loading a new page. The widget notices, and treats each new route as a new page view:

1. Popups, banners and other elements it added for the previous route are removed.
2. Your rules are checked again against the new URL, and matching actions are applied.
3. A page view is recorded, and goals that match the new URL can fire.

## What's detected automatically

- `history.pushState()` and `history.replaceState()`, which is how React Router, Vue Router, Next.js, Nuxt, SvelteKit and Angular change routes
- the browser's back and forward buttons (`popstate`)
- hash changes (`hashchange`), for hash-based routers

There's nothing to set up for any of these.

## Extra route-change detectors

Some sites change what's on screen without going through the History API. If route changes go unnoticed, switch on extra detectors. They're options to `GeoEngage.init()`, so the widget has to be [started by your own code](https://geoengage.app/docs/widget#starting-the-widget-yourself):

```js
GeoEngage.init({
  navigation: {
    enablePolling: true,    // compare the URL on a timer…
    pollingInterval: 500,   // …every 500 ms, the default
    observeTitle: true,     // check the URL whenever <title> changes
    interceptClicks: true,  // check the URL on clicks on internal links
  },
});
```

All of them are off by default. Switch on only what you need: polling, in particular, keeps running for as long as the page is open.

## Telling the widget yourself

If your router bypasses the History API entirely, call `notifyRouteChange()` after each route change:

```js
myRouter.on('change', () => window.GeoEngage?.notifyRouteChange());
```

> [!WARNING]
> Don't call it for route changes the widget already detects. Each call records a page view, so you'd count every one of those routes twice.

---

Source: https://geoengage.app/docs/widget/single-page-apps
