---
title: How do I reduce my build time with Next.js on Vercel?
description: When building a Next.js project with thousands of static pages, you may hit the maximum build time per deployment limit of 45 minutes. Learn some strategies for reducing your build times by reducing computation during each build.
url: /kb/guide/how-do-i-reduce-my-build-time-with-next-js-on-vercel
canonical_url: "https://vercel.com/kb/guide/how-do-i-reduce-my-build-time-with-next-js-on-vercel"
last_updated: 2025-11-10
authors: Lee Robinson, Anthony Shew, Ismael Rumzan
related:
  - /docs/concepts/edge-network/overview
  - /docs/concepts/next.js/incremental-static-regeneration
  - /docs/incremental-static-regeneration
  - /docs/concepts/analytics/web-vitals
  - /docs/concepts/image-optimization
  - /changelog/faster-builds-for-everyone
install_vercel_plugin: npx plugins add vercel/vercel-plugin
---

Next.js provides flexibility to control your build times. This includes prerendering static pages, generating and optimizing images, and updating your content from a headless CMS or database.

This guide will explain a few strategies to decrease your build times.

## Generating Static Pages On-Demand

`getStaticPaths` allows you to control which pages are generated during the build. The paths that you include will be generated at build time, while the rest of the pages can be generated on demand using `fallback`.

You can significantly decrease your build times by **not pre-rendering any pages during the build** and instead generating all static pages on demand. When deployed to Vercel, you can further extend this by pre-rendering pages for _only production builds_.

This keeps your iteration cycles fast for small changes but opts for longer production builds to pre-render your static pages. This flexibility is helpful for sites with hundreds/thousands of static pages.

`export async function getStaticPaths() { // When this is true (in preview environments) don't // prerender any static pages // (faster builds, but slower initial page load) if (process.env.SKIP_BUILD_STATIC_GENERATION) { return { paths: [], fallback: 'blocking', } } // Call an external API endpoint to get posts const res = await fetch('https://.../posts?sort=date-desc&limit=10') const posts = await res.json() // Get the paths we want to prerender based on posts const paths = posts.map((post) => ({ params: { id: post.id }, })) // { fallback: false } means other routes should 404 return { paths, fallback: false } }` [Learn more about getStaticPaths.](https://nextjs.org/docs/basic-features/data-fetching/get-static-paths)

## Updating Content without Redeploying

Incremental Static Regeneration (ISR) allows you to create or update content _without_ redeploying your site. ISR has three main benefits for developers: better performance, improved security, and faster build times.

- **Better Performance:** Static pages can be consistently fast by caching generated pages in every region on Vercel's [Edge Network](https://vercel.com/docs/concepts/edge-network/overview) and persisting files into durable storage.
  
- **Improved Security:** [ISR Render Functions](https://vercel.com/docs/concepts/next.js/incremental-static-regeneration#isr-render-function) are used to generate pages and do 
  
  _not_ have access to the incoming `request`, which prevents [accidental caching](https://vercel.com/docs/incremental-static-regeneration#differences-between-isr-and-cache-control-headers) of user data for increased security.
  
- **Faster Builds:** Pages can defer generation on request or through an API instead of during the build, helping keep build times fast as your application grows.
  

`export default async function handler(req, res) { // Check for secret to confirm this is a valid request if (req.query.secret !== process.env.MY_SECRET_TOKEN) { return res.status(401).json({ message: 'Invalid token' }); } try { await res.revalidate('/post/1'); return res.json({ revalidated: true }); } catch (err) { // If there was an error, Next.js will continue // to show the last successfully generated page return res.status(500).send('Error revalidating'); } }`

[Learn more about Incremental Static Regeneration.](https://vercel.com/docs/concepts/next.js/incremental-static-regeneration)

## Optimizing Images On-Demand

Next.js provides an image component that helps ensure images are loaded as efficiently and fast as possible. When deploying to Vercel, images are automatically optimized on demand, keeping your build times fast as well as improving your page load performance and [Core Web Vitals](https://vercel.com/docs/concepts/analytics/web-vitals#core-web-vitals). This helps your team get great performance by default and keeps builds fast.

Learn more about [Image Optimization](https://vercel.com/docs/concepts/image-optimization) on Vercel.

## Faster Builds on Vercel

Try out [Next.js to Vercel](https://vercel.com/templates/next.js) to experience the fastest builds. We recently made builds [40 seconds faster](https://vercel.com/changelog/faster-builds-for-everyone) on average for large projects.