-
Notifications
You must be signed in to change notification settings - Fork 20
[create-content-sdk-app] Fixes for cache components related build issues #343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
[create-content-sdk-app] Fixes for cache components related build issues #343
Conversation
📦 Package Size and Test Coverage Report
|
| export default async function Page({ params, searchParams }: PageProps) { | ||
| // Access uncached data first to satisfy Next.js 16 Cache Components requirements | ||
| // This ensures any time-related operations (like new Date()) can be used safely | ||
| await draftMode(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
considering the dynamic nature of Sitecore websites, there could be other instances of functionality that breaks cache components, and forces us to add more workarounds like this.
If it's not possible to limit caching to individual components (and it needs to be active from the root down), let's not have it enabled in empty sample by default and instead provide documentation on how users can do it (and enable it in example starters instead)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good point, and I had similar thoughts myself. I had added these workarounds to support Cache Components being enabled by default, but I agree with the concern raised above, so I removed these workarounds and disabled Cache Components by default. I also added documentation in the README.md file in the app router template that explains the steps for enabling this feature in detail (I wasn't sure where exactly to document this, if you have some other idea feel free to share). So now users can follow the doc if they want to opt-in for this feature.
Description / Motivation
Fix Next.js 16 Cache Components compatibility
Fixes build errors in Next.js App Router template when using Next.js 16 with Cache Components:
EmptyGenerateStaticParamsErrorby ensuringgenerateStaticParamsreturns at least one resultJSX.Elementerror inCdpPageView.tsxnew Date()errors by addingawait draftMode()/await cookies()before client method calls in server componentsTesting Details
Types of changes