Dev Helpers
← Back

Locale-aware welcome page

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

Open this example in the interactive library

Source code

// app/[lang]/page.tsx

import { notFound } from "next/navigation";

export default async function LocaleAwareWelcomePage({
  params,
}: {
  params: Promise<{ lang: string }>;
}) {
  const { lang } = await params;
  if (!["en", "fr"].includes(lang)) notFound();
  return (
    <main lang={lang}>
      <h1>{lang === "fr" ? "Bienvenue" : "Welcome"}</h1>
    </main>
  );
}