Nextjs app - Dynamic route - building time
Unanswered
Gazami crab posted this in #help-forum
Gazami crabOP
Hello I started to build a directory of ecommerce emails. As of today I generate 450+ pages (dynamic page). The thing is, it takes more than 45 minutes to deploy.
Ideally I just need to deploy the new pages added. But it starts from scratch. What are my solutions to decrease the time to build drastically?
Thanks a lot!
Ideally I just need to deploy the new pages added. But it starts from scratch. What are my solutions to decrease the time to build drastically?
Thanks a lot!
27 Replies
@Gazami crab Hello I started to build a directory of ecommerce emails. As of today I generate 450+ pages (dynamic page). The thing is, it takes more than 45 minutes to deploy.
Ideally I just need to deploy the new pages added. But it starts from scratch. What are my solutions to decrease the time to build drastically?
Thanks a lot!
Spectacled bear
Are they dynamic routes or is the page itself dynamic?
Either way, why are the pages being generated at build time? Are you using
generateStaticParams?Gazami crabOP
Yes I'm using generateStaticParams. They are dynamic route (app/[company]/[id])
I don't know why are they generated at build time, I just follow the next guideline. How can I solve that?
I don't know why are they generated at build time, I just follow the next guideline. How can I solve that?
@Gazami crab Yes I'm using generateStaticParams. They are dynamic route (app/[company]/[id])
I don't know why are they generated at build time, I just follow the next guideline. How can I solve that?
Its generating on buildTime because of generateStaticParams.
That basically fetched the id at buildTime and renders the page for it. Any IDs missed in that time will be built at runtime
That basically fetched the id at buildTime and renders the page for it. Any IDs missed in that time will be built at runtime
Gazami crabOP
got it, so from what I understand I should remove generateStaticParams.
But where should I define the different path (like I do in generateStaticParams)?
But where should I define the different path (like I do in generateStaticParams)?
@Gazami crab got it, so from what I understand I should remove generateStaticParams.
But where should I define the different path (like I do in generateStaticParams)?
You dont need to unless you want static generation.
Dynamic routes are used for dynamic pages in the first place. GenerateStaticParams is just to generate a small subset of possibilities so those subsets don't have to built at runtime
Gazami crabOP
Got it perfect! Also what will be the impact in terms of SEO?
I think you need to create a sitemap. As for generated paths i think those can get indexed already.
I'm not 100% sure about the last part
I'm not 100% sure about the last part
Gazami crabOP
got it thanks Let me try!
Gazami crabOP
ok it works well thanks, but now the pages take a ton of time to load
@Gazami crab ok it works well thanks, but now the pages take a ton of time to load
They are now being generated at runtime
Although i think it gets added to the cache so you shouldn't need to wait that long each and everytime
Its a trade off
Gazami crabOP
yes I need to assess what's approach is the best. But thank you so much for your help!
@Clown Dynamic routes are used for dynamic pages in the first place. GenerateStaticParams is just to generate a small subset of possibilities so those subsets don't have to built at runtime
Spectacled bear
Not necessarily, right? You can have static pages being generated for dynamic routes. They are generated on-demand but after that, those pages should be static and cached.
@Gazami crab ok it works well thanks, but now the pages take a ton of time to load
Spectacled bear
Make sure the dynamic route still generates static pages. It should not really affect load times since once one person visits that dynamic route, it should be statically generated and cached, effectively the same thing as
generateStaticParams but not at build time.Spectacled bear
Did you not say dynamic routes are for dynamic pages?
I guess you meant statically generated on-demand with "dynamic" and not dynamically generated on every request.
@Spectacled bear I guess you meant statically generated on-demand with "dynamic" and not dynamically generated on every request.
I said dynamic routes are for dynamic pages but you can generate a subset of them statically on build time
(for the ones generated at runtime ^)
@Clown I said dynamic routes are for dynamic pages but you can generate a subset of them statically on build time
Spectacled bear
What I'm saying is that dynamic routes are not only for dynamic pages. I guess maybe we are using "dynamic pages" differently. I understand that as meaning pages dynamically generated on every single request. The equivalent of
export const dynamic = "force-dynamic" .That's seperate from pages built at build time from generateStaticParams which is also different than pages built at runtime but that are static (not dynamically generated every single request)
My dynamic meant they are built at runtime and cached
Spectacled bear
Ahh okay that's where I misunderstood since next uses "dynamic" in so many different contexts.