Open this example in the interactive library
Source code
// app/print/page.tsx
export default async function CutListDownloadRoute({
searchParams,
}: {
searchParams: Promise<Record<string, string | string[] | undefined>>;
}) {
const q = await searchParams;
const w = Math.max(1, Number(q.w) || 210),
h = Math.max(1, Number(q.h) || 297);
return (
<a
download="cut-list.csv"
href={"data:text/csv," + encodeURIComponent("width_mm,height_mm\n" + w + "," + h)}
>
Save {w} × {h} mm cut list
</a>
);
}
