Next.js Discord

Discord Forum

Generate Dynamic routes on request or on build time?

Unanswered
Salman posted this in #help-forum
Open in Discord
Let's say I have a 10000 products in my site. Now I want to create dynamic route of them using generateStaticParam function. Is this decision good or bad?

20 Replies

American Chinchilla
How frequently are you updating those products?
The pages will be generated statically, so if you update a description or price you'd need to rebuild the site
You could use revalidate to update every so often instead of rebuilding
However you're not guaranteed to see changes immediately that way
Thanks a lot for you answer.

We aren't going to update these products that much! This is for a mockup site. We will get the mockup from a backend.

Seeing Realtime change might help when others are uploading the product to see whether they have the positions and sizes right.
But I think customers experience and SEO is more important right?
I am in a good dilema it will be actually quite important for the product team because when we ofload the task to non tech they aren't going to locally run the application and rebuild to see updates
If it's pretty minimal, I'd go for dynamic routes w/maybe a short-term cache
If it's pretty computation heavy you might want to consider a longer term cache
Hmm. Good point. Thanks, I will look into these further.
I have another idea. I might try a sepreate frontend for the product team. There they see changes as soon as done but the client side frontend these pages are statically rendered.
Madeiran sardinella
Why don't you revalidate the product path when you update that product?
@Madeiran sardinella Why don't you revalidate the product path when you update that product?
American Chinchilla
This is a great suggestion--is the backend for product management in Next @Salman?
I forget revalidatePath exists sometimes πŸ˜…
Silver Fox
You can use the manual revalidation in combination with a webhook to always have the latest updated data.
https://nextjs.org/docs/pages/building-your-application/data-fetching/incremental-static-regeneration#using-on-demand-revalidation
@Madeiran sardinella @Silver Fox For your suggestions, I will look into it. I am new to Nextjs so not familiar with all the concepts πŸ˜…
American Chinchilla
Thanks @American Chinchilla πŸ™‚ You are very kind. Let me see if I can connect all of these together πŸ˜