Dev Helpers
← Back

Regional currency specimen

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

Open this example in the interactive library

Source code

// app/regions/[code]/page.tsx

import { notFound } from "next/navigation";

export default async function RegionalCurrencySpecimen({
  params,
}: {
  params: Promise<{ code: string }>;
}) {
  const places = [
    {
      code: "ca",
      lang: "en-CA",
      currency: "CAD",
      zones: ["America/Toronto", "America/Vancouver"],
    },
    { code: "jp", lang: "ja-JP", currency: "JPY", zones: ["Asia/Tokyo"] },
  ];
  const { code } = await params;
  const place = places.find((p) => p.code === code);
  if (!place) notFound();
  return (
    <data value="1234.5">
      {new Intl.NumberFormat(place.lang, {
        style: "currency",
        currency: place.currency,
      }).format(1234.5)}
    </data>
  );
}