React SEO and Vite SEO: meta tags, prerendering and soft 404s
How Google crawls and renders a React or Vite app: React 19 native title, meta and canonical tags, prerendering vs SSR, and avoiding SPA soft 404s and hash URLs.
A plain React and Vite app sends an empty <div id="root"></div> in its first HTML response, then fills the page in the browser. Google can still index it because Googlebot runs JavaScript in headless Chromium. Every public page waits in Google's render queue first, crawlers that skip JavaScript see an empty shell, and client-side routing turns missing URLs into soft 404s unless you handle them. For pages meant to rank in search, prerender them to HTML at build time or render them on the server, and set one <title>, description and canonical per route.
Every rule below comes from the React 19 documentation, Vite's SSR guide, and Google Search Central's JavaScript SEO documentation, linked at the end.
TL;DR:
- Client-only Vite SPAs wait on Google's render queue. Pre-render public marketing and blog routes to HTML, or use server rendering, so crawlers read the content in the first HTTP response.
- React 19 hoists
<title>,<meta>and<link>into<head>natively. You do not needreact-helmeton React 19. - Pass
<title>one string, and render only one at a time. Two<title>tags in the tree put two<title>elements in<head>. - Leave any hardcoded canonical out of Vite's
index.htmlif you set per-page canonicals in React. - Use History API links (
<a href="/pricing">), never#fragments, and redirect missing routes to a real HTTP 404 or addnoindexso missing URLs do not become soft 404s.
Can Google index a client-side React and Vite app?
Yes, after a second step. Google Search Central explains that Google processes JavaScript apps in three phases: Crawling, Rendering and Indexing. When a site uses the app-shell model, "the initial HTML does not contain the actual content and Google needs to execute JavaScript before being able to see the actual page content that JavaScript generates."
Googlebot queues every indexable 200 response for rendering, then runs headless Chromium to execute the bundle and read the rendered DOM. Google notes that a page "may stay on this queue for a few seconds, but it can take longer than that", and adds the practical advice directly: "server-side or pre-rendering is still a great idea because it makes your website faster for users and crawlers, and not all bots can run JavaScript."
That split decides the architecture on most client projects:
- Behind a login (dashboards, settings, internal tools): pure Vite client rendering is fine, because none of those screens belong in Google.
- Public pages meant to rank (home, service pages, pricing, docs, blog): pre-render them at build time or render them on the server so the title, copy and links arrive in the raw HTML.
How do you set title, meta and canonical tags in React 19?
Render <title>, <meta> and <link> straight inside the page component. In React 19, React DOM hoists all three into the document <head> automatically, both in the browser and during server rendering or static prerendering.
type Props = {
slug: string
title: string
summary: string
}
export function ServicePage({ slug, title, summary }: Props) {
const url = `https://example.com/services/${slug}`
return (
<main>
<title>{`${title} · Example Studio`}</title>
<meta name="description" content={summary} />
<link rel="canonical" href={url} />
<h1>{title}</h1>
<p>{summary}</p>
</main>
)
}
Two traps in the React 19 <title> docs catch teams moving off react-helmet:
- Render only one
<title>at a time. React does not override a parent layout's<title>with a child page's<title>. Its docs warn: "If more than one component renders a<title>tag at the same time, React will place all of those titles in the document head. When this happens, the behavior of browsers and search engines is undefined." Keep<title>out of your shared layout unless the child page omits it, and delete any static<title>sitting in Vite'sindex.htmlonce every route renders its own. - Pass a single string child. Writing
<title>{title} · Example</title>passes a two-element array to<title>and throws an error in React. Interpolate a single template string instead, as in<title>{`${title} · Example`}</title>.
For canonical tags on a client-rendered Vite app, check index.html too. Google's JavaScript SEO guide states: "you shouldn't use JavaScript to change the canonical URL to something else than the URL you specified as the canonical URL in the original HTML." If index.html carries <link rel="canonical" href="https://example.com/"> and React injects a second URL on /pricing, Google sees conflicting canonicals. Leave the canonical out of index.html when React sets it per route, or pre-render each route so the right canonical is in the HTML from the start.
Try it
Point an SEO agent at your own site, not just an essay about one.
QueryScope holds the plan for your site, reads your real Search Console, and hands the coding agent you already have one change at a time to rank for the searches you decided to win. From $49/month, everything included.
How do you add prerendering or SSR to a Vite React app?
If you want to keep Vite without moving to a full framework, React 19's react-dom/static package exports prerender, and Vite's SSR guide documents pre-rendering known routes into static HTML files at build time.
In index.html, leave placeholders where the head tags and body HTML go, or render the full document in your server entry with prerender:
// prerender.tsx
import { prerender } from 'react-dom/static'
import { App } from './src/App'
export async function renderRoute(url: string): Promise<string> {
const { prelude } = await prerender(<App url={url} />)
return await new Response(prelude).text()
}
Because prerender waits for data to finish loading before returning the prelude stream, the <title>, <meta> and <link rel="canonical"> tags from your route component land inside <head> in the generated .html file.
In practice, before maintaining a custom Vite SSR server and sitemap script by hand, weigh the framework options your team already uses:
- Mostly content and marketing pages with interactive React islands: Astro renders static HTML by default and mounts React components only where needed.
- A full React app that needs per-request server rendering, image handling and
generateMetadata: Next.js builds that in; Astro vs Next.js for SEO compares the trade-offs on client projects. - React Router v7 (framework mode) runs on Vite and supports route-level
prerenderlists and server rendering without leaving React Router.
Why do Vite SPAs get "Soft 404" errors in Search Console?
Because static hosts serve index.html with HTTP 200 OK for every unknown path so client-side routing can work. When Googlebot crawls /services/deleted-page, the server answers 200, Chromium renders your "Page not found" component, and Google flags a soft 404 (or worse, indexes the error view).
Google Search Central gives two fixes when the server itself cannot return HTTP 404 on unknown routes:
- Add
<meta name="robots" content="noindex">on the not-found route. In React 19, yourNotFoundcomponent can render<meta name="robots" content="noindex" />directly, and React hoists it to<head>. - Redirect in JavaScript to a URL where the server really responds with HTTP
404, such as/404.htmlconfigured on your static host to send status404.
Returning a real 404 status from the server or edge when prerendering or server-rendering is cleaner than both, because Google skips the render queue on non-200 responses.
Which router links can Google crawl?
Standard <a href="/path"> anchors using the browser History API. Google's guide is explicit on both halves:
- Links: "Google can only discover your links if they are
<a>HTML elements with anhrefattribute." A<button onClick={() => navigate('/pricing')}>or a<div onClick>is invisible to link discovery. React Router's<Link to="/pricing">renders a real<a href="/pricing">, so use it instead of click handlers. - URLs: "don't use fragments to load different page content."
HashRouterURLs like/#/serviceskeep everything after#out of reliable crawling; useBrowserRouter(the History API) and configure your host to rewrite valid app routes instead.
How do you check what Google actually saw?
View Source in your browser shows the raw HTML before JavaScript ran. DevTools Elements shows what your own browser rendered, not what Googlebot rendered. To see Google's rendered HTML, open Search Console's URL Inspection tool, inspect a live URL, and check the rendered HTML and any console or blocked-resource errors. If robots.txt blocks a JS chunk or an API endpoint your page fetches copy from, Chromium renders an incomplete page and indexes that instead.
Running SEO on React and Vite client sites
Getting metadata, prerendering and clean status codes into a React repo gets the pages indexed. A month after launch, the client asks a different question: which searches are we showing up for, what should we change next, and did last month's edits move anything?
When the pages live in a repo, QueryScope runs that loop for web agencies inside Claude Code, Cursor, Cline or Windsurf: a plan per client site read from its repo, one change at a time made by your coding agent, a git commit before any visitor-facing copy ships, and a dated reading of each change from the day Google recrawls the page.
Sources
- Google Search Central, Understand the JavaScript SEO basics (Crawling, Rendering and Indexing phases; app shell model;
200responses queued for headless Chromium rendering; server-side or pre-rendering recommendation; canonical URL rule between HTML and JavaScript; the two soft-404 strategies for client-side SPAs;<a href>link discovery and History API over#fragments). - React docs (v19.3),
<title>(hoisting to<head>; the single-<title>pitfall; single-string children requirement),<meta>,<link>andprerender. - Vite docs, Server-Side Rendering (SSR) and Pre-Rendering / SSG (SSR entry structure and pre-rendering known routes to static HTML).
Try it
Put an SEO agent in your editor.
Ask your coding agent what to work on. QueryScope reads your real Search Console, holds the searches you decided to win, and hands back one move at a time with the proof it worked. From $49/month, everything included. 1, 3 or 10 sites.