Dev Helpers
← Back

Catch-all path list

Place this file at components/CatchAllPathList.tsx in an App Router project. Mount inside a route with the named dynamic segments shown in useParams.

Open this example in the interactive library

Source code

"use client";

// components/CatchAllPathList.tsx

import { useParams } from "next/navigation";

export default function CatchAllPathList() {
  const { parts } = useParams<{ parts: string[] }>();
  return (
    <ol>
      {(parts ?? []).map((s, i) => (
        <li key={i}>{s}</li>
      ))}
    </ol>
  );
}