Giter Site home page Giter Site logo

Comments (4)

AnshSinghSonkhia avatar AnshSinghSonkhia commented on May 27, 2024

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:

  1. Check Dynamic Imports - The error seems to be mentioning a dynamic import with a value of "error". Make sure you review your dynamic imports and ensure they are set up correctly. If you are using dynamic imports, double-check that the imported components are SSG-compatible.
  2. Review Code for toJSON Usage: Look through your code to find where searchParams.toJSON is being used. It's possible that this usage might be conflicting with the SSG process. If this usage isn't essential for SSG, consider removing or refactoring it to avoid the error.
  3. Check Dependencies and Compatibility
  4. Check Next.js Documentation: The error message references a specific URL for more information: https://nextjs.org/docs/messages/prerender-error

Hope it helps!
Let's Connect!!

from plasmic.

ryscheng avatar ryscheng commented on May 27, 2024

Thanks for getting back to me. Sending steps to reproduce:

  1. Create a brand new Plasmic project. Publish it
  2. Create a brand new Next.js application via npx create-plasmic-app. Make sure to select the app router, not the pages router.
  3. Add 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.

from plasmic.

jaslong avatar jaslong commented on May 27, 2024

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.

from plasmic.

ryscheng avatar ryscheng commented on May 27, 2024

Ah of course! Thanks for the response @jaslong

from plasmic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.