Dev Helpers
← Back

Slug title formatter

Place this file at app/guide/[slug]/page.tsx in an App Router project.

Open this example in the interactive library

Source code

// 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>
  );
}