Dev Helpers

Next.js / Client route parameters

Client slug display

Dev Helpers · August 5, 2025

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

Related articles

Free bin volume

Free storage volume depends on consistent dimensions and units. Derive capacity and usage in the same unit before formatting a human-readable summary.

Draft preview indexing

Draft pages need deliberate indexing metadata. An indexing directive controls crawler intent, while access to unpublished material needs a separate permission check.

Party size allocation

Allocating a party into groups is an integer problem. The remainder determines whether another group is needed and how full it will be.