Next.js fix

Before and after

Broken — before
// 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>
  );
}
Fixed — after
// 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>
  );
}
Live preview

Fixed vs. broken example

Passes landmark-one-main
Accessibility tree: Landmarks list: banner (<header>), main (<main id="main-content">)

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>.

Automated test

Playwright + axe-core check

tests/a11y-landmark-one-main.spec.ts
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.

Screen readers

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)

Broken

Pressing D (next landmark) announces: "no next landmark"


Fixed

Pressing D jumps straight past navigation and announces: "main landmark"

VoiceOver (macOS / iOS)

Broken

Landmarks rotor shows no Main region; user must step through every header link.


Fixed

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?
Use Next.js Route Groups—keep <html><body> in the root app/layout.tsx and render <main> inside each route group's layout ((marketing)/layout.tsx, (app)/layout.tsx, (auth)/layout.tsx) so every route still has exactly one <main>.
Should <header>, <nav>, and <footer> sit outside <main> in Next.js?
Yes—global site banner (<header>), primary navigation (<nav>), and contentinfo (<footer>) belong as siblings of <main>, not nested inside it.
Does <main> also need role='main' in modern HTML5/Next.js?
No—the native <main> element implicitly exposes the main ARIA landmark across all modern browsers and assistive technologies without redundant role='main'.