Skip to content
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

next build output incorrectly reports route as SSG when is uses searchParams and generateStaticParams #76507

Open
migueloller opened this issue Feb 25, 2025 · 1 comment
Labels
Dynamic Routes Related to dynamic routes. linear: next Confirmed issue that is tracked by the Next.js team.

Comments

@migueloller
Copy link
Contributor

Link to the code that reproduces this issue

https://github.com/migueloller/nextjs-dynamic-route-search-params-ssg-repro

To Reproduce

  1. Build the application (bun run build)
  2. The build output will show the result below:
┌ ○ /                                    5.55 kB         111 kB
├ ○ /_not-found                          982 B           106 kB
└ ● /[param]                             135 B           105 kB
    └ /foo
+ First Load JS shared by all            105 kB
  ├ chunks/4bd1b696-20882bf820444624.js  53 kB
  ├ chunks/517-03da3b76e13269b5.js       50.4 kB
  └ other shared chunks (total)          1.87 kB


○  (Static)  prerendered as static content
●  (SSG)     prerendered as static HTML (uses generateStaticParams)

Current vs. Expected behavior

I expect the output to look like the one below instead:

Route (app)                              Size     First Load JS
┌ ○ /                                    5.55 kB         111 kB
├ ○ /_not-found                          982 B           106 kB
└ ƒ /[param]                             135 B           105 kB
+ First Load JS shared by all            105 kB
  ├ chunks/4bd1b696-20882bf820444624.js  53 kB
  ├ chunks/517-03da3b76e13269b5.js       50.4 kB
  └ other shared chunks (total)          1.87 kB


○  (Static)   prerendered as static content
ƒ  (Dynamic)  server-rendered on demand

This can be recreated by commenting out the generateStaticParams export.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6020
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 23.7.0
  npm: 10.9.2
  Yarn: 1.22.21
  pnpm: N/A
Relevant Packages:
  next: 15.1.7 // Latest available version is detected (15.1.7).
  eslint-config-next: 15.1.7
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.3
Next.js Config:
  output: N/A

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

Not sure

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

next build (local)

Additional context

It seems that the build output marks a page as SSG when it uses generateStaticParams even though it actually generates a dynamic route. This can be confirmed by running next start and loading the page—it will show search params even though it shouldn't if the page is static.

next build should probably fail when a page uses dynamic data, like searchParams and also uses generateStaticParams.

Note, I also used dynamicParams to show that if a non-set para is visited, e.g., /bar that page still renders. This does not happen is the searchParams code is removed.

I was also able to use other dynamic APIs, like await cookies() and the issue was the same.

@samcx samcx added the Dynamic Routes Related to dynamic routes. label Feb 25, 2025
@samcx
Copy link
Member

samcx commented Feb 25, 2025

@migueloller Thank you for submitting an issue!

next build should probably fail when a page uses dynamic data, like searchParams and also uses generateStaticParams.

Yeah, agreed. It seems right now generateStaticParams() takes precedence, but this also breaks dynamicParams = false in next build. The dynamicParams is working only in next dev.

We will be taking a look!

@samcx samcx added the linear: next Confirmed issue that is tracked by the Next.js team. label Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dynamic Routes Related to dynamic routes. linear: next Confirmed issue that is tracked by the Next.js team.
Projects
None yet
Development

No branches or pull requests

2 participants