Dev Helpers
← Back

Locale preserving contact link

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 Link from "next/link";

export default async function LocalePreservingContactLink({
  params,
}: {
  params: Promise<{ lang: string }>;
}) {
  const { lang } = await params;
  return (
    <Link href={"/" + encodeURIComponent(lang) + "/contact"}>
      {lang === "fr" ? "Nous joindre" : "Contact us"}
    </Link>
  );
}