Fix heading-order in Next.js
Next.js App Router documentation and marketing sites frequently fail heading-order when a shared footer renders <h4> column titles on short pages that only contain an <h1>, or when MDX authors jump straight from page <h1> to ### subheadings. Rendering layout headings at <h2> and linting MDX heading hierarchy guarantees clean outlines on every route.
Before and after
// app/components/SiteFooter.tsx (Broken: <h4> inside global layout skips h2 & h3)
export function SiteFooter() {
return (
<footer>
<section>
<h4 className="text-sm font-semibold">Resources</h4>
<ul>
<li><a href="/rules">WCAG 2.2 Rules Catalog</a></li>
</ul>
</section>
</footer>
);
}// app/components/SiteFooter.tsx (Fixed: semantic <h2> with compact visual typography)
export function SiteFooter() {
return (
<footer>
<section>
<h2 className="text-sm font-semibold text-slate-900">Resources</h2>
<ul>
<li><a href="/rules">WCAG 2.2 Rules Catalog</a></li>
</ul>
</section>
</footer>
);
}Fixed vs. broken example
Decouple visual typography from semantic heading depth: choose <h1>–<h6> strictly for document outline nesting and apply CSS utility classes for font size.
Playwright + axe-core check
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";
test("Next.js App Router pages & MDX docs pass heading-order", async ({ page }) => {
await page.goto("/rules/color-contrast/tailwind");
const results = await new AxeBuilder({ page })
.withRules(["heading-order"])
.analyze();
expect(results.violations).toEqual([]);
});Template deduplication tip
A footer component in app/layout.tsx using <h4> headers breaks heading-order on every route that lacks an <h2> and <h3>. Switching footer section titles to <h2 className='text-sm font-semibold'> clears the whole app.
What NVDA and VoiceOver announce
Over 67% of screen-reader users navigate long pages primarily by jumping between headings (H / 1–6 keys). Skipping from <h1> straight to <h4> for visual sizing breaks the mental document outline and makes sub-sections appear orphaned.
NVDA (Windows)
"Accessibility Audit Report, heading level 1" -> "Key Template Clusters, heading level 4" (user suspects missed sections 2 & 3)
"Accessibility Audit Report, heading level 1" -> "Key Template Clusters, heading level 2"
VoiceOver (macOS / iOS)
"heading level 1, Accessibility Audit Report" -> "heading level 4, Key Template Clusters"
"heading level 1, Accessibility Audit Report" -> "heading level 2, Key Template Clusters"
Common questions
Should a Next.js App Router layout render an <h1> in app/layout.tsx?
How do I prevent MDX authors from skipping headings in Next.js blogs?
Is skipping headings a WCAG 2.2 Level A or AA failure?
Test a URL for heading-order
Enter any public URL for a free WCAG 2.2 AA check—no account or credit card required.
Shipping Next.js weekly? Block new heading-order regressions in PRs with our baseline-diff GitHub Action PR gate (≤20 URLs/PR).