Open this example in the interactive library
Source code
"use client";
// components/NestedSectionTitle.tsx
import { useSelectedLayoutSegment } from "next/navigation";
export default function NestedSectionTitle() {
const segment = useSelectedLayoutSegment();
return <h2>{(segment ?? "Overview").replaceAll("-", " ")}</h2>;
}
