Dev Helpers
← Back

Active subsection summary

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

Open this example in the interactive library

Source code

"use client";

// components/ActiveSubsectionSummary.tsx

import { useSelectedLayoutSegments } from "next/navigation";

export default function ActiveSubsectionSummary() {
  const segments = useSelectedLayoutSegments().filter((s) => !s.startsWith("("));
  return (
    <p>{segments.length ? segments.join(" / ") : "You are at the section root."}</p>
  );
}