A client component can read route parameters to display the current slug. Validate whether the matched segment is a string or an array.
Worked example
"use client";
// components/ClientSlugDisplay.tsx
import { useParams } from "next/navigation";
export default function ClientSlugDisplay() {
const { slug } = useParams<{ slug: string }>();
return <code>{slug}</code>;
}Implementation notes
Decode and format segment values only once. A string that resembles a path may be a single encoded segment rather than a list of segments.
Try it yourself
Try a single segment and a catch-all route.
Open the Next.js example →Editorial date August 5, 2025 · Published December 6, 2026