Technical SEO

SEO for Single-Page Applications: Routing, Rendering and Indexation

A single-page application swaps views with JavaScript instead of loading new pages — which is exactly where search engines lose track of it. Here is how routing, rendering and indexation actually work for SPAs, and how to make every view findable, crawlable and indexable.

9 min readBy the Zeshly editorial team
SEO for Single-Page Applications: Routing, Rendering and Indexation

A single-page application loads one HTML document and then swaps views with JavaScript instead of asking the server for a new page. For the person using it, that feels fast and seamless. For a search engine, it can mean something very different: a site with one page and no content at all. The gap between those two experiences is the whole subject of SPA SEO. It is not a single trick or a plugin. It is three separate problems that have to be solved together — routing, rendering and indexation — and a site that solves only one of them usually still fails.

The confusion starts with a reasonable assumption: Google can run JavaScript, so a JavaScript app should be fine. Google can run JavaScript, and it does, every day, at enormous scale. But running JavaScript is not the same as seeing your site the way a visitor sees it. Google processes a JavaScript page in three phases — crawling, rendering and indexing — and rendering happens in a separate queue from crawling. A page can be crawled today and rendered later, and Google says a page may stay in that queue for a few seconds but it can take longer than that. That delay is the first cost of a client-rendered SPA — your content exists, but search engines see it late.

Routing: every view needs a real URL

The first problem is addressability. A search engine indexes URLs, not views. If your app shows fifty different products but they all live at one URL, the search engine has one page to index, not fifty. The router is what decides whether each view gets its own address. Modern routers do this with the History API: when a visitor clicks a link, JavaScript updates the address bar with a clean path such as /products/shoes, using pushState, and swaps the content in the browser. The URL looks like a normal page URL, and it can be bookmarked, shared and linked to.

Older SPAs did it differently, with URL fragments: a product lived at example.com/#/products/shoes. The fragment — everything after the hash — was never sent to the server, so the server always returned the same single document no matter which view was requested. Google's old AJAX crawling scheme, which used hashbang URLs written as #!, was built to paper over this problem, and Google deprecated it in October 2015. Its current guidance is plain: do not use fragments to represent different pages of content. Any SPA still routing by fragment has an indexation problem that no rendering work will fix, because the crawler cannot even ask for the views separately.

Clean paths alone are not enough. A soft navigation — the router changing the URL and the content without a server request — creates no new server response. If a crawler asks the server directly for /products/shoes, the server has to answer with something useful. Many SPA servers return the same app shell for every path, with a 200 status code. That keeps the app working for visitors, who load the shell and let the router sort it out. For a crawler, a deleted product and a live product look identical: both return 200 with the same near-empty HTML. Google calls the result a soft 404 — a page that behaves like an error but reports success. The server side of routing needs real answers: a 200 with real content for a live route, a genuine 404 for a route that no longer exists, and a redirect where a route has moved.

Rendering: what the server sends decides everything

The second problem is rendering. In a purely client-rendered SPA, the server sends an almost empty HTML shell — a container element and a bundle of JavaScript — and the browser builds the page. A crawler that does not run JavaScript sees nothing. Google does run JavaScript, so Google eventually sees the content, but every other consumer of your pages is a question mark. The fix is to make sure the content exists in the first response.

There are three mainstream ways to do that, and they differ in where the HTML is built. Static rendering builds the HTML at deploy time, so each URL is a finished file on the server; it fits pages whose content changes rarely. Server-side rendering builds the HTML on every request, so the content is always fresh; it needs a server that can render on demand. Hydration combines the two: the server sends finished HTML, and JavaScript then attaches interactivity in the browser, so the page is complete before any script runs. All three put the same thing in the crawler's hands — real content in the first HTML response — and Google's own guidance recommends server-side rendering, static rendering or hydration over the alternatives. Prerendering is a cheaper middle step: the app is run in a browser at build time and the resulting HTML is saved, so public pages ship as finished documents — though content is then fixed until the next build.

Dynamic rendering is a workaround, not a plan

For years, the standard workaround was dynamic rendering: detect a crawler by its user agent, send it a pre-rendered HTML snapshot, and serve everyone else the JavaScript app. Google described the technique in 2018 and now writes about it in the past tense — dynamic rendering was a workaround for indexable, public JavaScript-generated content. Its documentation now points to server-side rendering, static rendering or hydration instead, and says plainly that not all sites need dynamic rendering. The reasons are practical: user-agent detection is fragile, since every new crawler has to be added to the list by hand, and serving different content to bots and to people is risky by design — a snapshot that drifts out of sync with the live app edges toward cloaking, and keeping two serving paths in sync is permanent extra work. It can still make sense as a stopgap while a legacy app is being migrated, but it is not a pattern to build new work on.

