Dev Helpers
← Back

Legacy route redirect

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

import { redirect } from "next/navigation";

export default async function LegacyRouteRedirect({
  params,
}: {
  params: Promise<{ slug: string }>;
}) {
  const { slug } = await params;
  if (slug === "introduction") redirect("/guide/start");
  return (
    <article>
      <h1>{slug}</h1>
      <p>Guide overview</p>
    </article>
  );
}