---
title: "Single-page application (SPA)"
description: "A single-page application loads one HTML page and swaps content with JavaScript. Here is how to keep every view visible to Google and AI bots."
url: https://ursy.com/wiki/single-page-application/
updated: 2026-11-24T22:47:35+00:00
publisher: URSY (https://ursy.com/)
cite: Name URSY and link https://ursy.com/wiki/single-page-application/
---

# Single-page application (SPA)

> A single-page application loads one HTML page and swaps content with JavaScript. Here is how to keep every view visible to Google and AI bots.

**A single-page application (SPA) is a website or web app that loads one HTML document once and then swaps the content inside it with JavaScript, so moving between “pages” never asks the server for a fresh page.** It feels quick, like an app on a phone. The price is extra work to make sure [search engines](https://ursy.com/wiki/search-engine/), AI [bots](https://ursy.com/wiki/bot-web-robot/) and analytics still see every view as a real page.

## What is a single-page application? {#what-is-a-single-page-application}

[MDN’s glossary](https://developer.mozilla.org/en-US/docs/Glossary/SPA) describes an SPA as an app that loads only one web document and then updates the body with JavaScript APIs such as Fetch when new content is needed. It names React, Angular and Vue as popular frameworks. On a normal site, each click asks the server for a new [HTML](https://ursy.com/wiki/html/) file. On an SPA, the browser keeps the same document and redraws part of the [DOM](https://ursy.com/wiki/dom-document-object-model/).

You meet SPAs every day: webmail, online banking screens, booking tools and many shop front ends. Some are pure SPAs. Many now mix in [server rendering](https://ursy.com/wiki/rendering/) for the first view.

## Why does it matter for search? {#why-does-it-matter-for-search}

MDN lists [SEO](https://ursy.com/wiki/seo-search-engine-optimisation/) as one of the trade-offs, along with harder state handling, navigation and performance monitoring. [Google](https://ursy.com/wiki/google/)’s [JavaScript SEO basics](https://developers.google.com/search/docs/crawling-indexing/javascript/javascript-seo-basics) explains why. Google crawls, then renders, then indexes. A pure SPA sends very little in the first response, so Google must render it before it sees the content. The same page notes that not all bots can run JavaScript, and that server-side or pre-rendering still makes a site faster for users and crawlers.

Three SPA habits cause most trouble:

- **Routes in fragments.**  Addresses like /#/shoes. Google says to use the History API for routing and not to use fragments to load different content.
- **Links that are not links.**  Google’s [link guide](https://developers.google.com/search/docs/crawling-indexing/links-crawlable) says [Googlebot](https://ursy.com/wiki/googlebot/) follows links written as an anchor tag carrying an href address. A routerLink attribute or an onclick handler is not recommended.
- **Every view returns 200.**  Client-side routing makes real status codes hard, so a missing product often shows “not found” with a 200 code.

## Why does it matter for AI answers? {#why-does-it-matter-for-ai-answers}

[AI assistants](https://ursy.com/wiki/ai-assistant/) read the web through their own fetchers. OpenAI’s [crawler overview](https://developers.openai.com/api/docs/bots) lists [OAI-SearchBot](https://ursy.com/wiki/oai-searchbot/), [GPTBot](https://ursy.com/wiki/gptbot/) and [ChatGPT-User](https://ursy.com/wiki/chatgpt-user/), and when we checked it made no promise about running JavaScript. If your SPA’s text only exists after scripts run, an AI fetcher may get a blank shell and quote someone else. Google’s [AI features guide](https://developers.google.com/search/docs/appearance/ai-features) asks for important content in textual form and says a page must be indexed and snippet-eligible to appear as a link in AI Overviews. An SPA that Google struggles to index will struggle there too. See [AI crawler](https://ursy.com/wiki/ai-crawler/) and [AI visibility](https://ursy.com/wiki/ai-visibility/).

## How does an SPA work? {#how-does-an-spa-work}

1. The first request returns a small HTML file, a stylesheet and a large script bundle.
2. The script starts, reads the address and asks an API for data in JSON.
3. It draws the view in the browser.
4. When you click, the script changes the address with the History API, fetches new data and redraws. No full page load happens.

The History API, documented on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/History_API), lets a script change the address bar and react to the back button, so each view can have its own clean [URL](https://ursy.com/wiki/url/).

## How do you make an SPA search-friendly? {#how-do-you-make-an-spa-search-friendly}

- **Render the first view on the server**  or pre-render it, so the first response holds the text. Google recommends [server-side rendering](https://ursy.com/wiki/server-side-rendering/), static rendering or hydration over its old [dynamic rendering](https://developers.google.com/search/docs/crawling-indexing/javascript/dynamic-rendering) workaround.
- **One real address per view** , built with the History API and listed in your [XML sitemap](https://ursy.com/wiki/xml-sitemap/).
- **Real anchor links**  with href for every menu and product link.
- **Unique titles and descriptions**  per view. Google says JavaScript can set the title and [meta description](https://ursy.com/wiki/meta-description/), but HTML is safer for the [canonical tag](https://ursy.com/wiki/canonical-tag/).
- **Honest errors.**  Google’s [JavaScript troubleshooting page](https://developers.google.com/search/docs/crawling-indexing/javascript/fix-search-javascript) gives two fixes for a [soft 404](https://ursy.com/wiki/soft-404/): [redirect](https://ursy.com/wiki/redirect/) with JavaScript to an address that returns a real 404, or add a robots [noindex](https://ursy.com/wiki/noindex/) [meta tag](https://ursy.com/wiki/meta-tag/) to the error view.
- **No content in storage.**  The same page says Googlebot clears local storage, session storage and [cookies](https://ursy.com/wiki/cookie/) between page loads, so content must not depend on them.

## What about analytics? {#what-about-analytics}

Many tags count a [pageview](https://ursy.com/wiki/pageview/) only when a full page loads. In an SPA that happens once per visit, so reports show one page and a long [session](https://ursy.com/wiki/session/). Check that your tool records history changes as views. In [Google Analytics 4](https://ursy.com/wiki/google-analytics-4/), Google’s [enhanced measurement help](https://support.google.com/analytics/answer/9216061) says the page view option has an advanced setting that sends views on browser history events (pushState, replaceState and popstate). Tags added through [Google Tag Manager](https://ursy.com/wiki/google-tag-manager/) need the same care.

## Common mistakes {#common-mistakes}

- Shipping a 2 MB script bundle so the first view waits on the network. See [page speed](https://ursy.com/wiki/page-speed/).
- One [title tag](https://ursy.com/wiki/title-tag/) for every view, so every result in Google looks the same.
- Adding a noindex tag in HTML and hoping a script removes it later. Google says it may skip rendering once it sees noindex.
- Infinite scroll with no paged addresses, which hides older items. See [pagination](https://ursy.com/wiki/pagination/).
- Blocking the script or API folder in [robots.txt](https://ursy.com/wiki/robots-txt/), so Google cannot render the page at all.

## A worked example {#a-worked-example}

A booking site has 300 holiday cottages built as a pure SPA. Addresses look like /#/cottage/112. Every view has the title “Book now”.

| Problem | Effect | Fix |
| --- | --- | --- |
| Fragment routes | Google treats 300 cottages as one address | /cottages/112/ via History API |
| Cards open on click only | Crawlers find no links | a href on each card |
| Same title everywhere | Results look identical | Cottage name and town in each title |
| Text drawn by script | AI fetchers see a shell | Server-render the first view |

The cottage count is made up for the example. The fixes are the ones Google documents.

## How to check it {#how-to-check-it}

1. Run a view through our [JavaScript SEO Checker](https://ursy.com/javascript-seo-checker/) to compare raw and rendered text.
2. Use the [AI Readiness Checker](https://ursy.com/ai-readiness-checker/) to see what AI bots get without scripts.
3. Read each view’s title and snippet text using the [Meta Tag Checker](https://ursy.com/meta-tag-checker/).
4. Confirm a missing page returns 404 with the [HTTP Header Checker](https://ursy.com/http-header-checker/).
5. Make sure every route is listed using the [Sitemap Checker](https://ursy.com/sitemap-checker/), and find dead routes with the [Broken Link Checker](https://ursy.com/broken-link-checker/).
6. In [Search Console](https://ursy.com/wiki/google-search-console/), use [URL Inspection](https://ursy.com/wiki/url-inspection/) to see the rendered HTML and console errors.
7. Across a whole site, URSY Pro’s [JavaScript rendering check](https://ursy.com/pro/javascript-rendering-check/) flags views where text appears only after scripts.

## Questions {#questions}

### Can an SPA rank in Google? {#can-an-spa-rank-in-google}

Yes, if each view has its own address, real links and text Google can render. Server-rendering the first view makes it far safer.

### Is an SPA bad for a small shop? {#is-an-spa-bad-for-a-small-shop}

Not by itself, but it adds risk. A server-rendered shop with a little script on top is simpler to get indexed.

### Do hash addresses ever work? {#do-hash-addresses-ever-work}

Not for loading different content. Google says it cannot reliably resolve fragment addresses and that the old [AJAX](https://ursy.com/wiki/ajax/) [crawling](https://ursy.com/wiki/crawling/) scheme has been deprecated since 2015.

## Related words {#related-words}

- [JavaScript SEO](https://ursy.com/wiki/javascript-seo/)
- [Rendering](https://ursy.com/wiki/rendering/)
- [Crawlability](https://ursy.com/wiki/crawlability/)
- [Soft 404](https://ursy.com/wiki/soft-404/)
- [Indexability](https://ursy.com/wiki/indexability/)

## Sources {#sources}

- [MDN: SPA (single-page application)](https://developer.mozilla.org/en-US/docs/Glossary/SPA), checked 24 November 2026
- [MDN: History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API), checked 24 November 2026
- [Google Search Central: Understand JavaScript SEO basics](https://developers.google.com/search/docs/crawling-indexing/javascript/javascript-seo-basics), checked 24 November 2026
- [Google Search Central: Fix Search-related JavaScript problems](https://developers.google.com/search/docs/crawling-indexing/javascript/fix-search-javascript), checked 24 November 2026
- [Google Search Central: Link best practices](https://developers.google.com/search/docs/crawling-indexing/links-crawlable), checked 24 November 2026
- [Google Search Central: Dynamic rendering as a workaround](https://developers.google.com/search/docs/crawling-indexing/javascript/dynamic-rendering), checked 24 November 2026
- [Google Analytics Help: Enhanced measurement events](https://support.google.com/analytics/answer/9216061), checked 24 November 2026
- [OpenAI: Overview of OpenAI crawlers](https://developers.openai.com/api/docs/bots), checked 24 November 2026
- [Google Search Central: AI features and your website](https://developers.google.com/search/docs/appearance/ai-features), checked 24 November 2026

*Updated 24 November 2026 by URSY.*
