My build times on Vercel increased 6x when I added generateStaticParams...
Unanswered
Nile Crocodile posted this in #help-forum
Nile CrocodileOP
Some background on this, I was and still am seeing a high numbers on Fast Origin Transfer in my Vercel dashboard. I reached out on Twitter to Lee Robinson about it and asked if adding
I have roughly just over 400 articles on this website and originally my website was building in roughly 2-3 minutes generating 18 static pages (which imo is still a long time). After adding
Any ideas on what to look for in order to reduce these build times? I am using next-sanity (https://github.com/sanity-io/next-sanity/tree/main) to create these fetch calls
generateStaticParams could help reduce this. The answer was yes it could help. So I added generateStaticParams for my app/(website)/[slug]/page.tsx file which loads data from Sanity CMS, for generateStaticParams, generateMetadata, and the page itself. The generateMetadata and page share the same function so I think they should be deduped from what I read, but not entirely sure.I have roughly just over 400 articles on this website and originally my website was building in roughly 2-3 minutes generating 18 static pages (which imo is still a long time). After adding
generateStaticParams, my build times have gone up to 11m 28s, 12m, and 13m 46s. I have followed pretty much all the Next/Sanity examples and create the same sort of calls (I think). However, hearing some folks saying they have 80 "heavy" pages build in 25 seconds on Vercel makes me question it.Any ideas on what to look for in order to reduce these build times? I am using next-sanity (https://github.com/sanity-io/next-sanity/tree/main) to create these fetch calls
export async function sanityFetch<QueryResponse>({
query,
params = {},
tags,
}: {
query: string
params?: QueryParams
tags: string[]
}): Promise<QueryResponse> {
return client.fetch(query, params, {
next: {
tags,
},
})
}export function getPostBySlug(slug: string) {
return sanityFetch<PostPayload | null>({
query: postsBySlugQuery,
params: { slug },
tags: [`post:${slug}`],
})
}