Part 16 / Topic 4 of 6
Calling it from a Server Component, cached with Part 10's directive
// harness/app/mandi/guestbook/lib/cached-entries.ts
export async function getCachedGuestbook(): Promise<GuestbookEntry[]> {
"use cache";
cacheTag("mandi-guestbook");
cacheLife("minutes");
return listEntries();
}
"use cache" requires an async function — a rule of the directive itself, not a reflection of anything about better-sqlite3 (the listEntries() call inside it is still fully synchronous). GuestbookPage (a Server Component) calls this cached wrapper directly; next build's own route table shows the result baked fully static, cache lifetime included:
├ ○ /mandi/guestbook 1m 1h
The page's <form action={postGuestbookEntry}> is a plain Server Component rendering its own form, calling an imported file-level "use server" action with no Client Component and no hook anywhere — Part 12 section 1's "going deeper" box named this exact shape (the alternative to every Client-Component-wrapped form Part 12 actually built) and never gave it real, kept content; this page is where it finally gets used for real, not just a scratch exercise.
Done here? The practice set for Part 16 — including the solutions — is on the part page.