Dev Helpers
← Back

Preferred unit label

Place this file at app/preferences/page.tsx in an App Router project.

Open this example in the interactive library

Source code

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