Dev Helpers

Next.js / Localized route pages

Locale preserving contact link

Dev Helpers · October 10, 2026

Localized links should retain the active language segment. Validate supported locales before inserting user-controlled segments into a destination.

Worked example

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

Implementation notes

Locale prefixes can be optional for a default language. Centralize the routing policy rather than concatenating several competing path patterns.

Try it yourself

Follow the contact link from two different locale roots.

Open the Next.js example →

Editorial date October 10, 2026 · Published December 6, 2026

Related articles

Free bin volume

Free storage volume depends on consistent dimensions and units. Derive capacity and usage in the same unit before formatting a human-readable summary.

Draft preview indexing

Draft pages need deliberate indexing metadata. An indexing directive controls crawler intent, while access to unpublished material needs a separate permission check.

Party size allocation

Allocating a party into groups is an integer problem. The remainder determines whether another group is needed and how full it will be.