Astro parallel prerendering is an experimental flag added in Astro 7.4 that renders static pages on multiple CPU cores during astro build. Turn it on with experimental: { parallelPrerender: true } in astro.config.mjs; by default Astro starts one worker per CPU core minus one, and you can cap that with workers if the build runs out of memory.
Key Takeaways
- Requires Astro 7.4 or newer and is opt-in through
experimental.parallelPrerender.- Default worker count is all available cores but one; set
workersto use fewer.- It speeds up the page-generation phase only, so measure with
astro build --timingsfirst.- Each worker uses its own memory, and adapters that supply their own prerenderer ignore the flag.
Enable parallel prerendering
Upgrade to 7.4 or later, then add the flag:
// astro.config.mjs
import { defineConfig } from 'astro/config';
export default defineConfig({
experimental: {
parallelPrerender: true,
},
});
To control how many workers start, pass an object instead of true:
// astro.config.mjs
import { defineConfig } from 'astro/config';
export default defineConfig({
experimental: {
parallelPrerender: { workers: 4 },
},
});
Run npx astro build as usual. Nothing else in your pages changes: getStaticPaths(), content collections and images work the same way.
How Astro splits the work
Without the flag, Astro renders static routes in a single thread, build.concurrency pages at a time (the default is 1). With parallel prerendering, Astro starts a pool of Node.js worker threads. One worker discovers the routes and runs getStaticPaths(), then the pages are handed out across the pool. Each worker still respects build.concurrency, so the total in flight is workers × build.concurrency.
Image metadata collected in the workers is merged back at the end, so optimized images are generated once, after rendering.
Measure before and after
Parallel prerendering only helps the “generating static routes” phase. If most of your build time is Vite bundling, image optimization or a slow CMS fetch, more workers won’t change much. Astro 7.4 added a flag that shows where the time goes:
# terminal
npx astro build --timings
Run it once with the flag off and once with it on, and compare the page-generation phase. Sites with hundreds or thousands of pages, such as a large blog or a docs site, are where the difference shows. A site with 20 pages will see little or nothing.
Tune workers for CI and memory
Every worker loads your project’s server bundle, so memory use grows with the worker count. On a laptop with plenty of RAM the default is fine. On CI runners and hosted build images, which often have two to four cores and limited memory, set the count explicitly:
// astro.config.mjs
import { defineConfig } from 'astro/config';
const workers = process.env.CI ? 2 : undefined;
export default defineConfig({
experimental: {
parallelPrerender: workers ? { workers } : true,
},
});
If a build fails with an out-of-memory error after enabling the flag, lower workers before anything else. Pairing this with a warm build cache, covered in caching Astro builds in CI, gives you two independent speedups.
When the flag is ignored
Some adapters provide their own prerenderer, for example to render pages inside the target runtime rather than in Node.js. In that case Astro logs a warning during the build:
`experimental.parallelPrerender` is not supported by the "<name>" prerenderer and will be ignored.
The build still succeeds; it just renders pages the normal way. Static sites without such an adapter use Astro’s own prerenderer, so the flag applies.
Code that relies on shared module state during a build (a counter in a module-level variable, a cache built up across pages) will behave differently, because each worker has its own copy. Move that kind of logic into a content loader or compute it inside getStaticPaths().
Should you turn it on?
Experimental flags can change between minor releases, so read the experimental parallel prerendering docs before relying on it in production. For large static sites with slow builds it’s worth a test today. The What’s New in Astro 7 roundup lists the other 7.4 flags, and astro.config.mjs in our docs shows where experimental options sit in a real config. Komal themes with large page counts, such as the ones in Blog & Editorial, are the kind of project that benefits.
FAQ
What is parallel prerendering in Astro?
It’s an experimental build option in Astro 7.4 that renders static pages across several worker threads instead of one process, so builds of large sites finish sooner on multi-core machines.
How many workers does Astro use for parallel prerendering?
All available CPU cores minus one, with a minimum of one. Set parallelPrerender: { workers: n } to choose a specific number.
Does parallel prerendering work with server output?
Yes, for the pages you prerender. Routes with prerender = false are rendered on request and aren’t part of the build step. Adapters that ship their own prerenderer ignore the flag and log a warning.
Is parallel prerendering the same as build.concurrency?
No. build.concurrency controls how many pages render at once inside a single process. Parallel prerendering adds worker threads, and each one uses build.concurrency.