Check 08.11 · JavaScript and HTML rendering

Check content loaded via API

List the content loaded by fetch or XHR, check that Googlebot and AI crawlers can reach it, then render on the server whatever matters for SEO.

Priority
Critical
Difficulty
Intermediate
Estimated time
2 to 4 h
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

In short

Many pages load part of their content afterwards, through an API call (fetch or XHR): description, price, reviews, related articles, FAQ, the results of a listing. This check consists of finding these calls, checking that crawlers actually get the content they return, and moving everything that matters for SEO into the initial HTML. Once this check is done, a page's main text, prices and links exist without JavaScript, and the remaining calls only concern personal or real-time elements.

Why it matters

Google executes JavaScript and the API calls it triggers, but under conditions that make many implementations fail:

  • robots.txt: each host has its own. If the API is on api.example.com and that subdomain disallows crawling, Googlebot cannot call the API during rendering. Google points out that you should not block resources whose absence makes the page hard to understand.
  • No state: Googlebot clears cookies, local storage and session storage between page loads. An API that requires a token saved during a previous visit responds with a 401.
  • No interaction: Google does not click or scroll. A call triggered by a tab, a “See more” button or scrolling never happens.
  • Protections: a web application firewall (WAF), anti-bot protection or a rate limit can block or slow down calls coming from Googlebot. Googlebot crawls mainly from IP addresses located in the United States: an API that filters by country returns something else to it.
  • Crawl budget: Google specifies that embedded resources, AJAX calls included, count toward the crawl budget. Ten calls per page multiply the requests.

If the call fails, Google indexes the page without that content, or classifies it as a soft 404 when only an empty template is left.

Generative engine crawlers are even more limited: according to the analysis Vercel published in December 2024, the OpenAI, Anthropic and Perplexity crawlers did not execute JavaScript. For them, content loaded by an API does not exist, and therefore cannot be cited.

What it improves

  • Complete indexing The text, prices and links loaded by an API are seen by Google, and right from the crawl if they are in the initial HTML.
  • Visibility in AI answers Content present in the initial HTML can be read by crawlers that do not execute JavaScript. No practice guarantees a citation.
  • Fewer soft 404s A slow or blocked API no longer empties the page.
  • Crawling Fewer requests per page for crawlers.
  • Performance The main content displays without waiting for an extra round trip, which often benefits LCP (Largest Contentful Paint).

How to check

1. List the calls. Open the page in Chrome, developer tools, Network tab, “Fetch/XHR” filter, then reload. For each request, the “Response” tab shows what it returns. Record them in a table:

URL called Content displayed Useful for SEO In the initial HTML Accessible to Googlebot Decision
/api/products/412 Description and price Yes No Yes Render on the server
api.example.com/reviews?product=412 Customer reviews Yes No No (robots.txt) Render on the server, unblock in the meantime
/api/cart Cart No No Not applicable Leave on the client side
/api/stock/412 Real-time stock Partly Availability, yes Yes Availability in the HTML, quantity on the client side

2. Look for the content in the initial HTML. Take a sentence returned by the API:

curl -s https://example.com/produits/theiere-fonte/ | grep -c "Enameled cast iron, 1.2 liters"

0 means the text only exists after JavaScript has run.

3. Simulate the failure. In the Network tab, right-click the request, choose “Block request URL”, then reload. Whatever disappears is what a crawler loses when the call fails.

