Upgrade to Astro v7
Esta página aún no está disponible en tu idioma.
Copy this prompt to upgrade your project:
Upgrade my Astro project to v7. Follow the migration guide athttps://v7.docs.astro.build/en/guides/upgrade-to/v7/This guide will help you migrate from Astro v6 to Astro v7.
Need to upgrade an older project to v6 first? See our older migration guide.
Need to see the v6 docs? Visit this older version of the docs site (unmaintained v6 snapshot).
Upgrade Astro
Section titled “Upgrade Astro”Update your project’s version of Astro to the latest version using your package manager:
# Upgrade Astro and official integrations togethernpx @astrojs/upgrade alpha# Upgrade Astro and official integrations togetherpnpm dlx @astrojs/upgrade alpha# Upgrade Astro and official integrations togetheryarn dlx @astrojs/upgrade alphaYou can also upgrade your Astro integrations manually if needed, and you may also need to upgrade other dependencies in your project.
After upgrading Astro, you may not need to make any changes to your project at all!
But, if you notice errors or unexpected behavior, please check below for what has changed that might need updating in your project.
Astro v7.0 includes potentially breaking changes, as well as the removal of some previously deprecated features.
If your project doesn’t work as expected after upgrading to v7.0, check this guide for an overview of all breaking changes and instructions on how to update your codebase.
See the Astro changelog for full release notes.
Breaking Changes
Section titled “Breaking Changes”Dependency Upgrades
Section titled “Dependency Upgrades”Vite 8
Section titled “Vite 8”Astro v7.0 upgrades to Vite 8 as the development server and production bundler.
What should I do?
Section titled “What should I do?”If you are using Vite-specific plugins, configuration, or APIs, check the Vite 8 migration guide for their breaking changes and upgrade your project as needed.
Most Astro users should be able to upgrade without any changes to their project code. This is primarily a breaking change for Astro integrations and plugins that depend on Vite internals.
Experimental Flags
Section titled “Experimental Flags”Experimental flags allow you to opt in to features while they are in early development. The following experimental flags have been removed in Astro 7.0 and are now stable, or the new default behavior.
Remove these experimental flags from your Astro config if you were previously using them:
import { defineConfig } from 'astro/config';
export default defineConfig({ experimental: { rustCompiler: true, advancedRouting: true, routeCaching: true, },})Experimental features now stable:
Section titled “Experimental features now stable:”-
rustCompiler: The Rust-based Astro compiler is now the default and only compiler, replacing the previous Go-based compiler. No action is required for most projects. If you encounter any issues, please report them on GitHub. -
advancedRouting: Advanced routing is now enabled by default. See the advanced routing reference for more information. Note thatsrc/fetch.tsis now a reserved file name. -
routeCaching: Route caching is now enabled by default for improved performance.
Reserved file name: src/fetch.ts
Section titled “Reserved file name: src/fetch.ts”Astro v7.0 introduces advanced routing, which uses src/fetch.ts (or src/fetch.js) as a special file name, similar to src/middleware.ts. Astro will automatically import this file to configure routing behavior.
If your project already has a src/fetch.ts file used for other purposes, Astro will attempt to process it as an advanced routing configuration, which may cause unexpected errors.
What should I do?
Section titled “What should I do?”If you have an existing src/fetch.ts file that is not related to advanced routing, you have two options:
Rename your file to something else (e.g. src/fetcher.ts, src/main.ts), and update any imports that reference it.
Disable advanced routing by setting fetchFile: null in your Astro config:
import { defineConfig } from 'astro/config';
export default defineConfig({ fetchFile: null,});You can also point fetchFile to a different file name if you want to use advanced routing but need to keep src/fetch.ts for another purpose:
import { defineConfig } from 'astro/config';
export default defineConfig({ fetchFile: './src/router.ts',});Removed: @astrojs/db
Section titled “Removed: @astrojs/db”The @astrojs/db package has been removed in Astro v7.0 and is no longer maintained.
What should I do?
Section titled “What should I do?”Remove @astrojs/db from your project’s dependencies and replace it with one of the following alternatives:
-
Node.js built-in SQLite: Node.js now includes a built-in
node:sqlitemodule (available since Node.js v22.5.0). This is a good option if you are using the Node.js adapter and were using@astrojs/dbfor local SQLite storage. -
Drizzle ORM: If you were using
@astrojs/dbfor its Drizzle-based schema and query API, you can use Drizzle directly with any supported database. -
Other database libraries: Use any database library that suits your deployment platform (e.g. Turso, PlanetScale, Neon).