Fix landmark-one-main in Next.js
Next.js App Router projects often miss <main> when app/layout.tsx renders {children} directly inside <body> or accidentally nest two <main> elements when both app/layout.tsx and a child page.tsx render <main>. Placing one <main id='main-content'> in the root shell (or strictly in leaf templates if layouts vary) keeps landmarks crisp on every route.
Before and after
// app/layout.tsx (Broken: no <main> landmark wrapping {children})
import { SiteHeader } from "@/components/SiteHeader";
import { SiteFooter } from "@/components/SiteFooter";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
<SiteHeader />
<div className="page-shell">{children}</div>
<SiteFooter />
</body>
</html>
);
}// app/layout.tsx (Fixed: Skip link + single <main id="main-content"> landmark)
import { SiteHeader } from "@/components/SiteHeader";
import { SiteFooter } from "@/components/SiteFooter";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
<a
href="#main-content"
className="sr-only focus:not-sr-only focus:fixed focus:top-4 focus:left-4 focus:z-50 focus:rounded-md focus:bg-slate-900 focus:px-4 focus:py-2 focus:text-white"
>
Skip to main content
</a>
<SiteHeader />
<main id="main-content" tabIndex={-1} className="page-shell">
{children}
</main>
<SiteFooter />
</body>
</html>
);
}Fixed vs. broken example
Pair your single <main id="main-content" tabindex="-1"> landmark with a visible-on-focus "Skip to main content" link at the top of <body>.
Playwright + axe-core check
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";
test("Next.js App Router routes expose exactly one <main> landmark", async ({ page }) => {
await page.goto("/pricing");
await expect(page.getByRole("main")).toHaveCount(1);
const results = await new AxeBuilder({ page })
.withRules(["landmark-one-main"])
.analyze();
expect(results.violations).toEqual([]);
});Template deduplication tip
Because app/layout.tsx wraps every App Router route, fixing the <main> wrapper in one root layout file resolves landmark-one-main across every static and dynamic route simultaneously.
What NVDA and VoiceOver announce
Keyboard and screen-reader users rely on the <main> landmark (and Skip-to-Content links targeting it) to bypass 30+ repeating header, mega-menu, and announcement links on every page navigation.
NVDA (Windows)
Pressing D (next landmark) announces: "no next landmark"
Pressing D jumps straight past navigation and announces: "main landmark"
VoiceOver (macOS / iOS)
Landmarks rotor shows no Main region; user must step through every header link.
Landmarks rotor lists "main", letting the user jump directly to primary content.
Common questions
What if a Next.js nested route group like (auth)/layout.tsx has a different chrome?
Should <header>, <nav>, and <footer> sit outside <main> in Next.js?
Does <main> also need role='main' in modern HTML5/Next.js?
Test a URL for landmark-one-main
Enter any public URL for a free WCAG 2.2 AA check—no account or credit card required.
Shipping Next.js weekly? Block new landmark-one-main regressions in PRs with our baseline-diff GitHub Action PR gate (≤20 URLs/PR).