How can I optimize build times for a large Next.js app on Vercel?

I have a Next.js 14 app deployed on Vercel with ~100 pages and heavy dynamic imports. Builds are taking 8–10 minutes, and I’m trying to speed this up. I’m using ISR, building API routes, and optimizing images. What are the best strategies to reduce build times—such as leveraging ISR more effectively, tuning caching, splitting large bundles, or configuring Vercel-specific build settings?

There are several ways of optimizing but it mainly depends on why your build is slow:

  • Does each page take long to build?
  • Do you have lots of pages?

Each page takes a long time to build

Check if you have:

  • Slow requests
  • Waterfalls of requests that doesn’t depend on previous requests to be executed
  • Waterfalls between layout → page

And optimize accordingly:

  • Slow requests → Optimize backend or use unstable_cache to leverage Vercel data cache
  • Waterfalls → Promise.all
  • Waterfalls between layouts / page → Restructure layouts to be more consistent with app usage

Lots of pages

Are you building just what you need? If your pages take a long time to generate and you optimize you will exponentially reduce your time to build. If you are building everything you can consider just building the important paths, like the home page and links referenced in it and then leverage a cache warmer that just do fire and forget requests to the rest of the path to warm the cache.

Usually you want:

  • Build the essential
  • Warm the needed
  • Defer the rest to be generated on user request
2 Likes

This might also be helpful:

1 Like