Skip to content

Conversation

@MenKNas
Copy link
Contributor

@MenKNas MenKNas commented Jan 20, 2026

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:

  • Fixed EmptyGenerateStaticParamsError by ensuring generateStaticParams returns at least one result
  • Fixed TypeScript JSX.Element error in CdpPageView.tsx
  • Fixed new Date() errors by adding await draftMode()/await cookies() before client method calls in server components

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@MenKNas MenKNas self-assigned this Jan 20, 2026
@github-actions
Copy link

github-actions bot commented Jan 20, 2026

📦 Package Size and Test Coverage Report

Package Base Size PR Size Δ Change Base Coverage PR Coverage Δ Change
analytics-core 122.52 KB 122.52 KB ✅ 0.00 KB 100.00% 100.00% 0.00%
cli 58.51 KB 58.51 KB ✅ 0.00 KB 69.73% 69.73% 0.00%
core 505.17 KB 505.17 KB ✅ 0.00 KB 91.23% 91.23% 0.00%
create-content-sdk-app 240.61 KB 242.35 KB 🔺 +1.74 KB 96.22% 96.22% 0.00%
events 76.92 KB 76.92 KB ✅ 0.00 KB 98.40% 98.40% 0.00%
nextjs 423.95 KB 423.95 KB ✅ 0.00 KB 89.69% 89.69% 0.00%
personalize 63.45 KB 63.45 KB ✅ 0.00 KB 99.32% 99.32% 0.00%
react 289.13 KB 289.13 KB ✅ 0.00 KB 93.64% 93.64% 0.00%
search 6.40 KB 6.40 KB ✅ 0.00 KB 98.57% 98.57% 0.00%
Total 🔺 +1.74 KB

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();
Copy link
Contributor

@art-alexeyenko art-alexeyenko Jan 20, 2026

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)

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants