From 099c3a0d33835ac32536ef556a7613a6468be1c7 Mon Sep 17 00:00:00 2001 From: sarahrainsberger Date: Mon, 15 Sep 2025 22:21:32 +0000 Subject: [PATCH 01/22] create v6 upgrade guide page --- src/content/docs/en/guides/upgrade-to/v6.mdx | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/content/docs/en/guides/upgrade-to/v6.mdx diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx new file mode 100644 index 0000000000000..5fae4fa496dd3 --- /dev/null +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -0,0 +1,13 @@ +--- +title: Upgrade to Astro v6 +description: How to upgrade your project to Astro v6.0. +sidebar: + label: v6.0 +i18nReady: true +--- +import PackageManagerTabs from '~/components/tabs/PackageManagerTabs.astro' +import { Steps } from '@astrojs/starlight/components'; +import ReadMore from '~/components/ReadMore.astro' +import SourcePR from '~/components/SourcePR.astro' + +This guide will help you migrate from Astro v5 to Astro v6. \ No newline at end of file From 64ea345be257bd00f698cb084a9995c75fd3d52e Mon Sep 17 00:00:00 2001 From: sarahrainsberger Date: Fri, 19 Sep 2025 09:42:54 +0000 Subject: [PATCH 02/22] add sections --- src/content/docs/en/guides/upgrade-to/v6.mdx | 83 +++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 5fae4fa496dd3..1a6d1f892dddd 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -10,4 +10,85 @@ import { Steps } from '@astrojs/starlight/components'; import ReadMore from '~/components/ReadMore.astro' import SourcePR from '~/components/SourcePR.astro' -This guide will help you migrate from Astro v5 to Astro v6. \ No newline at end of file +This guide will help you migrate from Astro v5 to Astro v6. + +Need to upgrade an older project to v5 first? See our [older migration guide](/en/guides/upgrade-to/v5/). + +Need to see the v5 docs? Visit this [older version of the docs site (unmaintained v5.xx snapshot)](https://v5.docs.astro.build/). + +## Upgrade Astro + +Update your project's version of Astro to the latest version using your package manager: + + + + ```shell + # Upgrade Astro and official integrations together + npx @astrojs/upgrade + ``` + + + ```shell + # Upgrade Astro and official integrations together + pnpm dlx @astrojs/upgrade + ``` + + + ```shell + # Upgrade Astro and official integrations together + yarn dlx @astrojs/upgrade + ``` + + + +You can also [upgrade your Astro integrations manually](/en/guides/integrations-guide/#manual-upgrading) if needed, and you may also need to upgrade other dependencies in your project. + +:::note[Need to continue?] +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 v6.0 includes [potentially breaking changes](#breaking-changes), as well as the removal and deprecation of some features. + +If your project doesn't work as expected after upgrading to v6.0, check this guide for an overview of all breaking changes and instructions on how to update your codebase. + +See [the Astro changelog](https://github.com/withastro/astro/blob/main/packages/astro/CHANGELOG.md) for full release notes. + +## Dependency Upgrades + +Any major upgrades to Astro's dependencies may cause breaking changes in your project. + +## Legacy + +The following features are now considered legacy features. They should function normally but are no longer recommended and are in maintenance mode. They will see no future improvements and documentation will not be updated. These features will eventually be deprecated, and then removed entirely. + +## Deprecated + +The following deprecated features are no longer supported and are no longer documented. Please update your project accordingly. + +Some deprecated features may temporarily continue to function until they are completely removed. Others may silently have no effect, or throw an error prompting you to update your code. + +## Removed + +The following features have now been entirely removed from the code base and can no longer be used. Some of these features may have continued to work in your project even after deprecation. Others may have silently had no effect. + +Projects now containing these removed features will be unable to build, and there will no longer be any supporting documentation prompting you to remove these features. + +## Changed Defaults + +Some default behavior has changed in Astro v5.0 and your project code may need updating to account for these changes. + +In most cases, the only action needed is to review your existing project's deployment and ensure that it continues to function as you expect, making updates to your code as necessary. In some cases, there may be a configuration setting to allow you to continue to use the previous default behavior. + +## Breaking Changes + +The following changes are considered breaking changes in Astro v5.0. Breaking changes may or may not provide temporary backwards compatibility. If you were using these features, you may have to update your code as recommended in each entry. + +## Community Resources + +Know a good resource for Astro v5.0? [Edit this page](https://github.com/withastro/docs/edit/main/src/content/docs/en/guides/upgrade-to/v6.mdx) and add a link below! + +## Known Issues + +Please check [Astro's issues on GitHub](https://github.com/withastro/astro/issues/) for any reported issues, or to file an issue yourself. From 1a1f081e1eb23976b983866835dbe4a590811e08 Mon Sep 17 00:00:00 2001 From: ellielok Date: Fri, 19 Sep 2025 23:12:26 +1000 Subject: [PATCH 03/22] Remove ViewTransitions in v6 (#12347) Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> --- src/content/docs/en/guides/upgrade-to/v6.mdx | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 1a6d1f892dddd..41552d4979312 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -75,6 +75,33 @@ The following features have now been entirely removed from the code base and can Projects now containing these removed features will be unable to build, and there will no longer be any supporting documentation prompting you to remove these features. +### Removed: `` component + + + +In Astro 5.0, the `` component was renamed to `` to clarify the role of the component. The new name makes it more clear that the features you get from Astro's `` routing component are slightly different from the native CSS-based MPA router. However, a deprecated version of the `` component still existed and may have functioned in Astro 5.x. + +Astro 6.0 removes the `` component entirely and it can no longer be used in your project. Update to the `` component to continue to use these features. + +#### What should I do? + +Replace all occurrences of the `ViewTransitions` import and component with `ClientRouter`: + +```astro title="src/layouts/MyLayout.astro" del={1,7} ins={2,8} +import { ViewTransitions } from 'astro:transitions'; +import { ClientRouter } from 'astro:transitions'; + + + + ... + + + + +``` + +Read more about [view transitions and client-side routing in Astro](/en/guides/view-transitions/). + ## Changed Defaults Some default behavior has changed in Astro v5.0 and your project code may need updating to account for these changes. From 3e61972999056bdd1e0437d77f8aa71cefaf2c8b Mon Sep 17 00:00:00 2001 From: sarahrainsberger Date: Mon, 22 Sep 2025 12:12:10 +0000 Subject: [PATCH 04/22] updates home page banner to point to v6 --- src/content/docs/en/getting-started.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/en/getting-started.mdx b/src/content/docs/en/getting-started.mdx index fce0eb7214e70..9b70bb453fd03 100644 --- a/src/content/docs/en/getting-started.mdx +++ b/src/content/docs/en/getting-started.mdx @@ -7,7 +7,7 @@ editUrl: false next: false banner: content: | - Astro v5 is here! Learn how to upgrade your site + Astro v6 is here! Learn how to upgrade your site hero: title: Astro Docs tagline: Guides, resources, and API references to help you build with Astro. From b0aec7b742a6ce888f2868ed1f7602824795ceff Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Tue, 23 Sep 2025 18:24:38 +0200 Subject: [PATCH 05/22] [v6] remove emitESMImage() (#12403) --- src/content/docs/en/guides/upgrade-to/v6.mdx | 23 ++++++++++ .../en/reference/image-service-reference.mdx | 42 ------------------- 2 files changed, 23 insertions(+), 42 deletions(-) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 41552d4979312..f3f072bfa4fba 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -102,6 +102,29 @@ import { ClientRouter } from 'astro:transitions'; Read more about [view transitions and client-side routing in Astro](/en/guides/view-transitions/). +### Removed: `emitESMImage()` + + + +In Astro 5.6.2, the `emitESMImage()` function was deprecated in favor of `emitImageMetadata()`, which removes two deprecated arguments that were not meant to be exposed for public use: `_watchMode` and `experimentalSvgEnabled`. + +Astro 6.0 removes `emitESMImage()` entirely. Update to `emitImageMetadata()` to keep your current behavior. + +#### What should I do? + +Replace all occurrences of the `emitESMImage()` with `emitImageMetadata()` and remove unused arguments: + +```ts del={1,5} ins={2,6} +import { emitESMImage } from 'astro/assets/utils'; +import { emitImageMetadata } from 'astro/assets/utils'; + +const imageId = '/images/photo.jpg'; +const result = await emitESMImage(imageId, false, false); +const result = await emitImageMetadata(imageId); +``` + +Read more about [`emitImageMetadata()`](/en/reference/image-service-reference/#emitimagemetadata). + ## Changed Defaults Some default behavior has changed in Astro v5.0 and your project code may need updating to account for these changes. diff --git a/src/content/docs/en/reference/image-service-reference.mdx b/src/content/docs/en/reference/image-service-reference.mdx index c77da89618558..ce7a20c8b335d 100644 --- a/src/content/docs/en/reference/image-service-reference.mdx +++ b/src/content/docs/en/reference/image-service-reference.mdx @@ -601,48 +601,6 @@ async function extractImageMetadata() { await extractImageMetadata(); ``` -### `emitESMImage()` - -:::caution[Deprecated] -Use the [`emitImageMetadata`](#emitimagemetadata) function instead. -::: - -

- **Type:** `(id: string | undefined, _watchMode: boolean, experimentalSvgEnabled: boolean, fileEmitter?: FileEmitter) => Promise`
- -

- - -Processes an image file and emits its metadata and optionally its contents. In build mode, the function uses `fileEmitter` to generate an asset reference. In development mode, it resolves to a local file URL with query parameters for metadata. - -```ts - -import { emitESMImage } from 'astro/assets/utils'; - -const imageId = '/images/photo.jpg'; -const unusedWatchMode = false; // Deprecated, unused -const unusedExperimentalSvgEnabled = false; // Set to `true` only if you are using SVG and want the file data to be embedded - -try { - const result = await emitESMImage(imageId, unusedWatchMode, unusedExperimentalSvgEnabled); - if (result) { - console.log('Image metadata with contents:', result); - // Example output: - // { - // width: 800, - // height: 600, - // format: 'jpg', - // contents: Uint8Array([...]) - // } - } else { - console.log('No metadata was emitted for this image.'); - } -} catch (error) { - console.error('Failed to emit ESM image:', error); -} - -``` - ### `emitImageMetadata()`

From 49cfc1700fdee76f2068d9fd2b3057b753a6bb37 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 25 Sep 2025 10:48:38 +0200 Subject: [PATCH 06/22] [v6] redirectToDefaultLocale default behaviour change (#12353) Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> --- .../docs/en/guides/internationalization.mdx | 10 +++----- src/content/docs/en/guides/upgrade-to/v6.mdx | 25 +++++++++++++++++++ .../en/reference/configuration-reference.mdx | 6 ++--- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/content/docs/en/guides/internationalization.mdx b/src/content/docs/en/guides/internationalization.mdx index e210b84c37816..70b4bbdea9db8 100644 --- a/src/content/docs/en/guides/internationalization.mdx +++ b/src/content/docs/en/guides/internationalization.mdx @@ -170,15 +170,11 @@ Set this option when all routes will have their `/locale/` prefix in their URL a - URLs without a locale prefix, (e.g. `example.com/about/`) will return a 404 (not found) status code unless you specify a [fallback strategy](#fallback). -### `redirectToDefaultLocale` +#### Opting out of redirects for the home URL -

+Even with your default locale routes prefixed, this behaviour does not apply by default to your site's index page. This allows you to have a home page that exists outside of your configured locale structure, where all of your localized routes are prefixed except the home URL of your site. -Configures whether or not the home URL (`/`) generated by `src/pages/index.astro` will redirect to `/`. - -Setting `prefixDefaultLocale: true` will also automatically set `redirectToDefaultLocale: true` in your `routing` config object. By default, the required `src/pages/index.astro` file will automatically redirect to the index page of your default locale. - -You can opt out of this behavior by [setting `redirectToDefaultLocale: false`](/en/reference/configuration-reference/#i18nroutingredirecttodefaultlocale). This allows you to have a site home page that exists outside of your configured locale folder structure. +You can opt out of this behavior so that your main site URL will also redirect to a prefixed, localized route for your default locale. When `prefixDefaultLocale: true` is set, you can additionally configure `redirectToDefaultLocale: true`. This will ensure that the home URL (`/`) generated by `src/pages/index.astro` will redirect to `/[defaultLocale]/`. ### `manual` diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index f3f072bfa4fba..32b1cbd42c32a 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -131,6 +131,31 @@ Some default behavior has changed in Astro v5.0 and your project code may need u In most cases, the only action needed is to review your existing project's deployment and ensure that it continues to function as you expect, making updates to your code as necessary. In some cases, there may be a configuration setting to allow you to continue to use the previous default behavior. +### Changed: `i18n.routing.redirectToDefaultLocale` default value + +In Astro v5.0, the `i18n.routing.redirectToDefaultLocale` default value was `true`. When combined with the `i18n.routing.prefixDefaultLocale` default value of `false`, the resulting redirects could cause infinite loops. + +In Astro v6.0, `i18n.routing.redirectToDefaultLocale` now defaults to `false`. Additionally, it can now only be used if `i18n.routing.prefixDefaultLocale` is set to `true`. + +#### What should I do? + +Review your Astro `i18n` config as you may now need to explicitly set values for `redirectToDefaultLocale` and `prefixDefaultLocale` to recreate your project's previous behavior. + +```js ins={7} title="astro.config.mjs" +import { defineConfig } from 'astro/config'; + +export default defineConfig({ + i18n: { + routing: { + prefixDefaultLocale: true, + redirectToDefaultLocale: true + } + } +}) +``` + +Learn more about [Internationalization routing](/en/guides/internationalization/#routing). + ## Breaking Changes The following changes are considered breaking changes in Astro v5.0. Breaking changes may or may not provide temporary backwards compatibility. If you were using these features, you may have to update your code as recommended in each entry. diff --git a/src/content/docs/en/reference/configuration-reference.mdx b/src/content/docs/en/reference/configuration-reference.mdx index a907cadcc1a6f..c220bafec5b62 100644 --- a/src/content/docs/en/reference/configuration-reference.mdx +++ b/src/content/docs/en/reference/configuration-reference.mdx @@ -1549,14 +1549,14 @@ export default defineConfig({

**Type:** `boolean`
-**Default:** `true`
+**Default:** `false`

Configures whether or not the home URL (`/`) generated by `src/pages/index.astro` will redirect to `/[defaultLocale]` when `prefixDefaultLocale: true` is set. -Set `redirectToDefaultLocale: false` to disable this automatic redirection at the root of your site: +Set `redirectToDefaultLocale: true` to enable this automatic redirection at the root of your site: ```js // astro.config.mjs export default defineConfig({ @@ -1565,7 +1565,7 @@ export default defineConfig({ locales: ["en", "fr"], routing: { prefixDefaultLocale: true, - redirectToDefaultLocale: false + redirectToDefaultLocale: true } } }) From f7e6625f5c1e9de4c80b56d7ab11ef72906bfb0f Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 25 Sep 2025 15:43:04 +0200 Subject: [PATCH 07/22] [v6]: remove Astro.glob() [i18nIgnore] (#12401) Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> --- src/content/docs/en/guides/upgrade-to/v6.mdx | 27 ++++ .../docs/en/reference/api-reference.mdx | 115 ------------------ .../reference/errors/astro-glob-no-match.mdx | 5 - .../errors/astro-glob-used-outside.mdx | 5 - src/content/docs/it/guides/upgrade-to/v2.mdx | 2 +- src/content/docs/ja/guides/imports.mdx | 59 --------- .../ja/guides/integrations-guide/netlify.mdx | 2 +- .../docs/ja/guides/markdown-content.mdx | 4 +- .../from-create-react-app.mdx | 4 +- .../guides/migrate-to-astro/from-gridsome.mdx | 4 +- src/content/docs/ja/guides/upgrade-to/v2.mdx | 4 +- src/content/docs/ja/recipes/rss.mdx | 4 +- .../docs/ja/tutorial/5-astro-api/1.mdx | 6 +- src/content/docs/pl/guides/imports.mdx | 63 ---------- src/content/docs/pl/guides/upgrade-to/v2.mdx | 2 +- src/content/docs/pl/recipes/rss.mdx | 2 +- 16 files changed, 42 insertions(+), 266 deletions(-) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 32b1cbd42c32a..cfd394dcb6374 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -125,6 +125,33 @@ const result = await emitImageMetadata(imageId); Read more about [`emitImageMetadata()`](/en/reference/image-service-reference/#emitimagemetadata). +### Removed: `Astro.glob()` + + + +In Astro 5.0, `Astro.glob()` was deprecated in favor of using `getCollection()` to query your collections, and `import.meta.glob()` to query other source files in your project. + +Astro 6.0 removes `Astro.glob()` entirely. Update to `import.meta.glob()` to keep your current behavior. + +#### What should I do? + +Replace all use of `Astro.glob()` with `import.meta.glob()`. Note that `import.meta.glob()` no longer returns a `Promise`, so you may have to update your code accordingly. You should not require any updates to your [glob patterns](/en/guides/imports/#glob-patterns). + +```astro title="src/pages/blog.astro" del={2} ins={3} +--- +const posts = await Astro.glob('./posts/*.md'); +const posts = Object.values(import.meta.glob('./posts/*.md', { eager: true })); +--- + +{posts.map((post) =>
  • {post.frontmatter.title}
  • )} +``` + +Where appropriate, consider using [content collections](/en/guides/content-collections/) to organize your content, which has its own newer, more performant querying functions. + +You may also wish to consider using glob packages from NPM, such as [`fast-glob`](https://www.npmjs.com/package/fast-glob). + +Learn more about [importing files with `import.meta.glob`](/en/guides/imports/#importmetaglob). + ## Changed Defaults Some default behavior has changed in Astro v5.0 and your project code may need updating to account for these changes. diff --git a/src/content/docs/en/reference/api-reference.mdx b/src/content/docs/en/reference/api-reference.mdx index 8bcdbedcee4bb..bd6c7f2b044e5 100644 --- a/src/content/docs/en/reference/api-reference.mdx +++ b/src/content/docs/en/reference/api-reference.mdx @@ -1048,118 +1048,3 @@ Loads a session by ID. In normal use, a session is loaded automatically from the - - -### Deprecated object properties - -#### `Astro.glob()` - -:::caution[Deprecated in v5.0] -Use [Vite's `import.meta.glob`](https://vite.dev/guide/features.html#glob-import) to query project files. - -`Astro.glob('../pages/post/*.md')` can be replaced with: - -`Object.values(import.meta.glob('../pages/post/*.md', { eager: true }));` - -See the [imports guide](/en/guides/imports/#importmetaglob) for more information and usage. -::: - -`Astro.glob()` is a way to load many local files into your static site setup. - -```astro ---- -// src/components/my-component.astro -const posts = await Astro.glob('../pages/post/*.md'); // returns an array of posts that live at ./src/pages/post/*.md ---- - -
    -{posts.slice(0, 3).map((post) => ( -
    -

    {post.frontmatter.title}

    -

    {post.frontmatter.description}

    - Read more -
    -))} -
    -``` - -`.glob()` only takes one parameter: a relative URL glob of which local files you'd like to import. It’s asynchronous and returns an array of the exports from matching files. - -`.glob()` can't take variables or strings that interpolate them, as they aren't statically analyzable. (See [the imports guide](/en/guides/imports/#supported-values) for a workaround.) This is because `Astro.glob()` is a wrapper of Vite's [`import.meta.glob()`](https://vite.dev/guide/features.html#glob-import). - -:::note -You can also use `import.meta.glob()` itself in your Astro project. You may want to do this when: -- You need this feature in a file that isn't `.astro`, like an API route. `Astro.glob()` is only available in `.astro` files, while `import.meta.glob()` is available anywhere in the project. -- You don't want to load each file immediately. `import.meta.glob()` can return functions that import the file content, rather than returning the content itself. Note that this import includes all styles and scripts for any imported files. These will be bundled and added to the page whether or not a file is actually used, as this is decided by static analysis, not at runtime. -- You want access to each file's path. `import.meta.glob()` returns a map of a file's path to its content, while `Astro.glob()` returns a list of content. -- You want to pass multiple patterns; for example, you want to add a "negative pattern" that filters out certain files. `import.meta.glob()` can optionally take an array of glob strings, rather than a single string. - -Read more in the [Vite documentation](https://vite.dev/guide/features.html#glob-import). -::: - -##### Markdown Files - -Markdown files loaded with `Astro.glob()` return the following `MarkdownInstance` interface: - -```ts -export interface MarkdownInstance> { - /* Any data specified in this file's YAML/TOML frontmatter */ - frontmatter: T; - /* The absolute file path of this file */ - file: string; - /* The rendered path of this file */ - url: string | undefined; - /* Astro Component that renders the contents of this file */ - Content: AstroComponentFactory; - /** (Markdown only) Raw Markdown file content, excluding layout HTML and YAML/TOML frontmatter */ - rawContent(): string; - /** (Markdown only) Markdown file compiled to HTML, excluding layout HTML */ - compiledContent(): string; - /* Function that returns an array of the h1...h6 elements in this file */ - getHeadings(): Promise<{ depth: number; slug: string; text: string }[]>; - default: AstroComponentFactory; -} -``` - -You can optionally provide a type for the `frontmatter` variable using a TypeScript generic. - -```astro ---- -interface Frontmatter { - title: string; - description?: string; -} -const posts = await Astro.glob('../pages/post/*.md'); ---- - -
      - {posts.map(post =>
    • {post.frontmatter.title}
    • )} -
    -``` - -##### Astro Files - -Astro files have the following interface: - -```ts -export interface AstroInstance { - /* The file path of this file */ - file: string; - /* The URL for this file (if it is in the pages directory) */ - url: string | undefined; - default: AstroComponentFactory; -} -``` - -##### Other Files - -Other files may have various different interfaces, but `Astro.glob()` accepts a TypeScript generic if you know exactly what an unrecognized file type contains. - -```ts ---- -interface CustomDataFile { - default: Record; -} -const data = await Astro.glob('../data/**/*.js'); ---- -``` diff --git a/src/content/docs/en/reference/errors/astro-glob-no-match.mdx b/src/content/docs/en/reference/errors/astro-glob-no-match.mdx index 0e440b87c3717..e0f6b9d83d6b6 100644 --- a/src/content/docs/en/reference/errors/astro-glob-no-match.mdx +++ b/src/content/docs/en/reference/errors/astro-glob-no-match.mdx @@ -17,8 +17,3 @@ import DontEditWarning from '~/components/DontEditWarning.astro' ## What went wrong? `Astro.glob()` did not return any matching files. There might be a typo in the glob pattern. - -**See Also:** -- [Astro.glob](/en/reference/api-reference/#astroglob) - - diff --git a/src/content/docs/en/reference/errors/astro-glob-used-outside.mdx b/src/content/docs/en/reference/errors/astro-glob-used-outside.mdx index 0046b3892b504..f3473054c151f 100644 --- a/src/content/docs/en/reference/errors/astro-glob-used-outside.mdx +++ b/src/content/docs/en/reference/errors/astro-glob-used-outside.mdx @@ -17,8 +17,3 @@ import DontEditWarning from '~/components/DontEditWarning.astro' ## What went wrong? `Astro.glob()` can only be used in `.astro` files. You can use [`import.meta.glob()`](https://vite.dev/guide/features.html#glob-import) instead to achieve the same result. - -**See Also:** -- [Astro.glob](/en/reference/api-reference/#astroglob) - - diff --git a/src/content/docs/it/guides/upgrade-to/v2.mdx b/src/content/docs/it/guides/upgrade-to/v2.mdx index 5f6a628a5a3d4..f7440cce788b0 100644 --- a/src/content/docs/it/guides/upgrade-to/v2.mdx +++ b/src/content/docs/it/guides/upgrade-to/v2.mdx @@ -358,7 +358,7 @@ Astro v2.0 rimuove questa opzione completamente. L'utilizzo di `Astro.fetchConte #### Cosa devo fare? -Usa [`Astro.glob()`](/it/reference/api-reference/#astroglob) per recuperare i file di Markdown, oppure passa alla funzionalità [Collezione di Contenuti](/it/guides/content-collections/). +Usa `Astro.glob()` per recuperare i file di Markdown, oppure passa alla funzionalità [Collezione di Contenuti](/it/guides/content-collections/). ```astro --- diff --git a/src/content/docs/ja/guides/imports.mdx b/src/content/docs/ja/guides/imports.mdx index df13fa496b19c..9e179c09e84ae 100644 --- a/src/content/docs/ja/guides/imports.mdx +++ b/src/content/docs/ja/guides/imports.mdx @@ -197,65 +197,6 @@ import logoUrl from '@assets/logo.png?url'; これらのエイリアスは、[VS Code](https://code.visualstudio.com/docs/languages/jsconfig)や他のエディタにも自動的に統合されます。 -## `Astro.glob()` - -[`Astro.glob()`](/ja/reference/api-reference/#astroglob)は、多数のファイルを一度にインポートするための方法です。 - -`Astro.glob()`は、インポートしたいローカルファイルと一致する相対[globパターン](/ja/guides/imports/#globパターン)を1つのパラメータとして受け取るだけです。これは非同期で、マッチした各ファイルのエクスポートを配列で返します。 - -```astro title="src/components/my-component.astro" ---- -// `./src/pages/post/`の`.md`で終わるすべてのファイルをインポート -const posts = await Astro.glob('../pages/post/*.md'); ---- - -
    -{posts.slice(0, 4).map((post) => ( -
    -

    {post.frontmatter.title}

    -

    {post.frontmatter.description}

    - もっと読む -
    -))} -
    -``` - -`Astro.glob`を使用してインポートされたAstroコンポーネントは、[`AstroInstance`](/ja/reference/api-reference/#astro-files)型です。各コンポーネントのインスタンスは、その`default`プロパティを使用してレンダリングできます。 - -```astro title="src/pages/component-library.astro" {8} ---- -// `./src/components/`の`.astro`で終わるすべてのファイルをインポート -const components = await Astro.glob('../components/*.astro'); ---- - -{components.map((component) => ( -
    - -
    -))} -``` - -### globパターン - -globパターンは、特殊なワイルドカード文字をサポートするファイルパスです。プロジェクト内の複数のファイルを一度に参照する場合に使用します。 - -たとえば、globパターン`./pages/**/*.{md,mdx}`は、`pages`サブディレクトリで始まり、そのサブディレクトリをすべて調べ(`/**`)、 ファイル名(`/*`)が`.md`または`.mdx`で終わる(`.{md,mdx}`)ファイルにマッチします。 - -#### Astroのglobパターン - -`Astro.glob()`で使用する場合、globパターンは文字列リテラルである必要があり、変数を含むことはできません。回避策については、[トラブルシューティングガイド](/ja/guides/troubleshooting/#astroglob---no-matches-found一致するものはありません)を参照してください。 - -また、グロブパターンは、以下のいずれかで始まる必要があります。 -- `./`(カレントディレクトリで起動する) -- `../`(親ディレクトリから開始する場合) -- `/`(プロジェクトのルートから開始する場合) - -[globパターンの構文について、詳しくはこちらをご覧ください](https://github.com/mrmlnc/fast-glob#pattern-syntax)。 - -#### `Astro.glob()`と`getCollection()` - -[コンテンツコレクション](/ja/guides/content-collections/)は、`Astro.glob()`の代わりに複数のファイルを読み込むための[`getCollection()` API](/ja/reference/modules/astro-content/#getcollection)を提供します。コンテンツファイル(Markdown、MDX、Markdocなど)が`src/content/`ディレクトリ内のコレクションに配置されている場合、`getCollection()`を使用して[コレクションのクエリ](/ja/guides/content-collections/#コレクションのクエリ)を行い、コンテンツのエントリーを返します。 - ## WASM ```js diff --git a/src/content/docs/ja/guides/integrations-guide/netlify.mdx b/src/content/docs/ja/guides/integrations-guide/netlify.mdx index fececca859309..710b3ed6c40f4 100644 --- a/src/content/docs/ja/guides/integrations-guide/netlify.mdx +++ b/src/content/docs/ja/guides/integrations-guide/netlify.mdx @@ -307,7 +307,7 @@ export default defineConfig({ #### globパターンの使用 -`includeFiles`と`excludeFiles`の両方で、複数のファイルを照合するための[globパターン](/ja/guides/imports/#globパターン)がサポートされています。 +`includeFiles`と`excludeFiles`の両方で、複数のファイルを照合するためのglobパターンがサポートされています。 ```js title="astro.config.mjs" ins={7, 10-11} import { defineConfig } from 'astro/config'; diff --git a/src/content/docs/ja/guides/markdown-content.mdx b/src/content/docs/ja/guides/markdown-content.mdx index 2cbe96ec2d96c..6b5b16b9e83c9 100644 --- a/src/content/docs/ja/guides/markdown-content.mdx +++ b/src/content/docs/ja/guides/markdown-content.mdx @@ -205,7 +205,7 @@ const props = Astro.props; MarkdownファイルやMDXファイルをAstroファイルに直接インポートできます。これにより、そのMarkdownコンテンツや、AstroのJSXライクな式で使用できるフロントマターの値などのプロパティにアクセスできます。 -`import`文で特定の1ページを、[`Astro.glob()`](/ja/guides/imports/#astroglob)で複数のページをインポートできます。 +`import`文で特定の1ページを、`Astro.glob()`で複数のページをインポートできます。 ```astro title="src/pages/index.astro" --- @@ -352,7 +352,7 @@ MDXファイルでは、`export`文を使用してデータをエクスポート export const title = 'はじめてのMDXの投稿' ``` -この`title`は`import`や[`Astro.glob()`](/ja/reference/api-reference/#astroglob)文からアクセスできます。 +この`title`は`import`や`Astro.glob()`文からアクセスできます。 ```astro --- diff --git a/src/content/docs/ja/guides/migrate-to-astro/from-create-react-app.mdx b/src/content/docs/ja/guides/migrate-to-astro/from-create-react-app.mdx index c4ca7bc9cbca6..bbab8afffeaf0 100644 --- a/src/content/docs/ja/guides/migrate-to-astro/from-create-react-app.mdx +++ b/src/content/docs/ja/guides/migrate-to-astro/from-create-react-app.mdx @@ -259,7 +259,7 @@ export default Component; 3. import文を含む必要なJavaScriptはすべて[`コードフェンス`(`---`)](/ja/basics/astro-components/#コンポーネントスクリプト)内へ移動します。※[条件付きレンダリング](/ja/reference/astro-syntax/#動的html)に使うJavaScriptはテンプレート内に直接記述できます。 4. 追加プロパティは[Astro.props](/ja/reference/api-reference/#props)で取得します。 5. インポートしているコンポーネントを`.astro`へ変換するか検討します。現在のままReactコンポーネントとして残すこともできますが、インタラクティブ性が不要な場合は将来的に`.astro`へ書き換えると軽量化できます。 -6. `useEffect()`で行っていたデータ取得は、import文や[`import.meta.glob()`](/ja/guides/imports/#globパターン)でローカルファイルを読み込むか、`fetch()`で外部データを取得する方法へ置き換えます。 +6. `useEffect()`で行っていたデータ取得は、import文や`import.meta.glob()`でローカルファイルを読み込むか、`fetch()`で外部データを取得する方法へ置き換えます。 ### テストの移行 @@ -328,7 +328,7 @@ const randomUser = data.results[0]; --- ``` -- `import.meta.glob()`によるローカルファイル取得: [/ja/guides/imports/#globパターン](/ja/guides/imports/#globパターン) +- `import.meta.glob()`によるローカルファイル取得 - Collections APIのクエリ: [/ja/guides/content-collections/#コレクションのクエリ](/ja/guides/content-collections/#コレクションのクエリ) - リモートデータのフェッチ: [/ja/guides/data-fetching/](/ja/guides/data-fetching/) diff --git a/src/content/docs/ja/guides/migrate-to-astro/from-gridsome.mdx b/src/content/docs/ja/guides/migrate-to-astro/from-gridsome.mdx index 8f6e0a2b40559..7d88acd5955d8 100644 --- a/src/content/docs/ja/guides/migrate-to-astro/from-gridsome.mdx +++ b/src/content/docs/ja/guides/migrate-to-astro/from-gridsome.mdx @@ -29,7 +29,7 @@ GridsomeサイトをAstroで再構築する際には、次のような違いに - GridsomeはVueベースのシングルページアプリ(SPA)ですが、Astroは[`.astro`コンポーネント](/ja/basics/astro-components/)を使ったマルチページアプリ(MPA)です。AstroではVueの他、React、Svelte、Solidなども併用可能です。 - GridsomeはSPAとして`vue-router`と`vue-meta`を使ってルーティングや``の管理を行いますが、Astroでは個別HTMLページと[レイアウトコンポーネント](/ja/basics/layouts/)内で``を直接管理します。 -- [ローカルファイルのデータ取得](/ja/guides/imports/): GridsomeはGraphQLでファイルをクエリしますが、AstroではESMインポートと[`import.meta.glob()`](/ja/guides/imports/#globパターン)を使用します。GraphQLを使いたい場合は手動で追加できますが、標準では含まれません。 +- [ローカルファイルのデータ取得](/ja/guides/imports/): GridsomeはGraphQLでファイルをクエリしますが、AstroではESMインポートと`import.meta.glob()`を使用します。GraphQLを使いたい場合は手動で追加できますが、標準では含まれません。 ## GridsomeサイトをAstroに変換する @@ -59,7 +59,7 @@ GridsomeブログをAstroへ移行するには、公式ブログテーマスタ Gridsomeのプロジェクト構成はAstroに似ているため、いくつかのファイルは新しいAstroプロジェクトにそのままコピーできるかもしれません。ただし完全には一致しないため、[Astroのプロジェクト構成](/ja/basics/project-structure/)を事前に確認するのがおすすめです。 -また、Gridsomeとは異なり、Astroではファイルの読み込みに[`import.meta.glob()`](/ja/guides/imports/#globパターン)を使用するため、ローカルファイルの操作方法も併せて確認してください。 +また、Gridsomeとは異なり、Astroではファイルの読み込みに`import.meta.glob()`を使用するため、ローカルファイルの操作方法も併せて確認してください。 ポートフォリオサイトやドキュメントサイトなど別タイプのサイトに移行したい場合は、[astro.new](https://astro.new)で他の公式スターターテンプレートを確認してください。GitHubリポジトリへのリンクや、IDX・StackBlitz・CodeSandbox・Gitpodで開くためのワンクリックリンクが用意されています。 diff --git a/src/content/docs/ja/guides/upgrade-to/v2.mdx b/src/content/docs/ja/guides/upgrade-to/v2.mdx index e18e0546f114e..d10e9f0284539 100644 --- a/src/content/docs/ja/guides/upgrade-to/v2.mdx +++ b/src/content/docs/ja/guides/upgrade-to/v2.mdx @@ -356,8 +356,8 @@ Astro v2.0では、このオプションは完全に削除されています。 #### どうすればいいの? -{/* TODO: Set anchor link from #その他のアセット to #astroglob */} -[`Astro.glob()`](/ja/guides/imports/#その他のアセット)を使ってローカルのMarkdownファイルを取得したり、[コンテンツコレクション](/ja/guides/content-collections/)に変換したりできます。 + +`Astro.glob()`を使ってローカルのMarkdownファイルを取得したり、[コンテンツコレクション](/ja/guides/content-collections/)に変換したりできます。 ```astro // src/pages/index.astro diff --git a/src/content/docs/ja/recipes/rss.mdx b/src/content/docs/ja/recipes/rss.mdx index b2be66cf2801a..e3e68fca48373 100644 --- a/src/content/docs/ja/recipes/rss.mdx +++ b/src/content/docs/ja/recipes/rss.mdx @@ -69,7 +69,7 @@ export function GET(context) { `items`フィールドは、RSSフィードのオブジェクトのリストを受け入れます。各オブジェクトには、`link`、`title`、`pubDate`の3つの必須フィールドがあります。`description`(短い抜粋)、`content`(記事の全文)、ブログ記事の他のフロントマタープロパティなど追加のデータのための`customData`フィールド、という3つの値も任意で含められます。 -コンテンツコレクションのスキーマからや、`src/pages/`内のブログ記事に対して[globインポート](/ja/guides/imports/#astroglob)を利用することで、この配列を生成できます。 +コンテンツコレクションのスキーマからや、`src/pages/`内のブログ記事に対してglobインポートを利用することで、この配列を生成できます。 ### コンテンツコレクションの使用 @@ -119,7 +119,7 @@ export const collections = { blog }; -`src/pages/`内のドキュメントからRSSフィードを作成するには、`pagesGlobToRssItems()`ヘルパーを利用します。これは[`import.meta.glob`](https://vite.dev/guide/features.html#glob-import)の結果を入力とし、有効なRSSフィードアイテムの配列を出力します(含めるページを指定するためには、[globパターンの書き方について](/ja/guides/imports/#globパターン)を確認してください)。 +`src/pages/`内のドキュメントからRSSフィードを作成するには、`pagesGlobToRssItems()`ヘルパーを利用します。これは[`import.meta.glob`](https://vite.dev/guide/features.html#glob-import)の結果を入力とし、有効なRSSフィードアイテムの配列を出力します(含めるページを指定するためには、globパターンの書き方についてを確認してください)。 :::caution この関数は、必要なフィードプロパティが各ドキュメントのフロントマターに存在することを前提としていますが、その検証はおこないません。エラーが発生した場合は、各ページのフロントマターを手動で確認してください。 diff --git a/src/content/docs/ja/tutorial/5-astro-api/1.mdx b/src/content/docs/ja/tutorial/5-astro-api/1.mdx index bd1cc15eaef02..993d43f5c563c 100644 --- a/src/content/docs/ja/tutorial/5-astro-api/1.mdx +++ b/src/content/docs/ja/tutorial/5-astro-api/1.mdx @@ -244,8 +244,4 @@ const myPosts = await Astro.glob('../pages/posts/*.md'); - [ ] ローカルファイルのデータを取得できる。 - [ ] ブログ記事のリストを表示できる。 - - -### 参考 - -- [`Astro.glob()` APIドキュメント](/ja/reference/api-reference/#astroglob) + \ No newline at end of file diff --git a/src/content/docs/pl/guides/imports.mdx b/src/content/docs/pl/guides/imports.mdx index 4e72b52d061c8..09ad6058543bc 100644 --- a/src/content/docs/pl/guides/imports.mdx +++ b/src/content/docs/pl/guides/imports.mdx @@ -186,69 +186,6 @@ import logoUrl from '@assets/logo.png?url'; Te aliasy są również automatycznie zintegrowane z [VS Code](https://code.visualstudio.com/docs/languages/jsconfig) i innymi edytorami. - -## `Astro.glob()` - -`Astro.glob()` to sposób na zaimportowanie wielu plików naraz. - -`Astro.glob()` przyjmuje tylko jeden parametr: względny [wzorzec glob](/pl/guides/imports/#wzorce-glob) pasujący do lokalnych plików, które chcesz zaimportować. Jest asynchroniczna i zwraca tablicę eksportów każdego pasującego pliku. - -``` -astro title="src/components/my-component.astro" ---- -// importuje wszystkie pliki kończące się na `.md` w `./src/pages/post/` -const posts = await Astro.glob('../pages/post/*.md'); ---- - -
    -{posts.slice(0, 4).map((post) => ( -
    -

    {post.frontmatter.title}

    -

    {post.frontmatter.description}

    - Read more -
    -))} -
    -``` - -Komponenty Astro importowane za pomocą `Astro.glob` są typu [`AstroInstance`](/pl/reference/api-reference/#astro-files). Możesz renderować każdą instancję komponentu używając jej właściwości `default`: - -```astro title="src/pages/component-library.astro" {8} ---- -// importuje wszystkie pliki kończące się na `.astro` w `./src/components/` -const components = await Astro.glob('../components/*.astro'); ---- - -{components.map((component) => ( -
    - -
    -))} -``` - - -### Wzorce glob - -Wzorzec glob to ścieżka pliku, która obsługuje specjalne znaki wieloznaczne. Używa się go do odwoływania się do wielu plików w Twoim projekcie naraz. - -Na przykład, wzorzec glob `./pages/**/*.{md,mdx}` zaczyna w podkatalogu `pages`, przeszukuje wszystkie jego podkatalogi `(/**)` i dopasowuje dowolną nazwę pliku `(/*)` kończącą się na `.md` lub `.mdx (.{md,mdx})`. - -#### Wzorce glob w Astro - -Aby użyć z `Astro.glob()`, wzorzec glob musi być ciągiem znaków i nie może zawierać żadnych zmiennych. Zobacz przewodnik rozwiązywania problemów po rozwiązania. - -Dodatkowo, wzorce glob muszą zaczynać się od jednego z następujących: -- `./` (aby zacząć w bieżącym katalogu) -- `../` (aby zacząć w katalogu nadrzędnym) -- `/` (aby zacząć w katalogu głównym projektu) - - -[Przeczytaj więcej o składni wzorców glob](https://github.com/mrmlnc/fast-glob#pattern-syntax). - -#### `Astro.glob()` vs `getCollection()` - -[Zbiory treści](/pl/guides/content-collections/) dostarczają [`getCollection()` API](/pl/reference/modules/astro-content/#getcollection) do ładowania wielu plików zamiast `Astro.glob()`. Jeśli Twoje pliki treści (np. Markdown, MDX, Markdoc) znajdują się w zbiorach w katalogu `src/content/` użyj `getCollection()`, aby [zapytaj zbiór](/pl/guides/content-collections/#querying-collections) i zwróć wpisy treści. - ## WASM ```js diff --git a/src/content/docs/pl/guides/upgrade-to/v2.mdx b/src/content/docs/pl/guides/upgrade-to/v2.mdx index 69f67a192131a..9ff4ef1b7f601 100644 --- a/src/content/docs/pl/guides/upgrade-to/v2.mdx +++ b/src/content/docs/pl/guides/upgrade-to/v2.mdx @@ -352,7 +352,7 @@ Astro v2.0 usuwa tę funkcję całkowicie. Wywołanie `Astro.fetchContent()` w t #### Co powinienem zrobić? -Skorzystaj z [`Astro.glob()`](/pl/reference/api-reference/#astroglob) do pobierania plików Markdown lub przekonwertuj je na [Kolekcję Treści](/pl/guides/content-collections/). +Skorzystaj z `Astro.glob()` do pobierania plików Markdown lub przekonwertuj je na [Kolekcję Treści](/pl/guides/content-collections/). ```astro --- diff --git a/src/content/docs/pl/recipes/rss.mdx b/src/content/docs/pl/recipes/rss.mdx index 61706587520ea..5927fb700b54e 100644 --- a/src/content/docs/pl/recipes/rss.mdx +++ b/src/content/docs/pl/recipes/rss.mdx @@ -127,7 +127,7 @@ export const collections = { blog };

    -Aby utworzyć kanał RSS z dokumentów w `src/pages/`, użyj pomocnika `pagesGlobToRssItems()`. Akceptuje on wynik [`import.meta.glob`](https://vite.dev/guide/features.html#glob-import) i zwraca tablicę prawidłowych elementów kanału RSS (zobacz [więcej o pisaniu wzorców glob](/pl/guides/imports/#wzorce-glob) w celu określenia, które strony uwzględnić). +Aby utworzyć kanał RSS z dokumentów w `src/pages/`, użyj pomocnika `pagesGlobToRssItems()`. Akceptuje on wynik [`import.meta.glob`](https://vite.dev/guide/features.html#glob-import) i zwraca tablicę prawidłowych elementów kanału RSS (zobacz więcej o pisaniu wzorców glob w celu określenia, które strony uwzględnić). :::caution Ta funkcja zakłada, ale nie weryfikuje, że wszystkie niezbędne właściwości kanału są obecne w każdym dokumencie frontmatter. Jeśli napotkasz błędy, zweryfikuj frontmatter każdej strony ręcznie. From 35cc592e36cdc7e244c65fd7a1131c43dc189706 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 25 Sep 2025 16:07:36 +0200 Subject: [PATCH 08/22] [v6] drop node 18 (#12423) Co-authored-by: Matt Kane Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> --- .../docs/en/guides/deploy/microsoft-azure.mdx | 2 +- src/content/docs/en/guides/deploy/netlify.mdx | 2 +- src/content/docs/en/guides/upgrade-to/v6.mdx | 28 +++++++++++++++++++ src/content/docs/en/install-and-setup.mdx | 2 +- src/content/docs/en/tutorial/1-setup/1.mdx | 4 +-- src/content/docs/en/upgrade-astro.mdx | 2 +- 6 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/content/docs/en/guides/deploy/microsoft-azure.mdx b/src/content/docs/en/guides/deploy/microsoft-azure.mdx index 57ffa6ddf0360..1c75d88e2e367 100644 --- a/src/content/docs/en/guides/deploy/microsoft-azure.mdx +++ b/src/content/docs/en/guides/deploy/microsoft-azure.mdx @@ -38,7 +38,7 @@ The GitHub action yaml that is created for you assumes the use of node 14. This ``` "engines": { - "node": ">=18.0.0" + "node": ">=22.0.0" }, ``` diff --git a/src/content/docs/en/guides/deploy/netlify.mdx b/src/content/docs/en/guides/deploy/netlify.mdx index 449e8fd034873..9b219286a123a 100644 --- a/src/content/docs/en/guides/deploy/netlify.mdx +++ b/src/content/docs/en/guides/deploy/netlify.mdx @@ -99,7 +99,7 @@ You can also create a new site on Netlify and link up your Git repository by ins ### Set a Node.js version -If you are using a legacy [build image](https://docs.netlify.com/configure-builds/get-started/#build-image-selection) (Xenial) on Netlify, make sure that your Node.js version is set. Astro requires `v18.20.8` or `v20.3.0` or higher. +If you are using a legacy [build image](https://docs.netlify.com/configure-builds/get-started/#build-image-selection) (Xenial) on Netlify, make sure that your Node.js version is set. Astro requires `v22.0.0` or higher. You can [specify your Node.js version in Netlify](https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript) using: - a [`.nvmrc`](https://github.com/nvm-sh/nvm#nvmrc) file in your base directory. diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index cfd394dcb6374..195dbbc427c48 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -59,6 +59,34 @@ See [the Astro changelog](https://github.com/withastro/astro/blob/main/packages/ Any major upgrades to Astro's dependencies may cause breaking changes in your project. +### Node 22 + + + +Node 18 reached its End of Life in March 2025 and Node 20 is scheduled to reach its End of Life in April 2026. + +Astro v6.0 drops Node 18 and Node 20 support entirely so that all Astro users can take advantage of Node's more modern features. + +#### What should I do? + +Check that both your development environment and your deployment environment are using **Node `22.0.0` or higher**. + + +1. Check your local version of Node using: + + ```sh + node -v + ``` + +2. Check your [deployment environment's](/en/guides/deploy/) own documentation to verify that they support Node 22. + + You can specify Node `22.0.0` for your Astro project either in a dashboard configuration setting or a `.nvmrc` file. + + ```bash title=".nvmrc" + 22.0.0 + ``` + + ## Legacy The following features are now considered legacy features. They should function normally but are no longer recommended and are in maintenance mode. They will see no future improvements and documentation will not be updated. These features will eventually be deprecated, and then removed entirely. diff --git a/src/content/docs/en/install-and-setup.mdx b/src/content/docs/en/install-and-setup.mdx index 9a2e4d50fbcd6..cf8c47ef79ffd 100644 --- a/src/content/docs/en/install-and-setup.mdx +++ b/src/content/docs/en/install-and-setup.mdx @@ -24,7 +24,7 @@ Prefer to try Astro in your browser? Visit [astro.new](https://astro.new/) to br ## Prerequisites -- **Node.js** - `v18.20.8` or `v20.3.0`, `v22.0.0` or higher. ( `v19` and `v21` are not supported.) +- **Node.js** - `v22.0.0` or higher. Odd-numbered versions like `v23` are not supported. - **Text editor** - We recommend [VS Code](https://code.visualstudio.com/) with our [Official Astro extension](https://marketplace.visualstudio.com/items?itemName=astro-build.astro-vscode). - **Terminal** - Astro is accessed through its command-line interface (CLI). diff --git a/src/content/docs/en/tutorial/1-setup/1.mdx b/src/content/docs/en/tutorial/1-setup/1.mdx index 3c00e5865385c..d0dac990e6062 100644 --- a/src/content/docs/en/tutorial/1-setup/1.mdx +++ b/src/content/docs/en/tutorial/1-setup/1.mdx @@ -28,7 +28,7 @@ You can access the command line through a local terminal program for your operat ### Node.js -For Astro to run on your system, you will also need to have a compatible version of [**Node.js**](https://nodejs.org/en/) installed. Astro supports **even-numbered** Node.js versions. The current minimum supported versions of each are: `v18.20.8`, `v20.3.0`, and `v22.0.0`. (`v19` and `v21` are not supported.) +For Astro to run on your system, you will also need to have a compatible version of [**Node.js**](https://nodejs.org/en/) installed. Astro supports **even-numbered** Node.js versions. The current minimum supported version is `v22.0.0`. Odd-numbered versions like `v23` are not supported. To check to see whether you already have a compatible version installed, run the following command in your terminal: @@ -36,7 +36,7 @@ To check to see whether you already have a compatible version installed, run the node -v // Example output -v18.20.8 +v22.20.0 ``` If the command returns a version number supported by Astro, you're good to go! diff --git a/src/content/docs/en/upgrade-astro.mdx b/src/content/docs/en/upgrade-astro.mdx index 9c99d13c6bba7..e59278a775e1a 100644 --- a/src/content/docs/en/upgrade-astro.mdx +++ b/src/content/docs/en/upgrade-astro.mdx @@ -194,7 +194,7 @@ A major release may also include some non-breaking changes and improvements that The following rules define when Astro may deprecate, drop, or add support for versions of Node.js: - Odd versions of Node.js can be deprecated and/or dropped when the next even version of Node.js published. This change can occur in a **minor** release of Astro, after a reasonable period of extended support as decided by the Astro Core team. -- Upgrading the minimum **_Maintenance_ LTS** (within the same major range, e.g. from `v18.14.*` to `v18.20.*`) version of Node.js can occur in a **minor** release of Astro. +- Upgrading the minimum **_Maintenance_ LTS** (within the same major range, e.g. from `22.14.*` to `22.20.*`) version of Node.js can occur in a **minor** release of Astro. - Security exception: If a security flaw in Node.js that **affects Astro** is disclosed and fixed, the Core team can bump the minimum version of the **_Maintenance_ LTS** in a **patch** release. - Upgrading minor or major versions of Node.js (**not** Maintenance LTS) occurs only in major versions of Astro. - Security exception: If a security flaw in Node.js that **affects Astro** is disclosed and fixed, the Core team can bump the minimum version in a **minor** release. From 8292fb32cff71e7c7912ef8a35ea60e8d52de4c7 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 25 Sep 2025 16:32:06 +0200 Subject: [PATCH 09/22] feat: update version --- src/content/docs/en/guides/deploy/microsoft-azure.mdx | 2 +- src/content/docs/en/guides/deploy/netlify.mdx | 2 +- src/content/docs/en/guides/upgrade-to/v6.mdx | 6 +++--- src/content/docs/en/install-and-setup.mdx | 2 +- src/content/docs/en/tutorial/1-setup/1.mdx | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/content/docs/en/guides/deploy/microsoft-azure.mdx b/src/content/docs/en/guides/deploy/microsoft-azure.mdx index 1c75d88e2e367..dfb03cdcd3785 100644 --- a/src/content/docs/en/guides/deploy/microsoft-azure.mdx +++ b/src/content/docs/en/guides/deploy/microsoft-azure.mdx @@ -38,7 +38,7 @@ The GitHub action yaml that is created for you assumes the use of node 14. This ``` "engines": { - "node": ">=22.0.0" + "node": ">=22.12.0" }, ``` diff --git a/src/content/docs/en/guides/deploy/netlify.mdx b/src/content/docs/en/guides/deploy/netlify.mdx index 9b219286a123a..795ab2bdb7d5c 100644 --- a/src/content/docs/en/guides/deploy/netlify.mdx +++ b/src/content/docs/en/guides/deploy/netlify.mdx @@ -99,7 +99,7 @@ You can also create a new site on Netlify and link up your Git repository by ins ### Set a Node.js version -If you are using a legacy [build image](https://docs.netlify.com/configure-builds/get-started/#build-image-selection) (Xenial) on Netlify, make sure that your Node.js version is set. Astro requires `v22.0.0` or higher. +If you are using a legacy [build image](https://docs.netlify.com/configure-builds/get-started/#build-image-selection) (Xenial) on Netlify, make sure that your Node.js version is set. Astro requires `v22.12.0` or higher. You can [specify your Node.js version in Netlify](https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript) using: - a [`.nvmrc`](https://github.com/nvm-sh/nvm#nvmrc) file in your base directory. diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 195dbbc427c48..983472171468f 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -69,7 +69,7 @@ Astro v6.0 drops Node 18 and Node 20 support entirely so that all Astro users ca #### What should I do? -Check that both your development environment and your deployment environment are using **Node `22.0.0` or higher**. +Check that both your development environment and your deployment environment are using **Node `22.12.0` or higher**. 1. Check your local version of Node using: @@ -80,10 +80,10 @@ Check that both your development environment and your deployment environment are 2. Check your [deployment environment's](/en/guides/deploy/) own documentation to verify that they support Node 22. - You can specify Node `22.0.0` for your Astro project either in a dashboard configuration setting or a `.nvmrc` file. + You can specify Node `22.12.0` for your Astro project either in a dashboard configuration setting or a `.nvmrc` file. ```bash title=".nvmrc" - 22.0.0 + 22.12.0 ``` diff --git a/src/content/docs/en/install-and-setup.mdx b/src/content/docs/en/install-and-setup.mdx index cf8c47ef79ffd..65f77ac9b9458 100644 --- a/src/content/docs/en/install-and-setup.mdx +++ b/src/content/docs/en/install-and-setup.mdx @@ -24,7 +24,7 @@ Prefer to try Astro in your browser? Visit [astro.new](https://astro.new/) to br ## Prerequisites -- **Node.js** - `v22.0.0` or higher. Odd-numbered versions like `v23` are not supported. +- **Node.js** - `v22.12.0` or higher. Odd-numbered versions like `v23` are not supported. - **Text editor** - We recommend [VS Code](https://code.visualstudio.com/) with our [Official Astro extension](https://marketplace.visualstudio.com/items?itemName=astro-build.astro-vscode). - **Terminal** - Astro is accessed through its command-line interface (CLI). diff --git a/src/content/docs/en/tutorial/1-setup/1.mdx b/src/content/docs/en/tutorial/1-setup/1.mdx index d0dac990e6062..40575f90934c1 100644 --- a/src/content/docs/en/tutorial/1-setup/1.mdx +++ b/src/content/docs/en/tutorial/1-setup/1.mdx @@ -28,7 +28,7 @@ You can access the command line through a local terminal program for your operat ### Node.js -For Astro to run on your system, you will also need to have a compatible version of [**Node.js**](https://nodejs.org/en/) installed. Astro supports **even-numbered** Node.js versions. The current minimum supported version is `v22.0.0`. Odd-numbered versions like `v23` are not supported. +For Astro to run on your system, you will also need to have a compatible version of [**Node.js**](https://nodejs.org/en/) installed. Astro supports **even-numbered** Node.js versions. The current minimum supported version is `v22.12.0`. Odd-numbered versions like `v23` are not supported. To check to see whether you already have a compatible version installed, run the following command in your terminal: From 2b258ce884d34d6a84afd32efbe48c7d0dae1ded Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Mon, 29 Sep 2025 11:35:37 +0200 Subject: [PATCH 10/22] [v6] update vite to v7 (#12444) --- src/content/docs/en/guides/upgrade-to/v6.mdx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 983472171468f..53a3dccfb302b 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -87,6 +87,14 @@ Check that both your development environment and your deployment environment are ``` +### Vite 7.0 + +Astro v6.0 upgrades to Vite v7.0 as the development server and production bundler. + +#### What should I do? + +If you are using Vite-specific plugins, configuration, or APIs, check the [Vite migration guide](https://vite.dev/guide/migration) for their breaking changes and upgrade your project as needed. + ## Legacy The following features are now considered legacy features. They should function normally but are no longer recommended and are in maintenance mode. They will see no future improvements and documentation will not be updated. These features will eventually be deprecated, and then removed entirely. From 369c7ab4065b3d3e0a610f23014dfd2fca664775 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Mon, 29 Sep 2025 11:39:40 +0200 Subject: [PATCH 11/22] [v6] deprecate Astro in getStaticPaths (#12435) Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> --- src/content/docs/en/guides/upgrade-to/v6.mdx | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 53a3dccfb302b..d0245ff410c90 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -105,6 +105,32 @@ The following deprecated features are no longer supported and are no longer docu Some deprecated features may temporarily continue to function until they are completely removed. Others may silently have no effect, or throw an error prompting you to update your code. +### `Astro` in `getStaticPaths()` + + + +In Astro 5.x, it was possible to access an `Astro` object inside `getStaticPaths()`. However, despite being typed the same as the `Astro` object accessible in the frontmatter, this object only had `site` and `generator` properties. This could lead to confusion about which `Astro` object properties were available inside `getStaticPaths()`. + +Astro 6.0 deprecates this object for `getStaticPaths()` to avoid confusion and improves error handling when attempting to access `Astro` values that are unavailable. Using `Astro.site` or `Astro.generator` within `getStaticPaths()` will now log a deprecation warning, and accessing any other property will throw a specific error with a helpful message. In a future major version, this object will be removed entirely, and accessing `Astro.site` or `Astro.generator` will also throw an error. + +#### What should I do? + +Update your `getStaticPaths()` function if you were attempting to access any `Astro` properties inside its scope. Remove `Astro.generator` entirely, and replace all occurrences of `Astro.site()` with `import.meta.env.SITE`: + +```astro title="src/pages/blog/[slug].astro" del={5,6} ins={7} +--- +import { getPages } from "../../../utils/data"; + +export async function getStaticPaths() { + console.log(Astro.generator); + return getPages(Astro.site); + return getPages(import.meta.env.SITE); +} +--- +``` + +Read more about [built-in environment variables such as `import.meta.env.SITE`](/en/guides/environment-variables/#default-environment-variables) that are accessible when [using `getStaticPaths()` to dynamically generate static routes](/en/guides/routing/#static-ssg-mode). + ## Removed The following features have now been entirely removed from the code base and can no longer be used. Some of these features may have continued to work in your project even after deprecation. Others may have silently had no effect. From 824ae0dca483a6d195b1f808de3f8a56f21f0ea8 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Mon, 29 Sep 2025 16:30:44 +0200 Subject: [PATCH 12/22] [v6] integration api cleanup (#12445) Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> --- src/content/docs/en/guides/upgrade-to/v5.mdx | 4 +- src/content/docs/en/guides/upgrade-to/v6.mdx | 65 ++++++ .../docs/en/reference/adapter-reference.mdx | 2 +- .../en/reference/integrations-reference.mdx | 186 ------------------ .../docs/es/guides/internationalization.mdx | 1 - .../docs/es/reference/adapter-reference.mdx | 87 -------- .../docs/ja/reference/adapter-reference.mdx | 89 +-------- src/content/docs/ko/guides/upgrade-to/v5.mdx | 4 +- .../docs/ko/reference/adapter-reference.mdx | 2 +- .../ko/reference/integrations-reference.mdx | 4 +- .../pt-br/reference/adapter-reference.mdx | 87 -------- .../docs/zh-cn/guides/upgrade-to/v5.mdx | 4 +- .../zh-cn/reference/adapter-reference.mdx | 2 +- .../reference/integrations-reference.mdx | 6 +- 14 files changed, 80 insertions(+), 463 deletions(-) diff --git a/src/content/docs/en/guides/upgrade-to/v5.mdx b/src/content/docs/en/guides/upgrade-to/v5.mdx index e807eaf133de5..f66c46dba673d 100644 --- a/src/content/docs/en/guides/upgrade-to/v5.mdx +++ b/src/content/docs/en/guides/upgrade-to/v5.mdx @@ -1112,7 +1112,7 @@ function useRoute(route: IntegrationRouteData) { } ``` -See the [API reference for `IntegrationRouteData`](/en/reference/integrations-reference/#integrationroutedata-type-reference). +See the API reference for `IntegrationRouteData`. ### Changed: `distURL` is now an array (Integrations API) @@ -1139,7 +1139,7 @@ if (route.distURL) { } ``` -See the [API reference for `IntegrationRouteData`](/en/reference/integrations-reference/#integrationroutedata-type-reference). +See the [API reference for `IntegrationRouteData`. ### Changed: Arguments passed to `app.render()` (Adapter API) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index d0245ff410c90..15aeac1e474a8 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -214,6 +214,71 @@ You may also wish to consider using glob packages from NPM, such as [`fast-glob` Learn more about [importing files with `import.meta.glob`](/en/guides/imports/#importmetaglob). +### Removed: `routes` on `astro:build:done` hook (Integration API) + + + +In Astro 5.0, accessing `routes` on the `astro:build:done` hook was deprecated. + +Astro 6.0 removes the `routes` array passed to this hook entirely. Instead, the `astro:routes:resolved` hook should be used. + +#### What should I do? + +Remove any instance of `routes` passed to `astro:build:done` and replace it with the new `astro:routes:resolved` hook. Access `distURL` on the newly exposed `assets` map: + +```js title="my-integration.mjs" ins={2,6-8,11,13-18} del={10} +const integration = () => { + let routes + return { + name: 'my-integration', + hooks: { + 'astro:routes:resolved': (params) => { + routes = params.routes + }, + 'astro:build:done': ({ + routes + assets + }) => { + for (const route of routes) { + const distURL = assets.get(route.pattern) + if (distURL) { + Object.assign(route, { distURL }) + } + } + console.log(routes) + } + } + } +} +``` + +Learn more about [the Integration API `astro:routes:resolved` hook](/en/reference/integrations-reference/#astroroutesresolved) for building integrations. + +### Removed: `entryPoints` on `astro:build:ssr` hook (Integration API) + + + +In Astro 5.0, [`functionPerRoute` was deprecated](/en/guides/upgrade-to/v5/#deprecated-functionperroute-adapter-api). That meant that `entryPoints` on the `astro:build:ssr` hook was always empty. + +Astro 6.0 removes the `entryPoints` map passed to this hook entirely. + +#### What should I do? + +Remove any instance of `entryPoints` passed to `astro:build:ssr`: + +```js title="my-integration.mjs" del={6} +const integration = () => { + return { + name: 'my-integration', + hooks: { + 'astro:build:ssr': (params) => { + someLogic(params.entryPoints) + }, + } + } +} +``` + ## Changed Defaults Some default behavior has changed in Astro v5.0 and your project code may need updating to account for these changes. diff --git a/src/content/docs/en/reference/adapter-reference.mdx b/src/content/docs/en/reference/adapter-reference.mdx index de3542df0e71f..6e8d70220ecb6 100644 --- a/src/content/docs/en/reference/adapter-reference.mdx +++ b/src/content/docs/en/reference/adapter-reference.mdx @@ -322,7 +322,7 @@ If not provided, Astro will fallback to its default behavior for fetching error **Default:** `app.match(request)`

    -Provide a value for [`integrationRouteData`](/en/reference/integrations-reference/#integrationroutedata-type-reference) if you already know the route to render. Doing so will bypass the internal call to [`app.match`](#appmatch) to determine the route to render. +Provide a value for `integrationRouteData` if you already know the route to render. Doing so will bypass the internal call to [`app.match`](#appmatch) to determine the route to render. ```js "routeData" const routeData = app.match(request); diff --git a/src/content/docs/en/reference/integrations-reference.mdx b/src/content/docs/en/reference/integrations-reference.mdx index b24c204fa85ea..effb14d6da7c6 100644 --- a/src/content/docs/en/reference/integrations-reference.mdx +++ b/src/content/docs/en/reference/integrations-reference.mdx @@ -79,7 +79,6 @@ interface AstroIntegration { }) => void | Promise; 'astro:build:ssr'?: (options: { manifest: SerializedSSRManifest; - entryPoints: Map; middlewareEntryPoint: URL | undefined; logger: AstroIntegrationLogger; }) => void | Promise; @@ -1036,13 +1035,11 @@ export default { **When:** After a production SSR build has completed. **Why:** To access the SSR manifest and map of the emitted entry points. This is useful when creating custom SSR builds in plugins or integrations. -- `entryPoints` maps a page route to the physical file emitted after the build; - `middlewareEntryPoint` is the file system path of the middleware file; ```js 'astro:build:ssr'?: (options: { manifest: SerializedSSRManifest; - entryPoints: Map; middlewareEntryPoint: URL | undefined; logger: AstroIntegrationLogger; }) => void | Promise; @@ -1071,29 +1068,6 @@ export default { } ``` -#### `entryPoints` option - -

    - -**Type:** Map\<IntegrationRouteData, URL\>
    - -

    - -A `Map` of the emitted entry points with the `IntegrationRouteData` as key and the physical file URL as value. - -```js -export default { - name: 'my-integration', - hooks: { - 'astro:build:ssr': ({ entryPoints }) => { - entryPoints.forEach((url) => { - console.log(url.href); - }); - }, - }, -} -``` - #### `middlewareEntryPoint` option

    @@ -1173,8 +1147,6 @@ export default { 'astro:build:done'?: (options: { pages: { pathname: string }[]; dir: URL; - /** @deprecated Use the `assets` map and the new `astro:routes:resolved` hook */ - routes: IntegrationRouteData[]; assets: Map; logger: AstroIntegrationLogger; }) => void | Promise; @@ -1207,24 +1179,6 @@ export default function myIntegration() { } ``` -#### `routes` option - -:::caution -This property is deprecated since v5.0. Check the [migration guide](/en/guides/upgrade-to/v5/#deprecated-routes-on-astrobuilddone-hook-integration-api). -::: - -

    - -**Type:** [`IntegrationRouteData[]`](#integrationroutedata-type-reference) -

    - -A list of all generated routes alongside their associated metadata. - -You can reference the full `IntegrationRouteData` type below, but the most common properties are: - -- `component` - the input file path relative to the project root -- `pathname` - the output file URL (undefined for routes using `[dynamic]` and `[...spread]` params) - #### `assets` option

    @@ -1496,146 +1450,6 @@ Allows you to access the route to redirect to. This can be a string or an object Determines if a route comes from Astro core (`internal`), an integration (`external`) or the user's project (`project`). -### `IntegrationRouteData` type reference - -:::caution -This type is deprecated since v5.0. Use [`IntegrationResolvedRoute`](#integrationresolvedroute-type-reference) instead. -::: - -A smaller version of the `RouteData` that is used in the integrations. - -```ts -interface IntegrationRouteData { - type: RouteType; - component: string; - pathname?: string; - pattern: RegExp; - params: string[]; - segments: { content: string; dynamic: boolean; spread: boolean; }[][]; - generate: (data?: any) => string; - prerender: boolean; - distURL?: URL[]; - redirect?: RedirectConfig; - redirectRoute?: IntegrationRouteData; -} -``` - -#### `type` - -

    - -**Type:** `RouteType` -

    - -Allows you to identify the type of the route. The value can be: -- `page`: a route that lives in the file system, usually an Astro component -- `endpoint`: a route that lives in the file system, usually a JS file that exposes endpoints methods -- `redirect`: a route that points to another route that lives in the file system -- `fallback`: a route that doesn't exist in the file system and needs to be handled with other means, usually middleware - -#### `component` - -

    - -**Type:** `string` -

    - -Allows you to access the source component URL pathname. - -#### `pathname` - -

    - -**Type:** `string | undefined` -

    - -For regular routes, the value will be the URL pathname where this route will be served. When the project uses [dynamic routes](/en/guides/routing/#dynamic-routes) (ie. `[dynamic]` or `[...spread]`), the pathname will be undefined. - -#### `pattern` - -

    - -**Type:** `RegExp` -

    - -Allows you to access a regex used for matching an input URL against a requested route. - -For example, given a `[fruit]/about.astro` path, the regex will be `/^\/([^/]+?)\/about\/?$/`. Using `pattern.test("banana/about")` will return `true`. - -#### `params` - -

    - -**Type:** `string[]` -

    - -Allows you to access the route `params`. For example, when a project uses the following [dynamic routes](/en/guides/routing/#dynamic-routes) `/pages/[lang]/[...slug].astro`, the value will be `['lang', '...slug']`. - -#### `segments` - -

    - -**Type:** `{ content: string; dynamic: boolean; spread: boolean; }[][]` -

    - -Allows you to access the route [`params`](#params-1) with additional metadata. Each object contains the following properties: -* `content`: the `param`, -* `dynamic`: whether the route is dynamic or not, -* `spread`: whether the dynamic route uses the spread syntax or not. - -For example, the following route `/pages/[lang]/index.astro` will output the segments `[[ { content: 'lang', dynamic: true, spread: false } ]]`. - -#### `generate()` - -

    - -**Type:** `(data?: any) => string` -

    - -A function that provides the optional parameters of the route, interpolates them with the route pattern, and returns the path name of the route. - -For example, with a route such as `/blog/[...id].astro`, the `generate` function could return: - -```js -console.log(generate({ id: 'presentation' })) // will log `/blog/presentation` -``` - -#### `prerender` - -

    - -**Type:** `boolean` -

    - -Determines whether the route is prerendered or not. - -#### `distURL` - -

    - -**Type:** `URL[] | undefined` -

    - -The paths of the physical files emitted by this route. When a route **isn't** prerendered, the value is either `undefined` or an empty array. - -#### `redirect` - -

    - -**Type:** RedirectConfig | undefined -

    - -Allows you to access the route to redirect to. This can be a string or an object containing information about the status code and its destination. - -#### `redirectRoute` - -

    - -**Type:** `IntegrationRouteData | undefined` -

    - -When the value of `RouteData.type` is `redirect`, the value will contains the `IntegrationRouteData` of the route to redirect to. Otherwise, the value will be undefined. - ## Allow installation with `astro add` [The `astro add` command](/en/reference/cli-reference/#astro-add) allows users to easily add integrations and adapters to their project. If you want _your_ integration to be installable with this tool, **add `astro-integration` to the `keywords` field in your `package.json`**: diff --git a/src/content/docs/es/guides/internationalization.mdx b/src/content/docs/es/guides/internationalization.mdx index 7217fa1ddce44..8e39333bc74a3 100644 --- a/src/content/docs/es/guides/internationalization.mdx +++ b/src/content/docs/es/guides/internationalization.mdx @@ -339,7 +339,6 @@ Esta característica tiene algunas restricciones: - La opción `site` es obligatoria. - La opción `output` debe estar configurada en `"server"`. - No puede haber páginas prerenderizadas individuales. -- La característica del adaptador [`functionPerRoute`](/es/reference/adapter-reference/#functionperroute) no es admitida. Astro depende de los siguientes encabezados para admitir la función: - [`X-Forwarded-Host`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host) y [`Host`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host). Astro usará el primero, y si no está presente, intentará el segundo. - [`X-Forwarded-Proto`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto) y [`URL#protocol`](https://developer.mozilla.org/en-US/docs/Web/API/URL/protocol) de la solicitud del servidor. diff --git a/src/content/docs/es/reference/adapter-reference.mdx b/src/content/docs/es/reference/adapter-reference.mdx index 2e41cf3cdcac1..ab07827f917d1 100644 --- a/src/content/docs/es/reference/adapter-reference.mdx +++ b/src/content/docs/es/reference/adapter-reference.mdx @@ -57,10 +57,6 @@ export interface AstroAdapterFeatures { * Crea una función edge que se comunicará con el middleware de Astro */ edgeMiddleware: boolean; - /** - * Solo SSR. Cada ruta se convierte en su propia función/archivo - */ - functionPerRoute: boolean; } export type SupportsKind = 'unsupported' | 'stable' | 'experimental' | 'deprecated'; @@ -338,89 +334,6 @@ y un error si el servicio utilizado para activos no es compatible con el adaptad Un conjunto de características que cambian la salida de los archivos emitidos. Cuando un adaptador elige habilitar estas características, recibirá información adicional dentro de hooks específicos. -### `functionPerRoute` - -Esta es una característica que se habilita al usar solo SSR. Por defecto, Astro emite un único archivo `entry.mjs`, que se encarga de emitir la página renderizada en cada solicitud. - -Cuando `functionPerRoute` está en `true`, Astro en su lugar creará un archivo separado para cada ruta definida en el proyecto. - -Cada archivo emitido solo renderizará una página. Las páginas se emitirán dentro de un directorio `dist/pages/`, y los archivos emitidos mantendrán las mismas rutas de archivo del directorio `src/pages/`. - -Los archivos dentro del directorio `pages/` de la compilación reflejarán la estructura de directorios de los archivos de página en `src/pages/`, por ejemplo: - - -- dist/ - - pages/ - - blog/ - - entry.\_slug\_.astro.mjs - - entry.about.astro.mjs - - entry.index.astro.mjs - - -Habilita la característica pasando `true` al adaptador. - -```js title="my-adapter.mjs" ins={9-11} -export default function createIntegration() { - return { - name: '@matthewp/my-adapter', - hooks: { - 'astro:config:done': ({ setAdapter }) => { - setAdapter({ - name: '@matthewp/my-adapter', - serverEntrypoint: '@matthewp/my-adapter/server.js', - adapterFeatures: { - functionPerRoute: true - } - }); - }, - }, - }; -} -``` - -Luego, utiliza el hook [`astro:build:ssr`](/es/reference/integrations-reference/#astrobuildssr), que te proporcionará un objeto `entryPoints` que mapea una ruta de página al archivo físico emitido después de la compilación. - -```js title="my-adapter.mjs" ins={15-19} -export default function createIntegration() { - return { - name: '@matthewp/my-adapter', - hooks: { - 'astro:config:done': ({ setAdapter }) => { - setAdapter({ - name: '@matthewp/my-adapter', - serverEntrypoint: '@matthewp/my-adapter/server.js', - adapterFeatures: { - functionPerRoute: true - } - }); - }, - - 'astro:build:ssr': ({ entryPoints }) => { - for (const [route, entryFile] of entryPoints) { - // haz algo con route y entryFile - } - } - }, - }; -} -``` - -:::caution -`entryFile` es de tipo `URL` y representa la ruta física del archivo en el sistema de archivos. Esto significa que las rutas cambian según el sistema operativo en el que se ejecute el código. -::: - -#### Entornos serverless - -Establecer `functionPerRoute: true` en un entorno serverless crea un archivo JavaScript (controlador) para cada ruta. El nombre de un controlador puede variar según la plataforma de alojamiento que estés utilizando: lambda, función, página, etc. - -Cada una de estas rutas está sujeta a un [arranque en frío](https://azure.microsoft.com/en-us/blog/understanding-serverless-cold-start/) cuando se ejecuta el controlador, lo que puede causar cierto retraso. Este retraso está influenciado por diferentes factores. - -Con `functionPerRoute: false`, solo hay un controlador único encargado de renderizar todas tus rutas. Cuando se activa este controlador por primera vez, estarás sujeto a un arranque en frío. Después de eso, todas las demás rutas deberían funcionar sin retraso. Sin embargo, perderás el beneficio de la división de código que proporciona `functionPerRoute: true`. - -:::note -Es importante que comprendas tu plataforma de alojamiento y cómo funciona para elegir la configuración adecuada de `functionPerRoute` para tu proyecto. -::: - ### `edgeMiddleware` Define si se incluirá el código de middleware SSR al realizar la compilación. diff --git a/src/content/docs/ja/reference/adapter-reference.mdx b/src/content/docs/ja/reference/adapter-reference.mdx index 0c1cedbff350c..4ce5749a7338a 100644 --- a/src/content/docs/ja/reference/adapter-reference.mdx +++ b/src/content/docs/ja/reference/adapter-reference.mdx @@ -57,10 +57,6 @@ export interface AstroAdapterFeatures { * Astroミドルウェアと通信するエッジ関数を作成します。 */ edgeMiddleware: boolean; - /** - * SSR専用。各ルートが個別の関数/ファイルになります。 - */ - functionPerRoute: boolean; } export type SupportsKind = 'unsupported' | 'stable' | 'experimental' | 'deprecated'; @@ -245,7 +241,7 @@ try { ###### `routeData`オプション -レンダリングするルートが事前に分かっている場合は、このオプションで[`routeData`](/ja/reference/integrations-reference/#integrationroutedata-type-reference)を指定できます。これにより、ルートを決定するための[`app.match`](#appmatchrequestメソッド)の内部呼び出しをスキップできます。 +レンダリングするルートが事前に分かっている場合は、このオプションで`routeData`を指定できます。これにより、ルートを決定するための[`app.match`](#appmatchrequestメソッド)の内部呼び出しをスキップできます。 ```js "routeData" const routeData = app.match(request); @@ -335,89 +331,6 @@ export default function createIntegration() { アダプターの機能は、出力されるファイルの内容を変更する一連の機能です。アダプターがこれらの機能を有効にすると、特定のフック内で追加情報を取得できます。 -### `functionPerRoute`機能 - -この機能は、SSR(サーバーサイドレンダリング)を使用する場合にのみ有効になります。デフォルトでは、Astroは単一の`entry.mjs`ファイルを生成し、このファイルが各リクエストに対してレンダリングされたページを出力します。 - -`functionPerRoute`を`true`に設定すると、Astroはプロジェクトで定義された各ルートに対して個別のファイルを作成します。 - -生成される各ファイルは1つのページのみをレンダリングします。これらのページファイルは`dist/pages/`ディレクトリ(または[`outDir`](/ja/reference/configuration-reference/#outdir)で指定されたディレクトリ内の`/pages/`)に出力され、`src/pages/`ディレクトリと同じファイル構造を維持します。 - -例えば、`pages/`ディレクトリ内のファイル構造は、ビルド後の`src/pages/`のページファイルの構造を反映します。 - - -- dist/ - - pages/ - - blog/ - - entry.\_slug\_.astro.mjs - - entry.about.astro.mjs - - entry.index.astro.mjs - - -この機能を有効にするには、アダプターに`true`を渡します。 - -```js title="my-adapter.mjs" ins={9-11} -export default function createIntegration() { - return { - name: '@matthewp/my-adapter', - hooks: { - 'astro:config:done': ({ setAdapter }) => { - setAdapter({ - name: '@matthewp/my-adapter', - serverEntrypoint: '@matthewp/my-adapter/server.js', - adapterFeatures: { - functionPerRoute: true - } - }); - }, - }, - }; -} -``` - -その後、[`astro:build:ssr`](/ja/reference/integrations-reference/#astrobuildssr)フックを使用します。このフックは`entryPoints`オブジェクトを提供し、ページのルートとビルド後に生成された実際のファイルをマッピングします。 - -```js title="my-adapter.mjs" ins={15-19} -export default function createIntegration() { - return { - name: '@matthewp/my-adapter', - hooks: { - 'astro:config:done': ({ setAdapter }) => { - setAdapter({ - name: '@matthewp/my-adapter', - serverEntrypoint: '@matthewp/my-adapter/server.js', - adapterFeatures: { - functionPerRoute: true - } - }); - }, - - 'astro:build:ssr': ({ entryPoints }) => { - for (const [route, entryFile] of entryPoints) { - // routeとentryFileを使用して何かをする - } - } - }, - }; -} -``` - -:::caution -`entryFile`は`URL`型で、ファイルシステム上の実際のファイルパスを表します。つまり、コードが実行されるOSによってパスが変わる可能性があります。 -::: - -#### サーバーレス環境での動作について - -サーバーレス環境で`functionPerRoute: true`を設定すると、各ルートに対して個別のJavaScriptファイル(ハンドラー)が作成されます。このハンドラーは、使用するホスティングプラットフォームによってlambda、function、pageなど、さまざまな名前で呼ばれることがあります。 - -これらの各ルートは、ハンドラーが実行される際に[コールドスタート](https://azure.microsoft.com/ja-jp/blog/understanding-serverless-cold-start/)の影響を受ける可能性があり、これにより多少の遅延が生じることがあります。この遅延の程度はさまざまな要因に左右されます。 - -一方、`functionPerRoute: false`に設定した場合、すべてのルートのレンダリングを1つのハンドラーが担当します。このハンドラーが最初に呼び出されるときにはコールドスタートの影響を受けますが、それ以降のルートは遅延なく機能するはずです。ただし、この設定では`functionPerRoute: true`で得られるコード分割の利点は失われてしまいます。 - -:::note -プロジェクトに最適な`functionPerRoute`の設定を選択するためには、使用するホスティングプラットフォームの仕組みをよく理解することが重要です。 -::: - ### `edgeMiddleware`機能について この機能は、SSR(サーバーサイドレンダリング)のミドルウェアコードをビルド時にバンドル(まとめて)するかどうかを指定します。 diff --git a/src/content/docs/ko/guides/upgrade-to/v5.mdx b/src/content/docs/ko/guides/upgrade-to/v5.mdx index 0004c96a2cd2f..7ad1c774516c5 100644 --- a/src/content/docs/ko/guides/upgrade-to/v5.mdx +++ b/src/content/docs/ko/guides/upgrade-to/v5.mdx @@ -1106,7 +1106,7 @@ function useRoute(route: IntegrationRouteData) { } ``` -[`IntegrationRouteData`에 대한 API 참조](/ko/reference/integrations-reference/#integrationroutedata-타입-참조)를 확인하세요. +`IntegrationRouteData`에 대한 API 참조를 확인하세요. ### 변경됨: `distURL`은 이제 배열입니다 (통합 API) @@ -1133,7 +1133,7 @@ if (route.distURL) { } ``` -[`IntegrationRouteData`에 대한 API 참조](/ko/reference/integrations-reference/#integrationroutedata-타입-참조)를 확인하세요. +`IntegrationRouteData`에 대한 API 참조를 확인하세요. ### 변경됨: `app.render()`에 전달되는 인수 (어댑터 API) diff --git a/src/content/docs/ko/reference/adapter-reference.mdx b/src/content/docs/ko/reference/adapter-reference.mdx index c4781f802909d..972f3db6dcc16 100644 --- a/src/content/docs/ko/reference/adapter-reference.mdx +++ b/src/content/docs/ko/reference/adapter-reference.mdx @@ -319,7 +319,7 @@ return app.render(request, { **기본값:** `app.match(request)`

    -렌더링할 경로를 이미 알고 있는 경우 [`integrationRouteData`](/ko/reference/integrations-reference/#integrationroutedata-타입-참조)에 대한 값을 제공하세요. 그렇게 하면 렌더링할 경로를 결정하기 위해 [`app.match`](#appmatch)에 대한 내부 호출을 우회하게 됩니다. +렌더링할 경로를 이미 알고 있는 경우 `integrationRouteData`에 대한 값을 제공하세요. 그렇게 하면 렌더링할 경로를 결정하기 위해 [`app.match`](#appmatch)에 대한 내부 호출을 우회하게 됩니다. ```js "routeData" const routeData = app.match(request); diff --git a/src/content/docs/ko/reference/integrations-reference.mdx b/src/content/docs/ko/reference/integrations-reference.mdx index fabca33a94f56..29d0bea5d8825 100644 --- a/src/content/docs/ko/reference/integrations-reference.mdx +++ b/src/content/docs/ko/reference/integrations-reference.mdx @@ -1076,7 +1076,7 @@ export default {

    -**타입:** Map\<IntegrationRouteData, URL\>
    +**타입:** Map\IntegrationRouteData, URL\>

    @@ -1216,7 +1216,7 @@ export default function myIntegration() {

    -**타입:** [`IntegrationRouteData[]`](#integrationroutedata-타입-참조) +**타입:** `IntegrationRouteData[]`

    생성된 모든 경로와 연결된 메타데이터 목록입니다. diff --git a/src/content/docs/pt-br/reference/adapter-reference.mdx b/src/content/docs/pt-br/reference/adapter-reference.mdx index 2a8b910a61b0e..302993d5e6480 100644 --- a/src/content/docs/pt-br/reference/adapter-reference.mdx +++ b/src/content/docs/pt-br/reference/adapter-reference.mdx @@ -54,10 +54,6 @@ export interface AstroAdapterFeatures { * Cria uma função na edge que irá se comunicar com o middleware do Astro. */ edgeMiddleware: boolean; - /** - * SSR apenas. Cada rota se torna sua própria função/arquivo. - */ - functionPerRoute: boolean; } export type SupportsKind = 'unsupported' | 'stable' | 'experimental' | 'deprecated'; @@ -293,89 +289,6 @@ e um erro se o serviço usado para assets não é compatível com o adaptador: Um conjunto de funcionalidades que modificam o resultado dos arquivos emitidos. Quando um adaptador opta por essas funcionalidades, ele irá adquirir informação adicional dentro de hooks específicos. -### `functionPerRoute` - -Essa é uma funcionalidade que é habilitada ao utilizar SSR apenas. Por padrão, Astro emite um único arquivo `entry.mjs`, que é responsável por emitir a página renderizada a cada requisição. - -Quando `functionPerRoute` é `true`, Astro irá ao invés disso criar um arquivo separado para cada rota definida no projeto. - -Cada arquivo emitido irá apenas renderizar uma página. As páginas serão emitidas dentro do diretório `dist/pages/` (ou dentro de um diretório `/pages/` no diretório especificado para [`outDir`](/pt-br/reference/configuration-reference/#outdir)), e os arquivos emitidos irão manter o mesmo caminho de arquivo que o diretório `src/pages/`. - -Os arquivos dentro do diretório `pages/` da build refletirão a estrutura do diretório dos seus arquivos de página em `src/pages/`, por exemplo: - - -- dist/ - - pages/ - - blog/ - - entry.\_slug\_.astro.mjs - - entry.sobre.astro.mjs - - entry.index.astro.mjs - - -Habilite essa funcionalidade passando `true` ao adaptador. - -```js title="meu-adaptador.mjs" ins={9-11} -export default function createIntegration() { - return { - name: '@matthewp/meu-adaptador', - hooks: { - 'astro:config:done': ({ setAdapter }) => { - setAdapter({ - name: '@matthewp/meu-adaptador', - serverEntrypoint: '@matthewp/meu-adaptador/server.js', - adapterFeatures: { - functionPerRoute: true - } - }); - }, - }, - }; -} -``` - -Então, consuma o hook [`astro:build:ssr`](/pt-br/reference/integrations-reference/#astrobuildssr), que irá te dar um objeto `entryPoints` que mapeia uma rota de página ao arquivo físico emitido após a build. - -```js title="meu-adaptador.mjs" ins={15-19} -export default function createIntegration() { - return { - name: '@matthewp/meu-adaptador', - hooks: { - 'astro:config:done': ({ setAdapter }) => { - setAdapter({ - name: '@matthewp/meu-adaptador', - serverEntrypoint: '@matthewp/meu-adaptador/server.js', - adapterFeatures: { - functionPerRoute: true - } - }); - }, - - 'astro:build:ssr': ({ entryPoints }) => { - for (const [route, entryFile] of entryPoints) { - // faça algo com a route e entryFile - } - } - }, - }; -} -``` - -:::caution -O `entryFile` é do tipo `URL` e representa o caminho físico do arquivo no sistema de arquivos. Isso significa que os caminhos mudam com base no SO onde o código é executado. -::: - -#### Ambientes Serverless - -Definir `functionPerRoute: true` em um ambiente serverless cria um arquivo JavaScript (handler) para cada rota. Um handler pode terr nomes diferentes com base na sua plataforma de hospedagem: lambda, function, page, etc. - -Cada uma dessas rotas é sujeita a um [cold start](https://azure.microsoft.com/en-us/blog/understanding-serverless-cold-start/) quando o handler é executado, o que pode causar algum delay. Esse delay é influenciado por diferentes fatores. - -Com `functionPerRoute: false`, há apenas um único handler no comando da renderização de todas as suas rotas. Quando esse handler é ativado pela primeira vez, você estará sujeito a um cold start. E então, todas as outras rotas devem funcionar sem delay. Porém, você irá perder o benefício da separação de código que `functionPerRoute: true` fornece. - -:::note -É importante que você entenda sua plataforma de hospedagem, e como ela funciona, para que você escolha a configuração de `functionPerRoute` apropriada para seu projeto. -::: - ### `edgeMiddleware` Define se algum código de middleware SSR passará por bundle ao ser construído. diff --git a/src/content/docs/zh-cn/guides/upgrade-to/v5.mdx b/src/content/docs/zh-cn/guides/upgrade-to/v5.mdx index 242e3e69e245e..2008d5de60019 100644 --- a/src/content/docs/zh-cn/guides/upgrade-to/v5.mdx +++ b/src/content/docs/zh-cn/guides/upgrade-to/v5.mdx @@ -1108,7 +1108,7 @@ function useRoute(route: IntegrationRouteData) { } ``` -请参阅 [`IntegrationRouteData` 的 API 参考](/zh-cn/reference/integrations-reference/#integrationroutedata-类型参考)。 +请参阅 `IntegrationRouteData` 的 API 参考。 ### 改动:`distURL` 现在是一个数组(集成 API) @@ -1135,7 +1135,7 @@ if (route.distURL) { } ``` -请参阅 [`IntegrationRouteData` 的 API 参考](/zh-cn/reference/integrations-reference/#integrationroutedata-类型参考) +请参阅 `IntegrationRouteData` 的 API 参考 ### 改动:传递给 `app.render()` 的参数(适配器 API) diff --git a/src/content/docs/zh-cn/reference/adapter-reference.mdx b/src/content/docs/zh-cn/reference/adapter-reference.mdx index f0c028a13370a..078a479d40813 100644 --- a/src/content/docs/zh-cn/reference/adapter-reference.mdx +++ b/src/content/docs/zh-cn/reference/adapter-reference.mdx @@ -322,7 +322,7 @@ return app.render(request, { **默认值:** `app.match(request)`

    -如果你已经知道要渲染的路由,请为 [`integrationRouteData`](/zh-cn/reference/integrations-reference/#integrationroutedata-类型参考) 提供一个值。这样做将绕过内部调用 [`app.match`](#appmatch) 来确定要渲染的路由。 +如果你已经知道要渲染的路由,请为 `integrationRouteData` 提供一个值。这样做将绕过内部调用 [`app.match`](#appmatch) 来确定要渲染的路由。 ```js "routeData" const routeData = app.match(request); diff --git a/src/content/docs/zh-cn/reference/integrations-reference.mdx b/src/content/docs/zh-cn/reference/integrations-reference.mdx index d7436f179326f..4f53b4ff6334b 100644 --- a/src/content/docs/zh-cn/reference/integrations-reference.mdx +++ b/src/content/docs/zh-cn/reference/integrations-reference.mdx @@ -612,7 +612,7 @@ function setPrerender() {

    -**类型:** [`IntegrationResolvedRoute[]`](#integrationroutedata-类型参考) +**类型:** `IntegrationResolvedRoute[]`

    一个包含了所有路由及其关联元数据的列表。 @@ -1074,7 +1074,7 @@ export default {

    -**类型:** Map\<IntegrationRouteData, URL\>
    +**类型:** Map\IntegrationRouteData, URL\>

    @@ -1214,7 +1214,7 @@ export default function myIntegration() {

    -**类型:** [`IntegrationRouteData[]`](#integrationroutedata-类型参考) +**类型:** `IntegrationRouteData[]`

    所有生成的路由及其相关元数据的列表。 From 43e911647aea937eef4a3d1e496a48e0a7bbaede Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Wed, 1 Oct 2025 17:32:35 +0200 Subject: [PATCH 13/22] [v6] deprecate import.meta.env.ASSETS_PREFIX (#12468) Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> --- .../docs/en/guides/environment-variables.mdx | 1 - src/content/docs/en/guides/upgrade-to/v6.mdx | 24 ++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/content/docs/en/guides/environment-variables.mdx b/src/content/docs/en/guides/environment-variables.mdx index c5184a78b58e4..bf227065c1a31 100644 --- a/src/content/docs/en/guides/environment-variables.mdx +++ b/src/content/docs/en/guides/environment-variables.mdx @@ -58,7 +58,6 @@ Astro includes a few environment variables out of the box: - `import.meta.env.DEV`: `true` if your site is running in development; `false` otherwise. Always the opposite of `import.meta.env.PROD`. - `import.meta.env.BASE_URL`: The base URL your site is being served from. This is determined by the [`base` config option](/en/reference/configuration-reference/#base). - `import.meta.env.SITE`: This is set to [the `site` option](/en/reference/configuration-reference/#site) specified in your project's `astro.config`. -- `import.meta.env.ASSETS_PREFIX`: The prefix for Astro-generated asset links if the [`build.assetsPrefix` config option](/en/reference/configuration-reference/#buildassetsprefix) is set. This can be used to create asset links not handled by Astro. Use them like any other environment variable. diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 15aeac1e474a8..533c986a95a61 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -105,7 +105,7 @@ The following deprecated features are no longer supported and are no longer docu Some deprecated features may temporarily continue to function until they are completely removed. Others may silently have no effect, or throw an error prompting you to update your code. -### `Astro` in `getStaticPaths()` +### Deprecated: `Astro` in `getStaticPaths()` @@ -131,6 +131,28 @@ export async function getStaticPaths() { Read more about [built-in environment variables such as `import.meta.env.SITE`](/en/guides/environment-variables/#default-environment-variables) that are accessible when [using `getStaticPaths()` to dynamically generate static routes](/en/guides/routing/#static-ssg-mode). +### Deprecated: `import.meta.env.ASSETS_PREFIX` + + + +In Astro 5.x, it was possible to access `build.assetsPrefix` in your Astro config via the built-in environment variable `import.meta.env.ASSETS_PREFIX`. However, Astro v5.7.0 introduced the `astro:config` virtual model to expose a non-exhaustive, serializable, type-safe version of the Astro configuration which included access to `build.assetsPrefix` directly. This became the preferred way to access the prefix for Astro-generated asset links when set, although the environment variable still existed. + +Astro 6.0 deprecates this variable in favor of `build.assetsPrefix` from the `astro:config/server` module. + +#### What should I do? + +Replace any occurances of `import.meta.env.ASSETS_PREFIX` with the `build.assetsPrefix` import from `astro:config/server`. This is a drop-in replacement to provide the existing value, and no other changes to your code should be necessary: + +```ts del={4} ins={2,5} +import { someLogic } from "./utils" +import { build } from "astro:config/server" + +someLogic(import.meta.env.ASSETS_PREFIX) +someLogic(build.assetsPrefix) +``` + +Read more about the [`astro:config` virtual modules](/en/reference/modules/astro-config/). + ## Removed The following features have now been entirely removed from the code base and can no longer be used. Some of these features may have continued to work in your project even after deprecation. Others may have silently had no effect. From e84033316ce4db7766a1f2c7eec4e8f17da13333 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Wed, 1 Oct 2025 17:40:35 +0200 Subject: [PATCH 14/22] [v6] clean deprecated APIs (#12469) Co-authored-by: Armand Philippot Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> --- src/content/docs/en/guides/upgrade-to/v6.mdx | 68 ++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 533c986a95a61..497a12e45e201 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -301,6 +301,74 @@ const integration = () => { } ``` +### Removed: old `app.render()` signature (Adapter API) + + + +In Astro 4.0, the `app.render()` signature that allowed passing `routeData` and `locals` as optional arguments was deprecated in favor of a single optional `renderOptions` argument. + +Astro 6.0 removes this signature entirely. Attempting to pass these separate arguments will now cause an error in your project. + +#### What should I do? + +Review your `app.render` calls and pass `routeData` and `locals` as properties of an object instead of as multiple independent arguments: + +```ts title="my-adapter/entrypoint.ts" del={1} ins={2} +app.render(request, routeData, locals) +app.render(request, { routeData, locals }) +``` + +Learn more about the [Adapter API](/en/reference/adapter-reference/). + +### Removed: `handleForms` prop for the `` component + + + +In Astro 4.0, the `handleForms` prop of the `` component was deprecated, as it was no longer necessary to opt in to handling `submit` events for `form` elements. This functionality has been built-in by default and the property, if still included in your project, silently had no impact on form submission. + +Astro 6.0 removes this prop entirely and it now must be removed to avoid errors in your project. + +#### What should I do? + +Remove the `handleForms` property from your `` component if it exists. It has provided no additional functionality, and so removing it should not change any behavior in your project: + +```astro title="src/pages/index.astro" del="handleForms" +--- +import { ClientRouter } from "astro:transitions"; +--- + + + + + + + + +``` + +Learn more about [transitions with forms](/en/guides/view-transitions/#transitions-with-forms). + +### Removed: `prefetch()` `with` option + + + +In Astro 4.8.4, the `with` option of the programmatic `prefetch()` function was deprecated in favor of a more sensible default behavior that no longer required specifying the priority of prefetching for each page. + +Astro 6.0 removes this option entirely and it is no longer possible to configure the priority of prefetching by passing the `with` option. Attempting to do so will now cause errors. + +By default, Astro's prefetching now uses an automatic approach that will always try to use ` {...} ``` +Note that endpoints whose URLs include a file extension (e.g. `src/pages/sitemap.xml.ts`) can only be accessed without a trailing slash (e.g. `/sitemap.xml`), regardless of your [`build.trailingSlash`](/en/reference/configuration-reference/#trailingslash) configuration. + ### `params` and Dynamic routing Endpoints support the same [dynamic routing](/en/guides/routing/#dynamic-routes) features that pages do. Name your file with a bracketed parameter name and export a [`getStaticPaths()` function](/en/reference/routing-reference/#getstaticpaths). Then, you can access the parameter using the `params` property passed to the endpoint function: diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 497a12e45e201..5fffa64a04815 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -89,6 +89,8 @@ Check that both your development environment and your deployment environment are ### Vite 7.0 + + Astro v6.0 upgrades to Vite v7.0 as the development server and production bundler. #### What should I do? @@ -377,6 +379,8 @@ In most cases, the only action needed is to review your existing project's deplo ### Changed: `i18n.routing.redirectToDefaultLocale` default value + + In Astro v5.0, the `i18n.routing.redirectToDefaultLocale` default value was `true`. When combined with the `i18n.routing.prefixDefaultLocale` default value of `false`, the resulting redirects could cause infinite loops. In Astro v6.0, `i18n.routing.redirectToDefaultLocale` now defaults to `false`. Additionally, it can now only be used if `i18n.routing.prefixDefaultLocale` is set to `true`. @@ -404,6 +408,25 @@ export default defineConfig({ The following changes are considered breaking changes in Astro v5.0. Breaking changes may or may not provide temporary backwards compatibility. If you were using these features, you may have to update your code as recommended in each entry. +### Changed: endpoints with a file extension cannot be accessed with a trailing slash + + + +In Astro v5.0, custom endpoints whose URL ended in a file extension (e.g. `/src/pages/sitemap.xml.ts` ) could be accessed with a trailing slash (`/sitemap.xml/`) or without (`/sitemap.xml`), regardless of the value configured for `build.trailingSlash`. + +In Astro v6.0, these endpoints can only be accessed without a trailing slash. This is true regardless of your `build.trailingSlash` configuration. + +#### What should I do? + +Review your links to your custom endpoints that include a file extension in the URL and remove any trailing slashes: + +```html del={1} ins={2} title="src/pages/index.astro" +Sitemap +Sitemap +``` + +Learn more about [custom endpoints](/en/guides/endpoints/). + ## Community Resources Know a good resource for Astro v5.0? [Edit this page](https://github.com/withastro/docs/edit/main/src/content/docs/en/guides/upgrade-to/v6.mdx) and add a link below! From 844769b03b3dd494d4dab8d155b9e577462c3780 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 2 Oct 2025 11:17:40 +0200 Subject: [PATCH 16/22] fix: diff --- src/content/docs/en/guides/upgrade-to/v6.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 5fffa64a04815..975dd27eb5663 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -364,7 +364,7 @@ By default, Astro's prefetching now uses an automatic approach that will always Review your `prefetch()` calls and remove the `with` option if it still exists: -```ts +```ts del={1} ins={2} prefetch('/about', { with: 'fetch' }); prefetch('/about'); ``` From e397c236b6361238de359864f302b5f35ed8ab36 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 2 Oct 2025 13:55:51 +0200 Subject: [PATCH 17/22] fix: typo --- src/content/docs/en/guides/upgrade-to/v6.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 975dd27eb5663..0720edb7d4289 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -326,7 +326,7 @@ app.render(request, { routeData, locals }) -In Astro 4.0, the `handleForms` prop of the `` component was deprecated, as it was no longer necessary to opt in to handling `submit` events for `form` elements. This functionality has been built-in by default and the property, if still included in your project, silently had no impact on form submission. +In Astro 4.0, the `handleForms` prop of the `` component was deprecated, as it was no longer necessary to opt in to handling `submit` events for `form` elements. This functionality has been built in by default and the property, if still included in your project, silently had no impact on form submission. Astro 6.0 removes this prop entirely and it now must be removed to avoid errors in your project. From 31685a28c2a8850341c0e562e4a164d3eafe8733 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Fri, 3 Oct 2025 13:54:42 +0200 Subject: [PATCH 18/22] [v6] stabilize experimental.preserveScriptOrder option (#12480) Co-authored-by: Louis Escher <66965600+louisescher@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> --- astro.sidebar.ts | 1 - src/content/docs/en/guides/upgrade-to/v6.mdx | 71 ++++++++++++++++ .../preserve-scripts-order.mdx | 81 ------------------- .../preserve-scripts-order.mdx | 80 ------------------ .../preserve-scripts-order.mdx | 81 ------------------- .../preserve-scripts-order.mdx | 81 ------------------- .../preserve-scripts-order.mdx | 81 ------------------- 7 files changed, 71 insertions(+), 405 deletions(-) delete mode 100644 src/content/docs/en/reference/experimental-flags/preserve-scripts-order.mdx delete mode 100644 src/content/docs/es/reference/experimental-flags/preserve-scripts-order.mdx delete mode 100644 src/content/docs/fr/reference/experimental-flags/preserve-scripts-order.mdx delete mode 100644 src/content/docs/ko/reference/experimental-flags/preserve-scripts-order.mdx delete mode 100644 src/content/docs/zh-cn/reference/experimental-flags/preserve-scripts-order.mdx diff --git a/astro.sidebar.ts b/astro.sidebar.ts index d687faf69ba66..8ca2eb0b25a76 100644 --- a/astro.sidebar.ts +++ b/astro.sidebar.ts @@ -147,7 +147,6 @@ export const sidebar = [ 'reference/experimental-flags/live-content-collections', 'reference/experimental-flags/client-prerender', 'reference/experimental-flags/content-intellisense', - 'reference/experimental-flags/preserve-scripts-order', 'reference/experimental-flags/heading-id-compat', 'reference/experimental-flags/static-import-meta-env', 'reference/experimental-flags/chrome-devtools-workspace', diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 0720edb7d4289..736f044897599 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -371,6 +371,37 @@ prefetch('/about'); Learn more about [prefetching](/en/guides/prefetch/). +### Experimental Flags + +The following experimental flags have been removed in Astro v6.0 and these features are available for use: + +- `thing 1` + +Additionally, the following experimental flags have been removed and **are now the default or recommended behavior in Astro v6.0**. + +- `experimental.preserveScriptOrder` (See below for breaking changes to [default ` + +``` + +Read more about [using `script`](/en/guides/client-side-scripts/) and [`style`](/en/guides/styling/) tags. + ## Breaking Changes The following changes are considered breaking changes in Astro v5.0. Breaking changes may or may not provide temporary backwards compatibility. If you were using these features, you may have to update your code as recommended in each entry. diff --git a/src/content/docs/en/reference/experimental-flags/preserve-scripts-order.mdx b/src/content/docs/en/reference/experimental-flags/preserve-scripts-order.mdx deleted file mode 100644 index 429fb416c60d5..0000000000000 --- a/src/content/docs/en/reference/experimental-flags/preserve-scripts-order.mdx +++ /dev/null @@ -1,81 +0,0 @@ ---- -title: Experimental preserve scripts order -sidebar: - label: Preserve scripts order -i18nReady: true ---- - -import Since from '~/components/Since.astro' - -

    - - **Type:** `boolean`
    - **Default:** `false`
    - -

    - -Renders multiple ` - - - -``` - -After compiling, Astro's default behavior will create an inline style where `yellow` appears first, and then `red`. This means the `red` background is applied. Similarly with the two scripts, the word `world!` is logged first, and then `hello` second: - -```css -body {background:#ff0} body {background:red} -``` - -```js -console.log("world!") -console.log("hello") -``` - -When `experimental.preserveScriptOrder` is set to `true`, the rendering order of ` - - - -``` - -Después de la compilación, el comportamiento predeterminado de Astro creará un estilo en línea donde `yellow` aparece primero, y luego `red`. Esto significa que se aplica el fondo `red`. De manera similar con los dos scripts, la palabra `world!` se registra primero, y luego `hello` en segundo lugar: - -```css -body {background:#ff0} body {background:red} -``` - -```js -console.log("world!") -console.log("hello") -``` - -Cuando `experimental.preserveScriptOrder` se establece en `true`, el orden de renderizado de las etiquetas ` - - - -``` - -Après la compilation, le comportement par défaut d'Astro crée un style en ligne où `yellow` apparaît en premier, puis `red`. Cela signifie que l'arrière-plan `red` est appliqué. De même, avec les deux scripts, le mot `world!` est affiché en premier, suivi de `hello` : - -```css -body {background:#ff0} body {background:red} -``` - -```js -console.log("world!") -console.log("hello") -``` - -Lorsque `experimental.preserveScriptOrder` est définie sur `true`, l'ordre de restitution des balises ` - - - -``` - -컴파일 후 Astro의 기본 동작은 `yellow`가 먼저 나타나고 `red`가 다음에 나타나는 인라인 스타일을 생성합니다. 이는 `red` 배경이 적용됨을 의미합니다. 두 스크립트의 경우 `world!`가 먼저 기록되고 `hello`가 다음에 기록됩니다. - -```css -body {background:#ff0} body {background:red} -``` - -```js -console.log("world!") -console.log("hello") -``` - -`experimental.preserveScriptOrder`가 `true`로 설정되면 ` - - - -``` - -在编译后,Astro 的默认行为会创建一个内联样式,其中 `yellow` 首先出现,然后是 `red`。这意味着最终应用的是 `red` 背景。类似地,对于两个脚本,会先打印 `world!`,然后是 `hello`: - -```css -body {background:#ff0} body {background:red} -``` - -```js -console.log("world!") -console.log("hello") -``` - -当 `experimental.preserveScriptOrder` 设置为 `true` 时,`