Dev Helpers
← Back

Nested section title

Place this file at components/NestedSectionTitle.tsx in an App Router project.

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>;
}