Single-page app add-on: #/ routes, back/forward restores and prerendering
Hash-routed apps otherwise look like one page, and back/forward-cache restores are silently missed.
An optional add-on for apps that use hash routes (#/settings), and for any site where people use Back and Forward a lot. The core script stays exactly as it is.
Why quietstats: you get this without cookies, a consent banner or storing IP addresses, in every plan including Free.
In every plan, including Free. Privacy and performance.
📘 Step-by-step guide, with screenshots and diagrams →
Start free, no cardSee live demo
- No cookies or consent banner
- No IP addresses stored
- Groups under 5 visitors hidden
- 845-byte script
- Free plan, no card


What it is
spa.js sits next to script.js or events.js, or goes into a one-file bundle. With data-hash on the tag, each #/ route counts as its own page (stored as /app#/settings, without the route’s query part); plain #section anchors are ignored, and the first route on load is attached to the core script’s pageview rather than counted twice. Pages restored from the browser’s back/forward cache are counted, which the core script cannot see. The add-on’s own pageviews wait until a prerendered page is actually shown.
Why it matters
Hash-routed apps otherwise look like one page, and back/forward-cache restores are silently missed. Fixing both in an add-on keeps the standard script small and unchanged for everyone else.
How it works
- Add the add-on tag after your quietstats tag, with data-hash if your app uses #/ routes.
- Or open Manage site → One-file bundle, tick Single-page apps and Count #/ routes as pages, and use the one tag it gives you.
- Routes appear in Top pages as /path#/route.
Privacy: what is and isn’t collected
Collected
- The #/ route as part of the page path (no query part)
- Nothing else new: the same pageview as the core script
Never collected
- Cookies or anything stored in the browser
- Plain #section anchors
- The query part of a route, such as ?token=…
- Cookies, localStorage or anything else stored on the visitor’s device
- IP addresses or user agents (used in memory, then discarded)
- Anything that links a visitor across days (the visitor ID resets daily)
Rows and limits
- The core script still counts its first pageview when a page is prerendered; only the add-on’s own pageviews wait for the page to be shown
- Scroll and engaged time (data-engage) still attach to the page without its #/ route
- spa.js is about 1.3 KB; script.js is unchanged at 845 bytes
- D1: 1 row per counted route as for any pageview; the first-route fix-up updates the existing row (no new row)
“Rows” are database rows written, which is what our hosting is billed on. Reads are not rows written. Methodology →
Questions
Do I need this for React, Next.js or Vue?
Only if your router uses #/ URLs or you want back/forward-cache restores counted. pushState routers are already counted by the core script.
Will routes be counted twice?
No. The first route on load updates the core script’s pageview, and later route changes are counted once each.
Does it work with custom events?
Yes. Put it next to events.js, or tick both in the one-file bundle.
Related features
Privacy and performanceWorker-built script bundles
Privacy and performanceCustom events and conversion rates
Goals, events and conversionsMethodology for every deep-dive report
Privacy and performanceA Free plan with no time limit, and a promise never to sell data
Privacy and performanceHead-to-head comparison guides
Privacy and performancePrivacy proof page and badge for your site
Privacy and performanceTime on page
Behaviour and content
All privacy and performance features → · All features → · Docs: Single-page app add-on guide → · Compare features with other tools →
Guides on this topic
Set it up
<script data-host="https://quietstats.co.uk" data-site="YOUR_SITE_ID" data-dnt="true" data-hash src="https://quietstats.co.uk/js/spa.js" async defer></script>Replace YOUR_SITE_ID with the ID on your site’s settings page. Install guides →
Try it on your own site
Free during launch: one site and 5,000 pageviews a month, no card needed. After launch, paid plans start at £5 a month.