nextjs - 💡(How to fix) Fix generateStaticParams silently ignored in route handler or opengraph-image.tsx when using `cacheComponents` [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#88043Fetched 2026-04-08 02:05:35
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
subscribed ×2issue_type_added ×1labeled ×1renamed ×1

Error Message

As an aside, this type of date formatting also triggers an error when building static Pages with useCache. The build errors out that this must be in a client component in a Suspense boundary. This is confusing and unexpected when just trying to format a string that isn't relative to the current time.

Code Example

>├ ● /[slug]/opengraph-image
> │ ├ /grove/opengraph-image
> │ ├ /mediated-matter/opengraph-image
> │ ├ /out-here-archery/opengraph-image
> │ └ [+4 more paths]
>

---

>├ ƒ /[slug]/opengraph-image
>

---

format(story.data.publication, "LLLL do, yyyy", { in: utc })

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.1.0: Mon Oct 20 19:33:00 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6020
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 24.10.0
  npm: 11.6.1
  Yarn: 1.22.19
  pnpm: 10.27.0
Relevant Packages:
  next: 16.1.1 // Latest available version is detected (16.1.1).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/lourd/descioli.com/tree/cache-components

To Reproduce

  1. Clone the application, install deps, run build
  2. See that the [slug[/opengraph-image routes are static
├ ● /[slug]/opengraph-image
│ ├ /grove/opengraph-image
│ ├ /mediated-matter/opengraph-image
│ ├ /out-here-archery/opengraph-image
│ └ [+4 more paths]
  1. Comment out either the date formatting, or font fetching. Run the build again.
  2. See that the [slug]/opengraph-image route is dynamic instead of static>
├ ƒ /[slug]/opengraph-image

Current vs. Expected behavior

I have a route handler for generating opengraph images for posts/pages on my blog. What I want to do is adopt cacheComponents and still statically generate the images. Despite using generateStaticParams, the opengraph image route is dynamic, whereas before adopting cacheComponents it was completely static. Before I was using a plain route handler with generateStaticParams. I switched to using the built-in opengraph-image feature, but the issue still remains, the route is dynamic instead of static.

Stepping through and figuring out what's making the route opengraph-image route dynamic:

  • Anything async other than awaiting the params. If I use async methods for reading files from the file system, those opt out of static rendering and make the route dynamic.
  • Any calls to fetch. I'm using fetch to download some font data. There's not really a way around this aside from downloading the fonts ahead of time and reading synchronously from the filesystem.
  • Any code that uses the Date constructor indirectly. I'm using date-fns to format the publication date:
format(story.data.publication, "LLLL do, yyyy", { in: utc })

This snippet alone changes the opengraph-image route from being statically generated to dynamic.

[!NOTE] As an aside, this type of date formatting also triggers an error when building static Pages with useCache. The build errors out that this must be in a client component in a Suspense boundary. This is confusing and unexpected when just trying to format a string that isn't relative to the current time.

These are all really opaque pitfalls. There's no warnings that get logged about the route being switched from static to dynamic or why.

What I would expect is for the route to stay static when explicitly using generateStaticParams.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.1.0: Mon Oct 20 19:33:00 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6020
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 24.10.0
  npm: 11.6.1
  Yarn: 1.22.19
  pnpm: 10.27.0
Relevant Packages:
  next: 16.1.1 // Latest available version is detected (16.1.1).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

cacheComponents

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

No response

extent analysis

TL;DR

To fix the issue, refactor the code to avoid using async methods, fetch calls, and Date constructor indirectly in the opengraph-image route handler.

Guidance

  • Identify and refactor any async methods that are not awaiting params, as these can opt out of static rendering.
  • Consider downloading fonts ahead of time and reading them synchronously from the filesystem to avoid using fetch.
  • Replace the date formatting code that uses the Date constructor indirectly with a static alternative, such as pre-formatting the dates before passing them to the route handler.
  • Review the Next.js documentation for cacheComponents and generateStaticParams to ensure correct usage.

Example

// Pre-format the dates before passing them to the route handler
const formattedDate = format(story.data.publication, "LLLL do, yyyy", { in: utc });
// Use the pre-formatted date in the route handler

Notes

The issue is likely due to the use of async methods, fetch calls, and Date constructor indirectly in the opengraph-image route handler, which can cause the route to be dynamic instead of static. Refactoring the code to avoid these pitfalls should fix the issue.

Recommendation

Apply a workaround by refactoring the code to avoid using async methods, fetch calls, and Date constructor indirectly in the opengraph-image route handler, as this is the most likely cause of the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix generateStaticParams silently ignored in route handler or opengraph-image.tsx when using `cacheComponents` [1 participants]