Unit preferences might arrive from a cookie, query or default setting. Validate the chosen value before incorporating it into a label.
Worked example
// app/preferences/page.tsx
import { cookies } from "next/headers";
export default async function PreferredUnitLabel() {
const jar = await cookies();
const metric = jar.get("units")?.value !== "imperial";
return <p>Desk width: {metric ? "120 cm" : "47.2 in"}</p>;
}Implementation notes
Caching and personalization must agree. A response that varies by a user's unit preference must not present another reader's chosen label.
Try it yourself
Supply an unsupported unit and inspect the fallback.
Open the Next.js example →Editorial date September 14, 2026 · Published December 6, 2026