You turn on Cache Components, add 'use cache' to a data function, and the build fails:
Error: Route "/broken": `cookies()` can't be read inside `"use cache"`. Read it outside the cached function and pass what you need as an argument. Learn more: https://nextjs.org/docs/messages/next-request-in-use-cache at h (lib/server-client.ts:6:29) at i (app/broken/page.tsx:7:24)
Enter fullscreen mode
Exit fullscreen mode
The confusing part is that your cached function might never call cookies() itself. In this example, the call is inside a helper that creates a "server client", the kind of cookie-aware factory that many auth and database SDKs ship for the App Router.…