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