4. Test access to the API. Read the robots.txt of each host called (curl -s https://api.example.com/robots.txt), then call the API without a cookie:

curl -s -o /dev/null -w "%{http_code} %{time_total}s\n" "https://api.example.com/reviews?product=412"

Expected result: 200 in roughly under one second, without authentication.

5. Confirm with Google. In Search Console's URL Inspection, “Test live URL”, “View tested page”, then “More info”: the resources that could not be loaded are listed there, with the reason (for example, blocked by robots.txt). Check in the tested page's HTML that the text from the API is present.

6. Read the API logs, filtered on Googlebot: 401, 403, 429 or 5xx codes reveal a problem that manual tests do not show. See analyze server logs (opens in a new tab).

How to implement

Before you start

Classify each piece of content:

Content Where to load it
Main text, title, description, price, availability Initial HTML (server or build)
Links to other pages (related products, related articles, pagination) Initial HTML
Review summary (rating, count, first reviews) Initial HTML; further reviews can come from an API
Personal content (cart, account, personalized recommendations) Client side, no SEO stakes
Real-time data (exact stock, prices of quoted assets, seats left) Starting value in the HTML, updated on the client side

For calls that stay on the client side and display public content:

  • GET requests, without authentication, at a stable URL;
  • the API host allowed in its own robots.txt;
  • verified crawlers not blocked by the WAF or the rate limit;
  • Cache-Control headers so the CDN absorbs the calls;
  • error handling: retry, then fallback content rather than an empty area.

Example robots.txt for an API subdomain where only part is public:

User-agent: *
Allow: /v1/public/
Disallow: /

Warning: allowing the API in robots.txt also lets Google crawl its URLs directly. If the JSON responses must not appear in search results, add the X-Robots-Tag: noindex header to them: it prevents indexing without blocking the call during rendering.

Next.js

Versions Next.js 15 and 16, App Router and Pages Router.

App Router

Load the data in a server component: the content is in the initial HTML and the API is only called by your server.

// app/produits/[slug]/page.tsx
export const revalidate = 3600;

export default async function Page({ params }: { params: Promise<{ slug: string }> }) {
  const { slug } = await params;
  const product = await fetch(`https://api.example.com/products/${slug}`).then((response) => response.json());

  return (
    <article>
      <h1>{product.name}</h1>
      <p>{product.description}</p>
      <StockLive productId={product.id} initialStock={product.stock} />
    </article>
  );
}

StockLive is a client component that receives the starting value and refreshes it. Avoid useEffect(() => { fetch(…) }) for indexable content. In Next.js 16, if you enable Cache Components (cacheComponents: true), the revalidate export is no longer accepted: put the 'use cache' directive and cacheLife('hours') (imported from next/cache) at the start of the function that loads the product.

Pages Router

Load the data in getStaticProps (with revalidate) or getServerSideProps: the page is rendered on the server with the content.

// pages/produits/[slug].tsx
import type { GetStaticPaths, GetStaticProps } from 'next';

export const getStaticPaths: GetStaticPaths = async () => ({ paths: [], fallback: 'blocking' });

export const getStaticProps: GetStaticProps = async ({ params }) => {
  const response = await fetch(`https://api.example.com/products/${params?.slug}`);

  if (!response.ok) {
    return { notFound: true };
  }

  return { props: { product: await response.json() }, revalidate: 3600 };
};

export default function Page({ product }: { product: { name: string; description: string } }) {
  return (
    <article>
      <h1>{product.name}</h1>
      <p>{product.description}</p>
    </article>
  );
}

A fetch placed in a useEffect of the page component stays on the client side.

Nuxt

Versions Nuxt 3.x and 4.

useFetch and useAsyncData called in <script setup> run during server rendering and pass the result on to the client:

const route = useRoute();
const { data: product } = await useFetch(`/api/products/${route.params.slug}`);
const { data: reviews } = await useFetch(`/api/reviews`, { query: { product: route.params.slug, limit: 5 } });

Two options move the call to the client side: server: false, and a $fetch placed in onMounted. Keep them for personal data. With lazy: true, the page does not wait for the response; check that the content is still present in the HTML served.

Laravel

Versions Laravel 11 to 13; Inertia 2 and 3; Livewire 3 and 4.

With Blade, pass the data to the view from the controller rather than loading it in JavaScript. With Inertia, pass it as page props and enable Inertia's server-side rendering; an axios call in a component's mounted stays on the client side. With Livewire, a lazy-loaded component (#[Lazy] attribute, or #[Defer] in Livewire 4) first displays a placeholder and loads its content with a subsequent request: do not use it for content to be indexed.

WordPress

Versions WordPress 6.4 and later (verified up to 7.1).

  • Dynamic blocks: prefer a block rendered in PHP (render_callback or a render.php file) to a block that calls the REST API from the browser.
  • robots.txt: WordPress's virtual file allows /wp-admin/admin-ajax.php, used by many plugins. If you wrote your own robots.txt, keep that line, and do not block /wp-json/ if the site calls it to display content.
  • Review, FAQ or related product plugins: check with curl that their content is in the initial HTML; otherwise, look for an option to display it through a shortcode or a server-rendered block.
  • Security: a plugin that blocks anonymous access to the REST API also breaks rendering for Googlebot if the site uses that API on the front end.

Shopify

Versions Shopify, all plans, Online Store 2.0 themes, November 2026.

The Liquid HTML is rendered by Shopify, but some sections arrive afterwards. In recent themes, product recommendations are loaded in JavaScript, and many review apps inject their widget on the client side. Check with curl that the text is present, look at the store's robots.txt for the URL called, and prefer apps that write their data into metafields displayed by the theme. For links to other products, add to the template a complementary products section rendered in Liquid from a collection or a metafield.

Cloudflare

Versions Cloudflare dashboard, all plans, November 2026.

If the API goes through Cloudflare, check in Security Analytics that Googlebot's requests to the API are neither blocked nor challenged. Anti-bot protection and rate limiting rules also apply to calls made during rendering. Allow verified bots in your custom rules, and cache public responses with a cache rule. See check CDN, WAF and anti-bot protection (opens in a new tab).

AWS

Versions AWS console (Amazon API Gateway, AWS WAF, CloudFront), November 2026.

On API Gateway, throttling returns 429 errors beyond the stage or usage plan quota: size it to absorb Googlebot's renders. An AWS WAF rate-based rule can block the same calls. Put CloudFront in front of the public GET routes with a cache policy to serve responses without hitting the API.

Single-page applications

Without server rendering, all the content comes from API calls. The measures above limit failures with Google, but not with crawlers that do not execute JavaScript. For pages that need to be found, the lasting solution is prerendering at build time or server rendering: see prefer SSR/SSG for critical content (opens in a new tab). When the API responds that the resource does not exist, send crawlers a clear signal: see check SPA HTTP status codes (opens in a new tab).

Common mistakes

  • Blocking the API subdomain in robots.txt: the page renders empty for Googlebot while everything works for visitors.
  • Requiring a token stored in localStorage: Googlebot never has that token.
  • Loading on scroll or on click: the crawler never requests the content.
  • Displaying an empty area on failure: the page becomes a soft 404 with no visible error.
  • API filtered by country: Googlebot, which crawls mostly from the United States, receives different content or an error.
  • JSON responses getting indexed: the API, allowed for crawling, shows up in search results for lack of X-Robots-Tag: noindex.
  • Relying only on Google's test: it can succeed while AI crawlers see nothing. Test with curl as well.

Frequently asked questions

Does Google index content loaded by fetch or AJAX?

Yes, Google generally indexes content loaded by fetch or AJAX, because it executes JavaScript when rendering, provided the call succeeds: the API is allowed in its host's robots.txt, reachable without a cookie or token, not blocked by a firewall, and triggered without a click or scroll. Each call counts toward the crawl budget. Crawlers that do not execute JavaScript, however, do not see this content.

Do the ChatGPT or Perplexity crawlers see content loaded by an API?

According to the analysis Vercel published in December 2024, the OpenAI, Anthropic and Perplexity crawlers did not execute JavaScript: content loaded by an API after the page is displayed escapes them. These companies do not document this point themselves, and their crawlers may change. The only reliable precaution is to put the main text, prices and links in the initial HTML.

Should the API be allowed in robots.txt?

Yes: if the public page calls this API to display its content, Googlebot must be able to reach it during rendering. Since each host has its own robots.txt, check the one on the API subdomain. To keep the JSON responses themselves out of search results, add the X-Robots-Tag: noindex header to them, which prevents indexing without blocking the call.

Which content can be left to load on the client side?

Content with no search stakes can stay on the client side: cart, account, personalized recommendations, counters, live chat, as well as real-time updates to a value already present in the HTML, such as the exact stock. Everything that must be indexed or cited, meaning the main text, the price, availability, the review summary and links to other pages, must be in the initial HTML.

Updated on

Topic checklist (PDF)

And now?

In the “JavaScript and HTML rendering” topic

  1. Inspect the initial HTML
  2. Compare initial HTML and rendered DOM
  3. Test rendering in Search Console
  4. Prefer SSR/SSG for critical content if relevant
  5. Make content accessible without user interaction
  6. Make links available in HTML with href
  7. Avoid links that rely solely on JS events
  8. Check title, description and canonical after rendering
  9. Check rendered structured data
  10. Fix JS and hydration errors
  11. Check content loaded via API
  12. Check dynamic pagination
  13. Check SPA HTTP status codes
  14. Avoid information available only in Canvas
  15. Test which information is accessible without JS