reactseo.com All posts
Structured Data Mar 28, 2026 6 min Priya Anand

Type-safe JSON-LD with TanStack Router loaders

Structured data is the cheapest SEO win you'll ever ship — if you actually keep it in sync with your content.

Co-locating JSON-LD with the route loader makes drift basically impossible.

#Why generate it at the route level

Routes already know their data shape. Putting schema.org generation next to the loader means the markup is always derived from the same source as the page itself.

#The pattern

tsx~/the-pattern.tsx
head: ({ loaderData }) => ({
scripts: [{
type: "application/ld+json",
children: JSON.stringify({
"@context": "https://schema.org",
"@type": "Article",
headline: loaderData.title,
datePublished: loaderData.date,
}),
}],
}),

#Validate continuously

Run the Rich Results Test in CI on a sample of routes. A broken JSON-LD payload silently disables rich results — you won't notice until traffic drops.

// next up

Migrating from Next.js Pages Router without losing rankings

The redirect map, canonical strategy, and crawl-budget tactics that kept our traffic flat through cutover.

Read article