Next.js JSON-LD served via next/script stays hidden from most web crawlers
A developer discovered that using Next.js's next/script component to inject JSON-LD structured data causes it to be rendered client-side after hydration, making it invisible to crawlers that parse only raw server-sent HTML. The issue went undetected because browser DevTools and popular schema validators use a live or JavaScript-rendered DOM, masking the problem from standard debugging workflows. Tools like Bing, social card scrapers, and many LLM crawlers do not execute JavaScript, meaning structured data injected this way never reaches them. The fix is straightforward: replace next/script with a plain HTML script tag, which React renders directly into the server HTML on the first pass, regardless of whether the component is a server or client component. Developers can verify the fix by running a curl command against their production build and checking for the presence of application/ld+json in the raw HTML response.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in