Static generation for unknown path
Answered
Large oak-apple gall posted this in #help-forum
Large oak-apple gallOP
My app has some pages that I hardcoded and some that user might add later using top level
Might be challenging to know which path name user will assign to include it into
Is it possible?
Making it dynamic on first request and static on subsequent requests is acceptable, as long as timed and manual revalidation still works for them
./[path]/page
.Might be challenging to know which path name user will assign to include it into
generateStaticParams
, but I still want to make this page static.Is it possible?
Making it dynamic on first request and static on subsequent requests is acceptable, as long as timed and manual revalidation still works for them
Answered by B33fb0n3
yes, you can do that: first dynamically rendered and later statically rendered. It's called [ISR](https://nextjs.org/docs/canary/app/building-your-application/data-fetching/incremental-static-regeneration).
With that you can build many pages (that you know) during build time and the ones that you don't know will be statically generated when someone access them. While accessing, they will be created and saves (cached) for the next person. The next person then gets the generated html instantly
With that you can build many pages (that you know) during build time and the ones that you don't know will be statically generated when someone access them. While accessing, they will be created and saves (cached) for the next person. The next person then gets the generated html instantly
7 Replies
yes, you can do that: first dynamically rendered and later statically rendered. It's called [ISR](https://nextjs.org/docs/canary/app/building-your-application/data-fetching/incremental-static-regeneration).
With that you can build many pages (that you know) during build time and the ones that you don't know will be statically generated when someone access them. While accessing, they will be created and saves (cached) for the next person. The next person then gets the generated html instantly
With that you can build many pages (that you know) during build time and the ones that you don't know will be statically generated when someone access them. While accessing, they will be created and saves (cached) for the next person. The next person then gets the generated html instantly
Answer
Large oak-apple gallOP
What is required for that to work like this? Just
export const revalidate
?Large oak-apple gallOP
But this whole issue comes from not knowing data to use in function. If I knew, I would simply generate pages at build time like usually
you can build many pages (that you know) during build time and the ones that you don't know will be statically generated when someone access them. While accessing, they will be created and saves (cached) for the next person. The next person then gets the generated html instantly
Large oak-apple gallOP
I see, thanks
sure thing