A nested layout can supply section context once for all of its children. Keep the page-specific heading under that shared context.
Worked example
"use client";
// components/NestedSectionTitle.tsx
import { useSelectedLayoutSegment } from "next/navigation";
export default function NestedSectionTitle() {
const segment = useSelectedLayoutSegment();
return <h2>{(segment ?? "Overview").replaceAll("-", " ")}</h2>;
}Implementation notes
Layouts persist across eligible navigations. Avoid assuming the parent component remounts every time a child route changes.
Try it yourself
Navigate between sibling pages and inspect the heading outline.
Open the Next.js example →Editorial date March 20, 2026 · Published December 6, 2026