Next.js Discord

Discord Forum

Is there any way to disable static prerendering in next 13?

Unanswered
Common Crane posted this in #help-forum
Open in Discord
Common CraneOP
I get all my content from a CMS, which is not available at build time. Is there any way to disable it?

Or is there even another, better solution for such a problem?

4 Replies

@Common Crane I get all my content from a CMS, which is not available at build time. Is there any way to disable it? Or is there even another, better solution for such a problem?
you can disable the pre-rendering of a specific component with ssr: false: https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading#skipping-ssr but keep in mind this basically will render an empty page so it won't be the best for SEO
for dynamic routes you can make use of dynamicParams (which is true by default) so the paths you don't return from generateStaticParams are gonna be generated on demand (not during the build)
@Rafael Almeida you can disable the pre-rendering of a specific component with `ssr: false`: <https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading#skipping-ssr> but keep in mind this basically will render an empty page so it won't be the best for SEO
Common CraneOP
Thanks for the answer! For one thing, I don't want to disable SSR completely, just at build time. I have for now fixed my build using export const dynamic = 'force-dynamic' in the root layout.tsx, but I am not sure if this is the intended way.

Also, I am unsure about generateStaticParams - should I return an empty array? All my routes are dynamic and should only be generated on-demand (though, they should be cached).
Just remove generateStaticParams entirely? If you're not genererating anything, no need to include it.