Indexation: status codes, links and metadata

Once routing and rendering are right, the remaining work is the ordinary indexation checklist — except that in an SPA, every item on it has to be built in JavaScript, which is where it usually breaks. Links are the first item. Google can only follow links reliably when they are anchor elements with an href attribute. A router link that renders as a real anchor tag is fine; a clickable span or div with an on-click handler is not a link to a crawler, even if it behaves like one for a visitor. Confirm that every route you want indexed is reachable through real anchor tags — including navigation, pagination and filters. If the only way to reach a view is a JavaScript interaction, crawlers will not find it.

Metadata is the second item. Title tags, descriptions, canonical URLs and robots tags all have to change as the router changes views — and they have to change in the rendered page, not only in the app's internal state. An SPA that keeps one title for every route hands Google fifty pages with the same title, and an SPA that sets its canonical tag in JavaScript after the page loads can leave Google looking at a half-finished document. Structured data has the same requirement: JSON-LD injected by JavaScript is accepted by Google, but only if it is present in the rendered page, which is worth testing rather than assuming. The sitemap is the third item, and it is the easiest to get wrong in an SPA: a sitemap that lists routes the server cannot actually serve sends crawlers to URLs that return an empty shell. Generate the sitemap from the same route list the app uses. Finally, watch lazy loading: content that only appears after scrolling or clicking is content a crawler may never trigger, because Google does not scroll or click the way a visitor does. Anything that matters for search should be in the page on first load, not behind an interaction.

The AI crawler problem

The rendering question has grown sharper, because Google is no longer the only search surface that matters. AI search tools send their own crawlers, and most do not document any JavaScript rendering at all. A study by Vercel and MERJ, published in December 2024, found that none of the major AI crawlers rendered JavaScript: the crawlers from OpenAI, Anthropic and Perplexity all read the raw HTML only. Google's own AI crawler renders, because it uses the same service as Googlebot, and Apple's crawler renders too — but those are the exceptions. If your key content only exists after JavaScript runs, it is invisible to the tools that increasingly answer questions instead of listing links. The fix is the same — finished HTML in the first response — but the reason has changed: it is about every crawler that never queues a render at all.

Testing your SPA the way a crawler sees it

The most common SPA SEO mistake is testing the app as a visitor. Open the page in a browser and everything works, so the team assumes search engines see the same thing. Test it as a crawler instead. Fetch a route with curl and read what the server actually returns: if the body is an empty container and a script tag, that is what every non-rendering crawler gets. Turn JavaScript off in the browser and load the page: what you see is the floor of what any crawler can see without rendering. Check the rendered HTML in Search Console's URL Inspection tool, which shows the page after Google renders it, and compare it with the raw HTML — the difference is exactly how much of your page depends on the render queue.

Then test the routes one by one. Request a deep URL directly and confirm the server returns the right status code and the right content, not the generic shell with a 200. Request a URL that should not exist and confirm it returns a real 404. Check that the title, description and canonical change per route, and that the sitemap lists the routes the app actually serves. This is a short audit — an afternoon, not a project — and it finds most SPA problems before they cost months of invisible pages.

A practical order of work

If you are fixing an existing SPA, work in the order that removes the most risk first. Start with routing: move off fragments to History API paths, make the server return real status codes, and confirm every public view has a unique URL. Then fix rendering for the pages that matter most for search — usually the landing pages, category pages and key content pages — rather than trying to convert the whole app at once. Then fix the indexation details: real anchor links, per-route metadata, a sitemap generated from the route list, and content that loads without interaction. Finally, repeat the tests above regularly, because SPA regressions are silent: a router change or a new lazy-load can un-index a set of pages without anyone noticing until traffic falls.

The decision that matters most is the one made before the app is built. A single-page application is a good architecture for a tool people log into and use — a dashboard, an editor, a checkout flow. It is a poor default for content that needs to be found: articles, product pages, category pages, documentation. For those pages, choose a framework that renders on the server or at build time from the start. The fastest SPA SEO fix is the one you never need, because the architecture already sends search engines finished pages.

This article is educational guidance on single-page application SEO; rendering behaviour, crawler capabilities and search features change, rankings and visibility vary by site, implementation, competition and execution, and nothing here guarantees a ranking or any number of new visitors.

Explore the full Zeshly product suite, read more on the Zeshly blog, or head back to the homepage.

Ready to put this into practice?

Spin up Zeshly free for 14 days and ship the playbook above on your own site.