To upgrade from Astro 6 to Astro 7, update Node.js first, run npx @astrojs/upgrade to bump Astro and every official integration together, then fix the four changes that cause most of the work: the new compressHTML: 'jsx' whitespace default, Markdown plugins moving into markdown.processor, importing z from astro/zod, and any existing src/fetch.ts file.
Key Takeaways
- Check Node.js before anything else. Astro 7.4.2 and later need Node.js 22.23.4 or newer.
npx @astrojs/upgradeupdates Astro and official integrations to matching versions.- Inline elements on separate lines can lose the space between them; check bylines and icon buttons.
- Deprecated options still work in Astro 7 but log warnings. Fix them now rather than in Astro 8.
1. Branch and record your versions
# terminal
git switch -c upgrade-astro-7
npx astro info
Save the astro info output so you can compare later. The astro info tip explains each line.
2. Update Node.js
Astro’s minimum Node.js version has moved during the 7.x line, so match it to the version you’re installing:
| Astro version | Minimum Node.js |
|---|---|
| 7.0 to 7.3 | 22.12.0 |
| 7.4.0 and 7.4.1 | 22.22.0 |
| 7.4.2 and later | 22.23.4 |
# terminal
node -v
Update your machine, your CI image and your host’s build setting. A .nvmrc file with 22 keeps them in step on most hosts.
3. Run the upgrade tool
# terminal
npx @astrojs/upgrade
It detects astro and every @astrojs/* package you use and installs versions built for Astro 7, so you don’t end up with an Astro 7 core and an Astro 6 adapter. Community integrations aren’t covered; update those by hand and check their changelogs.
4. Fix the breaking changes
Whitespace from compressHTML. The default is now 'jsx', which removes whitespace and line breaks around elements, the way React does. This renders “ByKomal”:
---
// src/components/Byline.astro
const { author } = Astro.props;
---
<p>
By
<strong>{author}</strong>
</p>
Put the text on one line, <p>By <strong>{author}</strong></p>, or add {" "} where you need the space. To defer the audit, set compressHTML: true to get the Astro 6 behaviour back.
Markdown plugins. Sätteri is the new default Markdown processor. Top-level markdown.remarkPlugins and rehypePlugins still work with a deprecation warning. Move them into unified():
// astro.config.mjs
import { defineConfig } from 'astro/config';
import { unified } from '@astrojs/markdown-remark';
import remarkToc from 'remark-toc';
export default defineConfig({
markdown: {
processor: unified({ remarkPlugins: [remarkToc] }),
},
});
Zod 4. Import z from astro/zod instead of astro:content. The old import still works in Astro 7 but is marked for removal. Review custom error messages and .refine() calls in your schemas.
// src/content.config.ts
import { defineCollection } from 'astro:content';
import { glob } from 'astro/loaders';
import { z } from 'astro/zod';
const blog = defineCollection({
loader: glob({ pattern: '**/*.{md,mdx}', base: './src/content/blog' }),
schema: z.object({ title: z.string(), pubDate: z.coerce.date() }),
});
export const collections = { blog };
src/fetch.ts. Astro 7 treats src/fetch.ts as a custom request entrypoint. If you already had a helper file with that name, rename it, or set fetchFile: null in your config.
5. Check types
# terminal
npx astro check
astro check doesn’t support TypeScript 7.0 yet. If you upgraded TypeScript at the same time, pin it back with npm install -D typescript@6. More in the astro check tip.
6. Build and compare
# terminal
npm run build && npm run preview
Click through pages with inline elements, Markdown with plugins, and any on-demand routes. The build log lists remaining deprecation warnings; fix them before merging.
Coming from Astro 5 or earlier? Upgrade one major at a time; our guide to upgrading Astro between major versions covers the older content collection changes, and What’s New in Astro 7 explains each new feature. Every Komal theme already runs Astro 7 and comes with free lifetime updates, so if your site is built on one you can pull the updated version from its repository; see our theme installation docs or browse Astro themes. The official Astro 7 upgrade guide has the complete list of changes.
FAQ
How do I upgrade to Astro 7?
Update Node.js, run npx @astrojs/upgrade, then fix whitespace changes from compressHTML, move remark and rehype plugins into markdown.processor, and import z from astro/zod.
What Node.js version does Astro 7 need?
Astro 7.0 to 7.3 need Node.js 22.12.0 or newer. From 7.4.2 the minimum is 22.23.4. Run node -v and check the engines field of the Astro version you install.
Why are spaces missing after upgrading to Astro 7?
The new compressHTML: 'jsx' default removes whitespace around elements that sit on separate lines. Put the text and element on one line, add {" "}, or set compressHTML: true.
Can I skip Astro 6 and go from Astro 5 to Astro 7?
It’s safer not to. Upgrade to Astro 6, build and fix, then upgrade to 7. Each official upgrade guide assumes you’re coming from the previous major.