Closed ryscheng closed 10 months ago
Hey @ryscheng, The error you're encountering appears to be related to a specific issue with static site generation (SSG) in Next.js. The error message mentions the use of searchParams.toJSON on a page with dynamic = "error", which seems to be causing the issue with static rendering.
Here are a few steps you can take to troubleshoot and potentially resolve the issue:
Hope it helps! Let's Connect!!
Thanks for getting back to me. Sending steps to reproduce:
npx create-plasmic-app
. Make sure to select the app router, not the pages router.output: 'export',
to your next.config.js.This is the error you get
StaticGenBailoutError: Page with `dynamic = "error"` couldn't be rendered statically because it used `searchParams.toJSON`.
at staticGenerationBailout (/home/ryscheng/Downloads/my-app/.next/server/chunks/587.js:156:15)
at Object.get (/home/ryscheng/Downloads/my-app/.next/server/chunks/208.js:12946:70)
at stringify (<anonymous>)
at pb (/home/ryscheng/Downloads/my-app/.next/server/chunks/208.js:14337:9)
at mb (/home/ryscheng/Downloads/my-app/.next/server/chunks/208.js:14236:29)
at Timeout._onTimeout (/home/ryscheng/Downloads/my-app/.next/server/chunks/208.js:14061:16)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7) {
code: 'NEXT_STATIC_GEN_BAILOUT'
}
I think this is a bug with Plasmic, because I am able to reproduce this with brand new projects with no code changes.
Hey @ryscheng, nice seeing you!
The reason this is happening is because the generated catchall page uses searchParams
, a dynamic function which only works with dynamic rendering. To use it with output: 'static'
, you'll need to remove references to searchParams
. If your Plasmic page relies on search params, you would need to create a new client component and call useSearchParams
to get search params on the client, then pass it into PlasmicComponent
. Note SSR would not be possible in this case.
Ah of course! Thanks for the response @jaslong
Steps to reproduce:
Here's the error you get: