Dev Helpers
← Back

Remembered density display

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 RememberedDensityDisplay() {
  const jar = await cookies();
  const compact = jar.get("density")?.value === "compact";
  return (
    <ul style={{ lineHeight: compact ? 1.3 : 2 }}>
      {["Profile", "Billing", "Notifications"].map((v) => (
        <li key={v}>{v}</li>
      ))}
    </ul>
  );
}