Dev Helpers

Next.js / Dynamic route pages

Slug title formatter

Dev Helpers · July 3, 2025

Turning a slug into a display title is a fallback for missing editorial metadata. Acronyms and proper names often need an explicit title override.

Worked example

// app/guide/[slug]/page.tsx

export default async function SlugTitleFormatter({
  params,
}: {
  params: Promise<{ slug: string }>;
}) {
  const { slug } = await params;
  return (
    <h1>
      {slug
        .split("-")
        .filter(Boolean)
        .map((s) => s[0].toUpperCase() + s.slice(1))
        .join(" ")}
    </h1>
  );
}

Implementation notes

Repeatedly deriving slugs from changing headlines breaks old links. Store the stable route key separately from the display title.

Try it yourself

Compare a simple hyphenated phrase with a slug containing an acronym.

Open the Next.js example →

Editorial date July 3, 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.