React SPA serves empty HTML? What Google sees and how to fix it

Your React or Vite app sends an empty div id="root" to crawlers. How to see what search engines get, and fix it with prerendering, real links and real 404s.

· 6 min read

You open your React app in a browser and everything is there: headings, text, pricing, a blog. Then you run curl on the same address, or look at the page source, and see almost nothing. A <title> you set months ago, a <div id="root"></div>, and a script tag. Search Console shows pages as "Crawled - currently not indexed", or every page in the results carries the same title.

That empty shell is how a client-side rendered single-page app works. It is not automatically an SEO disaster, but it moves a lot of risk onto the crawler. This guide explains what actually happens, how to see your site the way a crawler does, and which fixes are worth the effort.

Why a React SPA ships empty HTML

A typical React app built with Vite, Create React App, Lovable or Bolt has a single index.html. The server returns that file for every route: /, /pricing, /blog/some-post. The browser downloads the JavaScript bundle, React runs, reads the URL and builds the page inside #root.

So the HTML response contains no content. Everything a reader sees exists only after JavaScript runs.

Google handles this in stages. Its JavaScript SEO basics describe crawling, then rendering in a headless browser, then indexing. Rendering can happen later than the crawl, and Google recommends server-side or pre-rendering because it makes the site faster for users and crawlers, and because not every bot runs JavaScript.

That last part matters more than it used to. Link previews in Slack, WhatsApp, X and LinkedIn read only the raw HTML. Many other search engines and AI assistants fetch pages without rendering them. For all of them, your SPA is an empty page with one title.

Three side effects make it worse:

  • One title for every route. Unless something updates <title> and the meta description per route, every page shares the default from index.html.
  • Soft 404s. A missing route like /this-does-not-exist still returns status 200 with the same shell. To a crawler, any typo or old link looks like a real page with the same content as your home page.
  • Links that are not links. Navigation built with onClick on a div or button works for people but gives the crawler nothing to follow. Google only follows <a> elements with an href.

Check it yourself

You need a terminal and five minutes. Replace yourdomain.com with your address.

1. Look at the raw HTML

curl -s https://yourdomain.com/ | head -40

If the body is just <div id="root"></div> and a script, you have a pure client-rendered page. Note what the <title> and <meta name="description"> say.

2. Compare two different routes

curl -s https://yourdomain.com/ | grep -i '<title>'
curl -s https://yourdomain.com/pricing | grep -i '<title>'

Identical titles mean every page looks the same to any crawler that does not run JavaScript, and to every link preview.

3. Request a page that does not exist

curl -s -o /dev/null -w '%{http_code}\n' https://yourdomain.com/no-such-page-12345

200 is a soft 404. A healthy site answers 404.

4. See the rendered version Google got

In Google Search Console, open URL Inspection, paste a page address, click Test live URL, then View tested page. The HTML tab shows the rendered DOM, and the screenshot shows what Googlebot saw. If the content is there, Google can render your app. If the screenshot is blank or shows a loading spinner, rendering failed or timed out: often an API call that needs a login, a blocked script, or an error thrown on startup.

5. Check your links

In the browser, right-click a menu item and choose Inspect. You want to see <a href="/pricing">. If you see a div or button with a click handler, or links like /#/pricing, crawlers cannot discover those pages. Google's documentation says it generally does not support URL fragments for loading different content, so hash routing hides every route behind the home page.

How to fix it

Pick the smallest fix that solves your actual problem.

Put the basics into index.html

Even with nothing else changed, a real <title>, a meta description and Open Graph tags in the static index.html fix link previews for the home page and give every non-rendering crawler something accurate. This takes a minute and is always worth doing.

Set the title per route

Use React 19's built-in <title> and <meta> support, or a library such as react-helmet-async on older versions, so each route sets its own title and description. Google sees these after rendering. Previews and non-rendering crawlers still see only index.html, which is why the next step exists.

Prerender the pages that matter

Prerendering means generating finished HTML for each public route at build time. The server then sends real content, and React takes over in the browser. For marketing pages, docs and a blog, this is the fix with the best payoff.

If you use React Router v7 in framework mode, it is a config option. The pre-rendering guide shows prerender: true for static routes, or a list of paths that includes dynamic ones like blog posts, and it works with ssr: false for static hosting. Next.js, Astro and similar frameworks produce static HTML by default for pages without per-request data.

Keep the app behind login as a normal SPA. It does not need to be indexed.

Google also describes "dynamic rendering", serving a prerendered copy only to bots, but calls it a workaround and recommends server-side rendering, static rendering or hydration instead. Do not start a new project with it.

Return real 404s

With prerendering or a server, return status 404 for unknown paths. On a pure static SPA host where every path falls back to index.html, Google's guidance is to either redirect unknown routes to a URL that returns a real 404, or add <meta name="robots" content="noindex"> on your not-found view.

Use real links and path-based routes

Every navigation element that leads to a page should be an <a href>. React Router's <Link> renders one. Replace hash routes (/#/pricing) with normal paths (/pricing) and configure your host to serve the app for those paths.

A prompt for your AI tool

Paste this into Lovable, Cursor or Claude Code and adjust the routes:

My React app is client-side rendered and crawlers receive an empty
<div id="root">. Fix SEO without changing how the app looks:

1. In index.html, set a real <title>, <meta name="description">,
   og:title, og:description and og:image for the home page.
2. Give every public route its own title and meta description.
3. Prerender these public routes at build time into static HTML:
   /, /pricing, /about, /blog and every /blog/:slug.
   Leave the logged-in app as a client-side SPA.
4. Make unknown routes return HTTP 404, or if the host cannot do that,
   render a not-found page with <meta name="robots" content="noindex">.
5. Make sure all navigation uses <a href> (React Router <Link>), and no
   routes use hash URLs like /#/page.

After the change, show me the output of
curl -s https://<my-domain>/pricing | head -40
so I can confirm the content is in the HTML.

Then repeat the five checks above. curl on a public route should now show real text, and each route should have its own title.

Keep it from breaking again

Prerendering is a build step, and build steps quietly stop working. A dependency update, a new route added outside the prerender list, or a refactor of the head tags can send you back to empty HTML without anyone noticing, because the site still looks fine in a browser.

The same goes for the rest of the basics. If the problem started with "my site isn't on Google", the checklist in Why your Lovable site isn't showing up on Google covers noindex, robots.txt and sitemaps.

ScanYourSite looks at your page both ways, the raw HTML and the page rendered in a real browser, and reports which one is missing the title or description, whether Open Graph tags exist before JavaScript runs, whether a noindex slipped in, and whether unknown URLs answer 200 instead of 404. The free check covers one site weekly. Pro runs daily and after each deploy, so a broken prerender shows up the day it ships. You can see what it checks for AI-built sites, or run it now: https://scanyoursite.app/?check=yourdomain.com

Check your own site in a minute

Free, no sign-up. You get a prioritised list of what’s wrong and a prompt you can paste back into Lovable, Bolt, Cursor or Claude Code.

Free, no sign-up. The basic check makes only the requests an ordinary browser would.

SEO for AI-built sites