validateSEO — Find Missing Tags

Pass an array of routes with their SEO configs. The library checks each page for missing or invalid fields and returns structured issues.

PageFieldMessageSeverity
HomePagecanonicalMissing canonical URL⚠️ warning
HomePagestructured-dataNo structured data (JSON-LD)⚠️ warning
TicketListPageog:imageMissing og:image⚠️ warning
TicketListPagestructured-dataNo structured data (JSON-LD)⚠️ warning
Console output — printValidationReport(issues)Terminal
HomePage:
  ⚠️  [canonical] Missing canonical URL
  ⚠️  [structured-data] No structured data (JSON-LD)

TicketListPage:
  ⚠️  [og:image] Missing og:image
  ⚠️  [structured-data] No structured data (JSON-LD)
build/validate.ts — run at build timeTypeScript
import {
  validateSEO,
  printValidationReport,
} from "react-ssr-seo-toolkit/validation";
import { appRoutes } from "./routes";

const issues = validateSEO(appRoutes);

if (issues.some((i) => i.severity === "error")) {
  console.error(printValidationReport(issues));
  process.exit(1); // fail the build
} else if (issues.length > 0) {
  console.warn(printValidationReport(issues));
}

getSEOScore — 100-Point Audit per Page

Scores a single page's SEO config across 10 checks. Useful for identifying the highest-impact missing fields.

✅ Well-configured page

🟢 TicketDetailPage

95/100
95%
Title+20
Description+15
Canonical URL+10
og:image+15
og:title+5
og:description+5
Twitter Card+10
Structured Data+10
Robots Directives+5
Hreflang−5 (No hreflang alternates)

❌ Sparse page (needs work)

🔴 TicketListPage

45/100
45%
Title+20
Description+15
Canonical URL−10 (Missing canonical URL)
og:image−15 (Missing og:image)
og:title+5
og:description+5
Twitter Card−10 (Missing twitter:card)
Structured Data−10 (No JSON-LD structured data)
Robots Directives−5 (No robots directives)
Hreflang−5 (No hreflang alternates)
Console output — formatSEOScore(result)Terminal
🟢 SEO Score: TicketDetailPage  95/100 (95%)
  ✅ Title
  ✅ Description
  ✅ Canonical URL
  ✅ og:image
  ✅ og:title
  ✅ og:description
  ✅ Twitter Card
  ✅ Structured Data
  ✅ Robots Directives
  ❌ Hreflang (-5) — No hreflang alternates
getSEOScore usageTypeScript
import {
  getSEOScore,
  formatSEOScore,
} from "react-ssr-seo-toolkit/validation";

const result = getSEOScore(seoConfig, "TicketDetailPage");

console.log(formatSEOScore(result));
// 🟢 SEO Score: TicketDetailPage  75/100 (75%)
//   ✅ Title
//   ✅ Description
//   ✅ Canonical URL
//   ✅ og:image
//   ✅ og:title
//   ✅ og:description
//   ✅ Twitter Card
//   ✅ Structured Data
//   ❌ Robots Directives (-5) — No robots directives
//   ❌ Hreflang (-5) — No hreflang alternates

Scoring Breakdown (100 points)

CheckPointsNotes
Title20Full points if ≤60 chars, 10 if longer
Description15Full points if ≤160 chars, 8 if longer
Canonical URL10Must be set
og:image15At least one image in openGraph.images
og:title5openGraph.title or title fallback
og:description5openGraph.description or description fallback
Twitter Card10twitter.card must be set
Structured Data10jsonLd must be set
Robots Directives5robots config must be set
Hreflang5alternates array must have entries

Features Demonstrated

Build-time Validation

Run validateSEO(routes) in your build script. Fail the build on errors, warn on missing optional fields.

Per-page Scoring

getSEOScore(config, name) audits any SEO config against 10 weighted checks and returns a 0–100 score.

Readable Reports

printValidationReport() and formatSEOScore() format results for terminal output with icons and color hints.

Typed Results

SEOValidationIssue[] and SEOScoreResult are fully typed — integrate with your CI pipeline or CMS.

TIP

Add validateSEO(routes) to your pre-build script and pipe the output to your CI logs. Pages with error severity should block deploys — pages with warning severity can be treated as tech debt.