Skip to content
AE DIGITAL
Technical SEOBy 7 min read

JavaScript SEO: getting React and Next.js sites indexed without surprises

How Google reads a React or Next.js site, which rendering mode to pick between SSR, SSG and CSR, and the checks to run before an indexing issue costs you traffic.

Article cover: the word “Index” next to a glowing icon on a violet space background

How Google processes JavaScript

Google indexes sites built with React, Vue or Next.js. What differs from a classic HTML site is the route a page takes. According to Google Search Central, a JavaScript page goes through three phases: crawling, rendering and indexing. Googlebot fetches the HTML, checks robots.txt and queues the page for rendering. Rendering runs in headless Chromium, and the resulting HTML is used for indexing and for discovering new links.

The queue is the tricky part. Google says a page may sit there for a few seconds, but it can take longer. Until then, Google only has the initial HTML. If that HTML is an empty <div id="root"></div>, everything else depends on a later step you don't control.

Many teams also forget that not every crawler runs JavaScript. Google itself gives this as a reason to prefer server-side rendering. Social previews, SEO tools and many bots that feed AI answers read only the HTML.

SSR, SSG and CSR: what each means for indexing

Your rendering choice decides what is in the HTML the server sends back. On a JavaScript site this is the most important SEO decision you make, more than any plugin.

Static generation (SSG)

Pages are built at build time and served as ready HTML. In Next.js this is the default for pages that don't read per-request data (cookies, headers, search params). For service pages, articles and landing pages it's the simplest option: fast, stable, with all text visible to any bot.

Server-side rendering (SSR)

HTML is generated on every request. You need it when content depends on frequently changing data or on the request itself, such as filtered results or live availability. For Google the outcome matches SSG: the HTML arrives complete. The cost lands on the server and on response times, which you need to watch.

Client-side rendering (CSR)

The browser gets a near-empty page and builds it with JavaScript. That's the model of a single page app made with Vite or the old Create React App. It's fine for logged-in areas and dashboards; for pages that need to rank it's the most fragile choice. If the bundle throws, an API responds slowly or a resource is blocked by robots.txt, Google may index an empty or partial page.

For a company site with a few dozen pages, we would use SSG everywhere and SSR only where the data requires it. Headless ecommerce, with large catalogs and changing prices, has its own issues, covered in SEO and tracking for headless commerce.

Metadata, canonical and hreflang generated by the framework

Title, meta description, canonical, hreflang and meta robots belong in the initial HTML and must match the content. In Next.js (App Router) you set them with the metadata object or the generateMetadata function in page.tsx and layout.tsx. The alternates field outputs <link rel="canonical"> and hreflang links; metadataBase, set in the root layout, turns relative paths into absolute URLs.

Common metadata mistakes

  • Canonical inherited from the layout: if the layout sets a fixed canonical to the homepage and the page doesn't override it, every page declares the homepage as the main version.
  • Non-reciprocal hreflang: each language version must list the others and itself, plus an x-default. We cover this in the guide to hreflang and canonical for multilingual sites.
  • Two canonicals on one page: one in the HTML and one added by a script. Google asks for a single canonical and, if you set it with JavaScript, for the same value as in the HTML.

You can't remove noindex with JavaScript

Google warns that if it finds noindex in the initial HTML, it may skip rendering. A script that removes the tag after load has no effect. This happens when a staging setup copied to production brings its noindex along and the team tries to fix it client-side.

Links and client-side navigation

Google discovers pages through links, and only treats <a> elements with an href containing a real URL as reliable. A <div onClick> or a <button> calling router.push() works for users but leaves nothing for the crawler. Avoid href values starting with javascript: as well.

In Next.js the Link component outputs a normal <a href>, so the problem nearly always comes from custom components: clickable cards, dropdown menus, filters. For client-side routing Google recommends the History API and advises against fragment URLs such as /#/services, which aren't resolved reliably.

Content loaded after user interaction

Google Search doesn't interact with your page: it doesn't click, scroll or fill in fields. Anything that appears only after clicking a tab, a "show more" button or an infinite scroll may never be indexed.

  • Tabs and accordions: fine if the text is already in the DOM and only hidden with CSS. Not fine if it's fetched from the API on click.
  • Infinite scroll: Google asks you to split content into pages with their own stable URLs, linked sequentially with normal links.
  • Lazy loading: images and blocks should load when they enter the viewport, without depending on a user action.

Testing tools: URL Inspection and rendered HTML

Source versus rendered DOM

The first check takes thirty seconds. Open the page, press Ctrl+U (view source) and search for a sentence from the main content. If it's there, the server is sending it. Then open developer tools and compare with the DOM. Whatever you only see in the DOM depends on Google's rendering.

Search Console

In Search Console's URL Inspection, the Test live URL button shows the page as Google's tool sees it: HTML, a screenshot, JavaScript console messages and resources it couldn't load. The screenshot is only available in the live test. If a page sits in "Crawled – currently not indexed", check that the rendered HTML really contains the text before looking for other causes; the full diagnosis is in our guide on crawled but not indexed pages.

Keep performance in view too: a heavy JavaScript bundle hurts LCP and INP, and Core Web Vitals and crawlability are best reviewed together, as explained in our article on technical SEO and Core Web Vitals.

SEO checklist for a Next.js site

  1. Public pages are static or server-rendered, and the main text shows up in the page source (Ctrl+U).
  2. Every page has its own title and description, set with metadata or generateMetadata.
  3. There is exactly one canonical, absolute, pointing to the page itself unless a duplicate is intended.
  4. Hreflang annotations are reciprocal and include x-default.
  5. No leftover noindex from staging; missing pages return a real 404 via notFound(), not an empty page with status 200.
  6. All navigation uses <a href> or the Link component.
  7. No indexable content depends on clicks or scrolling.
  8. JavaScript and CSS are not blocked in robots.txt.
  9. The Search Console live test shows full text, links and screenshot on template pages (home, service, article).

When a site is already live and traffic doesn't come, we usually start from these nine points before touching the content. If you want us to check your React or Next.js project, get in touch with the URL and the framework you use.

Frequently asked questions

Can Google index a React site that renders only on the client?

Yes, Google runs JavaScript with an up-to-date Chromium. Rendering happens after crawling, in a queue, and any script error or blocked resource can leave the page empty. Other crawlers, including many AI service bots, do not run JavaScript at all.

Is SSR or SSG better for SEO?

For Google they are equivalent: both deliver complete HTML. The choice depends on your data. Pages that rarely change (services, articles) work well as static pages; pages with per-request or fast-changing data need SSR or periodic regeneration.

Does metadata from generateMetadata in Next.js reach Google?

Yes. If the page is prerendered, metadata is in the initial HTML. If generateMetadata depends on request data, Next.js may stream it into the body; the docs state Googlebot reads it correctly, while for bots that do not run JavaScript it stays in the head.

How do I check what Google sees on my page?

In Search Console, open URL Inspection and click Test live URL: you get the HTML, a screenshot, JavaScript console messages and resources that failed to load. Compare it with the page source (Ctrl+U) to see what comes from the server and what only from the browser.

Sources

  1. Understand JavaScript SEO basics — Google Search Central
  2. Make your links crawlable — Google Search Central
  3. Fix lazy-loaded content — Google Search Central
  4. URL Inspection tool — Google Search Console Help
  5. Rendering on the Web — web.dev
  6. generateMetadata — Next.js

Related articles

Tell us what isn't working.

We reply within one business day with a first opinion and, if it makes sense, a quote.

Write to us