Astro build timings show where astro build spends its time. Run npx astro build --timings (Astro 7.4 or later) and, after a successful build, Astro prints a report that breaks the total down by build phase, Vite plugin, Markdown plugin, syntax-highlighted language, slowest modules, slowest pages, image transforms and integration hooks.
Key Takeaways
--timingswas added in Astro 7.4 (October 2026); older versions ignore it.- The report prints only after a successful build and never fails the build itself.
- Read “Build phases” first, then the section under the slowest phase.
- Slow pages usually mean slow data fetching in
getStaticPaths()or the page itself.- Image transforms and highlighting are often the biggest wins on content-heavy sites.
Run it
# Terminal
npx astro build --timings
# or through your package script
npm run build -- --timings
The -- passes the flag through npm to astro build. Check your version first with npx astro --version; the flag is listed in npx astro build --help from 7.4. Nothing in astro.config.mjs needs to change, and normal builds are unaffected when you leave the flag off.
Read the report
The report opens with a “build timings” header that shows the total time, the page count and the output mode (static or server). Below it, sections appear only when they have something to show:
| Section | What it measures |
|---|---|
| Build phases | A tree of phases such as resolve config, content sync, prerender bundle, client bundle and generate pages, with a strip showing when each ran |
| Vite plugins | Time per plugin, with the hooks that used it |
| Markdown plugins | Time per remark or rehype plugin, across all Markdown and MDX files |
| Syntax highlighting | Time per language across all highlighted code blocks |
| Slowest files to bundle | Modules that took longest to load and transform, and which plugins did the work |
| Astro compiler | Slowest .astro files to compile (shown when it is at least 1% of the build) |
| Page rendering / Slowest pages | Render time, median and p95 per page, and how many came from cache |
| Images | Image transforms, the slowest files, and cache hits (shown when at least 1% of the build) |
| Integrations | Time spent in each integration’s hooks (shown when at least 1% of the build) |
Times are wall-clock, with overlapping work counted once, so the plugin totals tell you real elapsed time rather than summed CPU time.
Fix what it finds
Start from the largest phase in “Build phases” and go to the matching section.
Slow pages. If a few pages dominate “Slowest pages”, look at what they fetch. A fetch() per page in getStaticPaths() or in page frontmatter is the usual cause. Fetch once and pass data through props:
---
// src/pages/products/[id].astro
export async function getStaticPaths() {
const res = await fetch('https://api.example.com/products');
const products = await res.json();
return products.map((product) => ({
params: { id: product.id },
props: { product },
}));
}
const { product } = Astro.props;
---
<h1>{product.name}</h1>
If every page is evenly slow and the site is large, try the experimental parallel prerenderer, also new in 7.4:
// astro.config.mjs
import { defineConfig } from 'astro/config';
export default defineConfig({
experimental: {
parallelPrerender: { workers: 4 },
},
});
It renders pages on several CPU cores and uses more memory; by default it uses all cores but one. Run --timings before and after to see whether it helps your site.
Images. If “Images” shows many transforms and few cache hits on CI, your build cache is not being restored between runs. The CI build cache tip shows how to keep Astro’s cache directory.
Syntax highlighting. A long time in one language usually means one huge code block or a rarely used grammar. Our Shiki highlighting guide covers lighter configurations.
Markdown plugins and integrations. A single remark, rehype or integration hook at the top of the list is a candidate for caching or removal. Disable it, rebuild with --timings, and compare.
Slowest files to bundle. Large dependencies show up here by package name. Pair this with the bundle size analysis tip to see what reaches the browser.
Keep a baseline
Run the report on main and save it before you optimise, so you compare like with like:
# Terminal
npm run build -- --timings > timings-before.txt 2>&1
Build times vary between runs, so compare two or three before trusting a small difference. For what each phase actually does, read what happens during astro build, and see what’s new in Astro 7.4 for the release that added the flag. The flag is documented in the Astro CLI reference.
If you build from a Komal theme, the report works the same way; the deploy docs cover where builds run on each host, and the Astro themes catalog lists what each theme includes.
FAQ
How do I see build times in Astro?
Run npx astro build --timings on Astro 7.4 or later. Astro prints a breakdown of build phases, plugins, pages, images and integrations after the build finishes.
Why is my Astro build so slow?
The most common causes are data fetched separately for every page, many image transforms without a restored cache, heavy remark or rehype plugins, and large syntax-highlighted code blocks. The timings report shows which one applies.
Does astro build –timings slow down the build?
It adds a small amount of measurement work. Use it when you are investigating, and leave it off in your normal build script.
Does –timings work with server output?
Yes. The report header shows the output mode, and the sections cover whatever the build did, including prerendered pages in a server build.