#Do I still need `generateStaticParams` with PPR enabled?

1 messages · Page 1 of 1 (latest)

vapid fjord
#

SInce dynamic routes are marked as PPR when it is enabled, do I still need to specify generateStaticParams?

late capeBOT
#

Hi @vapid fjord. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

The generateStaticParams function is used in combination with dynamic route segments to statically generate routes at build time instead of on-demand at request time. It's primarily used for smart retrieval of data, where fetch requests with the same arguments across multiple generateStaticParams, Layouts, and Pages will only be made once, decreasing build times (source (https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes#generating-static-params)).

However, if you have enabled Partial Page Rendering (PPR) in Next.js, it means that your dynamic routes are already marked as PPR. This means that they will be rendered on the server at request time, and then cached for future requests.

In this case, the use of generateStaticParams would depend on your specific use case. If you want to statically generate some routes at build time for performance reasons, you might still want to use generateStaticParams. But if you're fine with all dynamic routes being rendered at request time (with the results cached for future requests), then you might not need to use generateStaticParams.

Remember, generateStaticParams is specifically for generating static pages at build time. If your application doesn't require this, or if PPR meets your needs, then you might not need to use it.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: