๐ Patch Changes
- #15832
95e12a2Thanks @Princesseuh! - Fixesreturn;syntax not working in the frontmatter correctly in certain contexts
95e12a2 Thanks @Princesseuh! - Fixes return; syntax not working in the frontmatter correctly in certain contextsc2cd371]:
#14446 ece667a Thanks @florian-lefebvre! - Removes entryPoints on astro:build:ssr hook (Integration API) - (v6 upgrade guidance)
#15535 dfe2e22 Thanks @florian-lefebvre! - Deprecates loadManifest() and loadApp() from astro/app/node (Adapter API) - (v6 upgrade guidance)
#15006 f361730 Thanks @florian-lefebvre! - Removes session test driver - (v6 upgrade guidance)
#15461 9f21b24 Thanks @florian-lefebvre! - BREAKING CHANGE to the v6 beta Adapter API only: renames entryType to entrypointResolution and updates possible values
Astro 6 introduced a way to let adapters have more control over the entrypoint by passing entryType: 'self' to setAdapter(). However during beta development, the name was unclear and confusing.
entryType is now renamed to entrypointResolution and its possible values are updated:
legacy-dynamic becomes explicit.self becomes auto.If you are building an adapter with v6 beta and specifying entryType, update it:
setAdapter({ // ... entryType: 'legacy-dynamic' entrypointResolution: 'explicit'})
setAdapter({ // ... entryType: 'self' entrypointResolution: 'auto'})#14426 861b9cc Thanks @florian-lefebvre! - Removes the deprecated emitESMImage() function - (v6 upgrade guidance)
#15006 f361730 Thanks @florian-lefebvre! - Deprecates session driver string signature - (v6 upgrade guidance)
#15180 8780ff2 Thanks @Princesseuh! - Adds support for converting SVGs to raster images (PNGs, WebP, etc) to the default Sharp image service - (v6 upgrade guidance)
#14446 ece667a Thanks @florian-lefebvre! - Removes routes on astro:build:done hook (Integration API) - (v6 upgrade guidance)
#15424 33d6146 Thanks @Princesseuh! - Throws an error when getImage() from astro:assets is called on the client - (v6 upgrade guidance)
#14462 9fdfd4c Thanks @florian-lefebvre! - Removes the old app.render() signature (Adapter API) - (v6 upgrade guidance)
#14956 0ff51df Thanks @matthewp! - Astro v6.0 upgrades to Zod v4 for schema validation - (v6 upgrade guidance)
#14759 d7889f7 Thanks @florian-lefebvre! - Updates how schema types are inferred for content loaders with schemas (Loader API) - (v6 upgrade guidance)
#15192 ada2808 Thanks @gameroman! - Removes support for CommonJS config files - (v6 upgrade guidance)
#14462 9fdfd4c Thanks @florian-lefebvre! - Removes prefetch() with option - (v6 upgrade guidance)
#14306 141c4a2 Thanks @ematipico! - Removes support for routes with percent-encoded percent signs (e.g. %25) - (v6 upgrade guidance)
#14432 b1d87ec Thanks @florian-lefebvre! - Deprecates Astro in getStaticPaths() - (v6 upgrade guidance)
#14759 d7889f7 Thanks @florian-lefebvre! - Removes the option to define dynamic schemas in content loaders as functions and adds a new equivalent createSchema() property (Loader API) - (v6 upgrade guidance)
#14457 049da87 Thanks @florian-lefebvre! - Updates trailing slash behavior of endpoint URLs - (v6 upgrade guidance)
#14494 727b0a2 Thanks @florian-lefebvre! - Updates Markdown heading ID generation - (v6 upgrade guidance)
#14461 55a1a91 Thanks @florian-lefebvre! - Deprecates import.meta.env.ASSETS_PREFIX - (v6 upgrade guidance)
#14586 669ca5b Thanks @ocavue! - Changes the values allowed in params returned by getStaticPaths() - (v6 upgrade guidance)
#15668 1118ac4 Thanks @florian-lefebvre! - Changes TypeScript configuration - (v6 upgrade guidance)
#14421 df6d2d7 Thanks @florian-lefebvre! - Removes the previously deprecated Astro.glob() - (v6 upgrade guidance)
#15049 beddfeb Thanks @Ntale3! - Removes the ability to render Astro components in Vitest client environments - (v6 upgrade guidance)
#15461 9f21b24 Thanks @florian-lefebvre! - Deprecates createExports() and start() (Adapter API) - (v6 upgrade guidance)
#15535 dfe2e22 Thanks @florian-lefebvre! - Deprecates NodeApp from astro/app/node (Adapter API) - (v6 upgrade guidance)
#14462 9fdfd4c Thanks @florian-lefebvre! - Removes the handleForms prop for the <ClientRouter /> component - (v6 upgrade guidance)
#14427 e131261 Thanks @florian-lefebvre! - Increases minimum Node.js version to 22.12.0 - (v6 upgrade guidance)
#15332 7c55f80 Thanks @matthewp! - Adds frontmatter parsing support to renderMarkdown in content loaders. When markdown content includes frontmatter, it is now extracted and available in metadata.frontmatter, and excluded from the HTML output. This makes renderMarkdown behave consistently with the glob loader.
const loader = { name: 'my-loader', load: async ({ store, renderMarkdown }) => { const content = `---title: My Post---
# Hello World`; const rendered = await renderMarkdown(content); // rendered.metadata.frontmatter is now { title: 'My Post' } // rendered.html contains only the content, not the frontmatter },};#14400 c69c7de Thanks @ellielok! - Removes the deprecated <ViewTransitions /> component - (v6 upgrade guidance)
#14306 141c4a2 Thanks @ematipico! - Removes RouteData.generate from the Integration API - (v6 upgrade guidance)
#14406 4f11510 Thanks @florian-lefebvre! - Changes the default routing configuration value of i18n.routing.redirectToDefaultLocale from true to false - (v6 upgrade guidance)
#14989 73e8232 Thanks @florian-lefebvre! - Deprecates exposed astro:transitions internals - (v6 upgrade guidance)
#15726 6f19ecc Thanks @ocavue! - Updates dependency shiki to v4
Check Shikiโs upgrade guide.
#14758 010f773 Thanks @florian-lefebvre! - Removes the setManifestData method from App and NodeApp (Adapter API) - (v6 upgrade guidance)
#14477 25fe093 Thanks @florian-lefebvre! - Removes rewrite() from Actions context - (v6 upgrade guidance)
#14826 170f64e Thanks @florian-lefebvre! - Removes the experimental.failOnPrerenderConflict flag and replaces it with a new configuration option prerenderConflictBehavior - (v6 upgrade guidance)
#14923 95a1969 Thanks @florian-lefebvre! - Deprecates astro:schema and z from astro:content in favor of astro/zod - (v6 upgrade guidance)
#14844 8d43b1d Thanks @trueberryless! - Removes exposed astro:actions internals - (v6 upgrade guidance)
#14306 141c4a2 Thanks @ematipico! - Changes the shape of SSRManifest properties and adds several new required properties in the Adapter API - (v6 upgrade guidance)
#15266 f7c9365 Thanks @florian-lefebvre! - Allows Astro.csp and context.csp to be undefined instead of throwing errors when csp: true is not configured
When using the experimental Content Security Policy feature in Astro 5.x, context.csp was always defined but would throw if experimental.csp was not enabled in the Astro config.
For the stable version of this API in Astro 6, context.csp can now be undefined if CSP is not enabled and its methods will never throw.
If you were using experimental CSP runtime utilities, you must now access methods conditionally:
Astro.csp.insertDirective("default-src 'self'");Astro.csp?.insertDirective("default-src 'self'");#14445 ecb0b98 Thanks @florian-lefebvre! - Astro v6.0 upgrades to Vite v7.0 as the development server and production bundler - (v6 upgrade guidance)
#15407 aedbbd8 Thanks @ematipico! - Changes how styles of responsive images are emitted - (v6 upgrade guidance)
#14306 141c4a2 Thanks @ematipico! - Changes integration hooks and HMR access patterns in the Integration API - (v6 upgrade guidance)
#14306 141c4a2 Thanks @ematipico! - Removes the unused astro:ssr-manifest virtual module - (v6 upgrade guidance)
#14485 6f67c6e Thanks @florian-lefebvre! - Updates import.meta.env values to always be inlined - (v6 upgrade guidance)
#14480 36a461b Thanks @florian-lefebvre! - Updates <script> and <style> tags to render in the order they are defined - (v6 upgrade guidance)
#14407 3bda3ce Thanks @ascorbic! - Removes legacy content collection support - (v6 upgrade guidance)
#14306 141c4a2 Thanks @ematipico! - Adds new optional properties to setAdapter() for adapter entrypoint handling in the Adapter API
Changes:
entryType?: 'self' | 'legacy-dynamic' - determines if the adapter provides its own entrypoint ('self') or if Astro constructs one ('legacy-dynamic', default)Migration: Adapter authors can optionally add these properties to support custom dev entrypoints. If not specified, adapters will use the legacy behavior.
#15700 4e7f3e8 Thanks @ocavue! - Updates the internal logic during SSR by providing additional metadata for UI framework integrations.
#15231 3928b87 Thanks @rururux! - Adds a new optional getRemoteSize() method to the Image Service API.
Previously, inferRemoteSize() had a fixed implementation that fetched the entire image to determine its dimensions.
With this new helper function that extends inferRemoteSize(), you can now override or extend how remote image metadata is retrieved.
This enables use cases such as:
For example, you can add a simple cache layer to your existing image service:
const cache = new Map();
const myService = { ...baseService, async getRemoteSize(url, imageConfig) { if (cache.has(url)) return cache.get(url);
const result = await baseService.getRemoteSize(url, imageConfig); cache.set(url, result); return result; },};See the Image Services API reference documentation for more information.
#15077 a164c77 Thanks @matthewp! - Updates the Integration API to add setPrerenderer() to the astro:build:start hook, allowing adapters to provide custom prerendering logic.
The new API accepts either an AstroPrerenderer object directly, or a factory function that receives the default prerenderer:
'astro:build:start': ({ setPrerenderer }) => { setPrerenderer((defaultPrerenderer) => ({ name: 'my-prerenderer', async setup() { // Optional: called once before prerendering starts }, async getStaticPaths() { // Returns array of { pathname: string, route: RouteData } return defaultPrerenderer.getStaticPaths(); }, async render(request, { routeData }) { // request: Request // routeData: RouteData // Returns: Response }, async teardown() { // Optional: called after all pages are prerendered } }));}Also adds the astro:static-paths virtual module, which exports a StaticPaths class for adapters to collect all prerenderable paths from within their target runtime. This is useful when implementing a custom prerenderer that runs in a non-Node environment:
// In your adapter's request handler (running in target runtime)import { App } from 'astro/app';import { StaticPaths } from 'astro:static-paths';
export function createApp(manifest) { const app = new App(manifest);
return { async fetch(request) { const { pathname } = new URL(request.url);
// Expose endpoint for prerenderer to get static paths if (pathname === '/__astro_static_paths') { const staticPaths = new StaticPaths(app); const paths = await staticPaths.getAll(); return new Response(JSON.stringify({ paths })); }
// Normal request handling return app.render(request); }, };}See the adapter reference for more details on implementing a custom prerenderer.
#15345 840fbf9 Thanks @matthewp! - Adds a new emitClientAsset function to astro/assets/utils for integration authors. This function allows emitting assets that will be moved to the client directory during SSR builds, useful for assets referenced in server-rendered content that need to be available on the client.
import { emitClientAsset } from 'astro/assets/utils';
// Inside a Vite plugin's transform or load hookconst handle = emitClientAsset(this, { type: 'asset', name: 'my-image.png', source: imageBuffer,});#15460 ee7e53f Thanks @florian-lefebvre! - Updates the Adapter API to allow providing a serverEntrypoint when using entryType: 'self'
Astro 6 introduced a new powerful yet simple Adapter API for defining custom server entrypoints. You can now call setAdapter() with the entryType: 'self' option and specify your custom serverEntrypoint:
export function myAdapter() { return { name: 'my-adapter', hooks: { 'astro:config:done': ({ setAdapter }) => { setAdapter({ name: 'my-adapter', entryType: 'self', serverEntrypoint: 'my-adapter/server.js', supportedAstroFeatures: { // ... }, }); }, }, };}If you need further customization at the Vite level, you can omit serverEntrypoint and instead specify your custom server entrypoint with vite.build.rollupOptions.input.
#15781 2de969d Thanks @ematipico! - Adds a new clientAddress option to the createContext() function
Providing this value gives adapter and middleware authors explicit control over the client IP address. When not provided, accessing clientAddress throws an error consistent with other contexts where it is not set by the adapter.
Additionally, both of the official Netlify and Vercel adapters have been updated to provide this information in their edge middleware.
import { createContext } from 'astro/middleware';
createContext({ clientAddress: context.headers.get('x-real-ip'),});#15258 d339a18 Thanks @ematipico! - Stabilizes the adapter feature experimentalStatiHeaders. If you were using this feature in any of the supported adapters, youโll need to change the name of the flag:
export default defineConfig({ adapter: netlify({ experimentalStaticHeaders: true staticHeaders: true })})#15535 dfe2e22 Thanks @florian-lefebvre! - Exports new createRequest() and writeResponse() utilities from astro/app/node
To replace the deprecated NodeApp.createRequest() and NodeApp.writeResponse() methods, the astro/app/node module now exposes new createRequest() and writeResponse() utilities. These can be used to convert a NodeJS IncomingMessage into a web-standard Request and stream a web-standard Response into a NodeJS ServerResponse:
import { createApp } from 'astro/app/entrypoint';import { createRequest, writeResponse } from 'astro/app/node';import { createServer } from 'node:http';
const app = createApp();
const server = createServer(async (req, res) => { const request = createRequest(req); const response = await app.render(request); await writeResponse(response, res);});#15755 f9ee868 Thanks @matthewp! - Adds a new security.serverIslandBodySizeLimit configuration option
Server island POST endpoints now enforce a body size limit, similar to the existing security.actionBodySizeLimit for Actions. The new option defaults to 1048576 (1 MB) and can be configured independently.
Requests exceeding the limit are rejected with a 413 response. You can customize the limit in your Astro config:
export default defineConfig({ security: { serverIslandBodySizeLimit: 2097152, // 2 MB },});#15529 a509941 Thanks @florian-lefebvre! - Adds a new build-in font provider npm to access fonts installed as NPM packages
You can now add web fonts specified in your package.json through Astroโs type-safe Fonts API. The npm font provider allows you to add fonts either from locally installed packages in node_modules or from a CDN.
Set fontProviders.npm() as your fonts provider along with the required name and cssVariable values, and add options as needed:
import { defineConfig, fontProviders } from 'astro/config';
export default defineConfig({ experimental: { fonts: [ { name: 'Roboto', provider: fontProviders.npm(), cssVariable: '--font-roboto', }, ], },});See the NPM font provider reference documentation for more details.
#15471 32b4302 Thanks @ematipico! - Adds a new experimental flag queuedRendering to enable a queue-based rendering engine
The new engine is based on a two-pass process, where the first pass traverses the tree of components, emits an ordered queue, and then the queue is rendered.
The new engine does not use recursion, and comes with two customizable options.
Early benchmarks showed significant speed improvements and memory efficiency in big projects.
The new engine can be enabled in your Astro config with experimental.queuedRendering.enabled set to true, and can be further customized with additional sub-features.
export default defineConfig({ experimental: { queuedRendering: { enabled: true, }, },});With the new engine enabled, you now have the option to have a pool of nodes that can be saved and reused across page rendering. Node pooling has no effect when rendering pages on demand (SSR) because these rendering requests donโt share memory. However, it can be very useful for performance when building static pages.
export default defineConfig({ experimental: { queuedRendering: { enabled: true, poolSize: 2000, // store up to 2k nodes to be reused across renderers }, },});The new engine additionally unlocks a new contentCache option. This allows you to cache values of nodes during the rendering phase. This is currently a boolean feature with no further customization (e.g. size of cache) that uses sensible defaults for most large content collections:
When disabled, the pool engine wonโt cache strings, but only types.
export default defineConfig({ experimental: { queuedRendering: { enabled: true, contentCache: true, // enable re-use of node values }, },});For more information on enabling and using this feature in your project, see the experimental queued rendering docs for more details.
#14888 4cd3fe4 Thanks @OliverSpeir! - Updates astro add cloudflare to better setup types, by adding ./worker-configuration.d.ts to tsconfig includes and a generate-types script to package.json
#15646 0dd9d00 Thanks @delucis! - Removes redundant fetchpriority attributes from the output of Astroโs <Image> component
Previously, Astro would always include fetchpriority="auto" on images not using the priority attribute.
However, this is the default value, so specifying it is redundant. This change omits the attribute by default.
#15291 89b6cdd Thanks @florian-lefebvre! - Removes the experimental.fonts flag and replaces it with a new configuration option fonts - (v6 upgrade guidance)
#15495 5b99e90 Thanks @leekeh! - Adds a new middlewareMode adapter feature to replace the previous edgeMiddleware option.
This feature only impacts adapter authors. If your adapter supports edgeMiddleware, you should upgrade to the new middlewareMode option to specify the middleware mode for your adapter as soon as possible. The edgeMiddleware feature is deprecated and will be removed in a future major release.
export default function createIntegration() { return { name: '@example/my-adapter', hooks: { 'astro:config:done': ({ setAdapter }) => { setAdapter({ name: '@example/my-adapter', serverEntrypoint: '@example/my-adapter/server.js', adapterFeatures: { edgeMiddleware: true middlewareMode: 'edge' } }); }, }, };}#15694 66449c9 Thanks @matthewp! - Adds preserveBuildClientDir option to adapter features
Adapters can now opt in to preserving the client/server directory structure for static builds by setting preserveBuildClientDir: true in their adapter features. When enabled, static builds will output files to build.client instead of directly to outDir.
This is useful for adapters that require a consistent directory structure regardless of the build output type, such as deploying to platforms with specific file organization requirements.
export default function myAdapter() { return { name: 'my-adapter', hooks: { 'astro:config:done': ({ setAdapter }) => { setAdapter({ name: 'my-adapter', adapterFeatures: { buildOutput: 'static', preserveBuildClientDir: true, }, }); }, }, };}#15332 7c55f80 Thanks @matthewp! - Adds a fileURL option to renderMarkdown in content loaders, enabling resolution of relative image paths. When provided, relative image paths in markdown will be resolved relative to the specified file URL and included in metadata.localImagePaths.
const loader = { name: 'my-loader', load: async ({ store, renderMarkdown }) => { const content = `# My Post
`; // Provide a fileURL to resolve relative image paths const fileURL = new URL('./posts/my-post.md', import.meta.url); const rendered = await renderMarkdown(content, { fileURL }); // rendered.metadata.localImagePaths now contains the resolved image path },};#15407 aedbbd8 Thanks @ematipico! - Adds support for responsive images when security.csp is enabled, out of the box.
Astroโs implementation of responsive image styles has been updated to be compatible with a configured Content Security Policy.
Instead of, injecting style elements at runtime, Astro will now generate your styles at build time using a combination of class="" and data-* attributes. This means that your processed styles are loaded and hashed out of the box by Astro.
If you were previously choosing between Astroโs CSP feature and including responsive images on your site, you may now use them together.
#15543 d43841d Thanks @Princesseuh! - Adds a new experimental.rustCompiler flag to opt into the experimental Rust-based Astro compiler
This experimental compiler is faster, provides better error messages, and generally has better support for modern JavaScript, TypeScript, and CSS features.
After enabling in your Astro config, the @astrojs/compiler-rs package must also be installed into your project separately:
import { defineConfig } from 'astro/config';
export default defineConfig({ experimental: { rustCompiler: true, },});This new compiler is still in early development and may exhibit some differences compared to the existing Go-based compiler. Notably, this compiler is generally more strict in regard to invalid HTML syntax and may throw errors in cases where the Go-based compiler would have been more lenient. For example, unclosed tags (e.g. <p>My paragraph) will now result in errors.
For more information about using this experimental feature in your project, especially regarding expected differences and limitations, please see the experimental Rust compiler reference docs. To give feedback on the compiler, or to keep up with its development, see the RFC for a new compiler for Astro for more information and discussion.
#15349 a257c4c Thanks @ascorbic! - Passes collection name to live content loaders
Live content collection loaders now receive the collection name as part of their parameters. This is helpful for loaders that manage multiple collections or need to differentiate behavior based on the collection being accessed.
export function storeLoader({ field, key }) { return { name: 'store-loader', loadCollection: async ({ filter, collection }) => { // ... }, loadEntry: async ({ filter, collection }) => { // ... }, };}#15006 f361730 Thanks @florian-lefebvre! - Adds new session driver object shape
For greater flexibility and improved consistency with other Astro code, session drivers are now specified as an object:
import { defineConfig } from 'astro/config'import { defineConfig, sessionDrivers } from 'astro/config'
export default defineConfig({ session: { driver: 'redis', options: { url: process.env.REDIS_URL }, driver: sessionDrivers.redis({ url: process.env.REDIS_URL }), }})Specifying the session driver as a string has been deprecated, but will continue to work until this feature is removed completely in a future major version. The object shape is the current recommended and documented way to configure a session driver.
#15291 89b6cdd Thanks @florian-lefebvre! - Adds a new Fonts API to provide first-party support for adding custom fonts in Astro.
This feature allows you to use fonts from both your file system and several built-in supported providers (e.g. Google, Fontsource, Bunny) through a unified API. Keep your site performant thanks to sensible defaults and automatic optimizations including preloading and fallback font generation.
To enable this feature, configure fonts with one or more fonts:
import { defineConfig, fontProviders } from 'astro/config';
export default defineConfig({ fonts: [ { provider: fontProviders.fontsource(), name: 'Roboto', cssVariable: '--font-roboto', }, ],});Import and include the <Font /> component with the required cssVariable property in the head of your page, usually in a dedicated Head.astro component or in a layout component directly:
---import { Font } from 'astro:assets';---
<html> <head> <Font cssVariable="--font-roboto" preload /> </head> <body> <slot /> </body></html>In any page rendered with that layout, including the layout component itself, you can now define styles with your fontโs cssVariable to apply your custom font.
In the following example, the <h1> heading will have the custom font applied, while the paragraph <p> will not.
---import Layout from '../layouts/Layout.astro';---
<Layout> <h1>In a galaxy far, far away...</h1>
<p>Custom fonts make my headings much cooler!</p>
<style> h1 { font-family: var('--font-roboto'); } </style></Layout>Visit the updated fonts guide to learn more about adding custom fonts to your project.
#14550 9c282b5 Thanks @ascorbic! - Adds support for live content collections
Live content collections are a new type of content collection that fetch their data at runtime rather than build time. This allows you to access frequently updated data from CMSs, APIs, databases, or other sources using a unified API, without needing to rebuild your site when the data changes.
In Astro 5.0, the content layer API added support for adding diverse content sources to content collections. You can create loaders that fetch data from any source at build time, and then access it inside a page via getEntry() and getCollection(). The data is cached between builds, giving fast access and updates.
However, there was no method for updating the data store between builds, meaning any updates to the data needed a full site deploy, even if the pages are rendered on demand. This meant that content collections were not suitable for pages that update frequently. Instead, these pages tended to access the APIs directly in the frontmatter. This worked, but it led to a lot of boilerplate, and meant users didnโt benefit from the simple, unified API that content loaders offer. In most cases, users tended to individually create loader libraries shared between pages.
Live content collections (introduced experimentally in Astro 5.10) solve this problem by allowing you to create loaders that fetch data at runtime, rather than build time. This means that the data is always up-to-date, without needing to rebuild the site.
To use live collections, create a new src/live.config.ts file (alongside your src/content.config.ts if you have one) to define your live collections with a live content loader using the new defineLiveCollection() function from the astro:content module:
import { defineLiveCollection } from 'astro:content';import { storeLoader } from '@mystore/astro-loader';
const products = defineLiveCollection({ loader: storeLoader({ apiKey: process.env.STORE_API_KEY, endpoint: 'https://api.mystore.com/v1', }),});
export const collections = { products };You can then use the getLiveCollection() and getLiveEntry() functions to access your live data, along with error handling (since anything can happen when requesting live data!):
---import { getLiveCollection, getLiveEntry, render } from 'astro:content';// Get all productsconst { entries: allProducts, error } = await getLiveCollection('products');if (error) { // Handle error appropriately console.error(error.message);}
// Get products with a filter (if supported by your loader)const { entries: electronics } = await getLiveCollection('products', { category: 'electronics' });
// Get a single product by ID (string syntax)const { entry: product, error: productError } = await getLiveEntry('products', Astro.params.id);if (productError) { return Astro.redirect('/404');}
// Get a single product with a custom query (if supported by your loader) using a filter objectconst { entry: productBySlug } = await getLiveEntry('products', { slug: Astro.params.slug });const { Content } = await render(product);---
<h1>{product.data.title}</h1><Content />If you were using the experimental feature, you must remove the experimental.liveContentCollections flag from your astro.config.* file:
export default defineConfig({ // ... experimental: { liveContentCollections: true, },});No other changes to your project code are required as long as you have been keeping up with Astro 5.x patch releases, which contained breaking changes to this experimental feature. If you experience problems with your live collections after upgrading to Astro v6 and removing this flag, please review the Astro CHANGELOG from 5.10.2 onwards for any potential updates you might have missed, or follow the current v6 documentation for live collections.
#15548 5b8f573 Thanks @florian-lefebvre! - Adds a new optional embeddedLangs prop to the <Code /> component to support languages beyond the primary lang
This allows, for example, highlighting .vue files with a <script setup lang="tsx"> block correctly:
---import { Code } from 'astro:components';
const code = `<script setup lang="tsx">const Text = ({ text }: { text: string }) => <div>{text}</div>;</script>
<template> <Text text="hello world" /></template>`;---
<Code {code} lang="vue" embeddedLangs={['tsx']} />See the <Code /> component documentation for more details.
#14826 170f64e Thanks @florian-lefebvre! - Adds an option prerenderConflictBehavior to configure the behavior of conflicting prerendered routes
By default, Astro warns you during the build about any conflicts between multiple dynamic routes that can result in the same output path. For example /blog/[slug] and /blog/[...all] both could try to prerender the /blog/post-1 path. In such cases, Astro renders only the highest priority route for the conflicting path. This allows your site to build successfully, although you may discover that some pages are rendered by unexpected routes.
With the new prerenderConflictBehavior configuration option, you can now configure this further:
prerenderConflictBehavior: 'error' fails the buildprerenderConflictBehavior: 'warn' (default) logs a warning and the highest-priority route winsprerenderConflictBehavior: 'ignore' silently picks the highest-priority route when conflicts occurimport { defineConfig } from 'astro/config';
export default defineConfig({ prerenderConflictBehavior: 'error',});#14946 95c40f7 Thanks @ematipico! - Removes the experimental.csp flag and replaces it with a new configuration option security.csp - (v6 upgrade guidance)
#15579 08437d5 Thanks @ascorbic! - Adds two new experimental flags for a Route Caching API and further configuration-level Route Rules for controlling SSR response caching.
Route caching gives you a platform-agnostic way to cache server-rendered responses, based on web standard cache headers. You set caching directives in your routes using Astro.cache (in .astro pages) or context.cache (in API routes and middleware), and Astro translates them into the appropriate headers or runtime behavior depending on your adapter. You can also define cache rules for routes declaratively in your config using experimental.routeRules, without modifying route code.
This feature requires on-demand rendering. Prerendered pages are already static and do not use route caching.
Enable the feature by configuring experimental.cache with a cache provider in your Astro config:
import { defineConfig } from 'astro/config';import node from '@astrojs/node';import { memoryCache } from 'astro/config';
export default defineConfig({ adapter: node({ mode: 'standalone' }), experimental: { cache: { provider: memoryCache(), }, },});Astro.cache and context.cacheIn .astro pages, use Astro.cache.set() to control caching:
---Astro.cache.set({ maxAge: 120, // Cache for 2 minutes swr: 60, // Serve stale for 1 minute while revalidating tags: ['home'], // Tag for targeted invalidation});---
<html><body>Cached page</body></html>In API routes and middleware, use context.cache:
export function GET(context) { context.cache.set({ maxAge: 300, tags: ['api', 'data'], }); return Response.json({ ok: true });}cache.set() accepts the following options:
maxAge (number): Time in seconds the response is considered fresh.swr (number): Stale-while-revalidate window in seconds. During this window, stale content is served while a fresh response is generated in the background.tags (string[]): Cache tags for targeted invalidation. Tags accumulate across multiple set() calls within a request.lastModified (Date): When multiple set() calls provide lastModified, the most recent date wins.etag (string): Entity tag for conditional requests.Call cache.set(false) to explicitly opt out of caching for a request.
Multiple calls to cache.set() within a single request are merged: scalar values use last-write-wins, lastModified uses most-recent-wins, and tags accumulate.
Purge cached entries by tag or path using cache.invalidate():
// Invalidate all entries tagged 'data'await context.cache.invalidate({ tags: ['data'] });
// Invalidate a specific pathawait context.cache.invalidate({ path: '/api/data' });Use experimental.routeRules to set default cache options for routes without modifying route code. Supports Nitro-style shortcuts for ergonomic configuration:
import { memoryCache } from 'astro/config';
export default defineConfig({ experimental: { cache: { provider: memoryCache(), }, routeRules: { // Shortcut form (Nitro-style) '/api/*': { swr: 600 },
// Full form with nested cache '/products/*': { cache: { maxAge: 3600, tags: ['products'] } }, }, },});Route patterns support static paths, dynamic parameters ([slug]), and rest parameters ([...path]). Per-route cache.set() calls merge with (and can override) the config-level defaults.
You can also read the current cache state via cache.options:
const { maxAge, swr, tags } = context.cache.options;Cache behavior is determined by the configured cache provider. There are two types:
CDN-Cache-Control, Cache-Tag) and let the CDN handle caching. Astro strips these headers before sending the response to the client.onRequest() to intercept and cache responses in-process, adding an X-Astro-Cache header (HIT/MISS/STALE) for observability.Astro includes a built-in, in-memory LRU runtime cache provider. Import memoryCache from astro/config to configure it.
Features:
X-Astro-Cache response header: HIT, MISS, or STALE?b=2&a=1 and ?a=1&b=2 hit the same entry)utm_*, fbclid, gclid, etc.) excluded from cache keys by defaultVary header support โ responses that set Vary automatically get separate cache entries per variantquery.exclude (glob patterns) and query.include (allowlist)For more information on enabling and using this feature in your project, see the Experimental Route Caching docs. For a complete overview and to give feedback on this experimental API, see the Route Caching RFC.
#15483 7be3308 Thanks @florian-lefebvre! - Adds streaming option to the createApp() function in the Adapter API, mirroring the same functionality available when creating a new App instance
An adapterโs createApp() function now accepts streaming (defaults to true) as an option. HTML streaming breaks a document into chunks to send over the network and render on the page in order. This normally results in visitors seeing your HTML as fast as possible but factors such as network conditions and waiting for data fetches can block page rendering.
HTML streaming helps with performance and generally provides a better visitor experience. In most cases, disabling streaming is not recommended.
However, when you need to disable HTML streaming (e.g. your host only supports non-streamed HTML caching at the CDN level), you can opt out of the default behavior by passing streaming: false to createApp():
import { createApp } from 'astro/app/entrypoint';
const app = createApp({ streaming: false });See more about the createApp() function in the Adapter API reference.
#15423 c5ea720 Thanks @matthewp! - Improves error message when a dynamic redirect destination does not match any existing route.
Previously, configuring a redirect like /categories/[category] โ /categories/[category]/1 in static output mode would fail with a misleading โgetStaticPaths requiredโ error. Now, Astro detects this early and provides a clear error explaining that the destination does not match any existing route.
#15167 4fca170 Thanks @HiDeoo! - Fixes an issue where CSS from unused components, when using content collections, could be incorrectly included between page navigations in development mode.
#15565 30cd6db Thanks @ematipico! - Fixes an issue where the use of the Astro internal logger couldnโt work with Cloudflare Vite plugin.
#15508 2c6484a Thanks @KTibow! - Fixes behavior when shortcuts are used before server is ready
#15125 6feb0d7 Thanks @florian-lefebvre! - Improves JSDoc annotations for AstroGlobal, AstroSharedContext and APIContext types
#15712 7ac43c7 Thanks @florian-lefebvre! - Improves astro info by supporting more operating systems when copying the information to the clipboard.
#15054 22db567 Thanks @matthewp! - Improves zod union type error messages to show expected vs received types instead of generic โInvalid inputโ
#15064 caf5621 Thanks @ascorbic! - Fixes a bug that caused incorrect warnings of duplicate entries to be logged by the glob loader when editing a file
#15801 01db4f3 Thanks @ascorbic! - Improves the experience of working with experimental route caching in dev mode by replacing some errors with silent no-ops, avoiding the need to write conditional logic to handle different modes
Adds a cache.enabled property to CacheLike so libraries can check whether caching is active without try/catch.
#15562 e14a51d Thanks @florian-lefebvre! - Removes types for the astro:ssr-manifest module, which was removed
#15542 9760404 Thanks @rururux! - Improves rendering by preserving hidden="until-found" value in attributes
#15044 7cac71b Thanks @florian-lefebvre! - Removes an exposed internal API of the preview server
#15573 d789452 Thanks @matthewp! - Clear the route cache on content changes so slug pages reflect updated data during dev.
#15308 89cbcfa Thanks @matthewp! - Fixes styles missing in dev for prerendered pages when using Cloudflare adapter
#15435 957b9fe Thanks @rururux! - Improves compatibility of the built-in image endpoint with runtimes that donโt support CJS dependencies correctly
#15640 4c1a801 Thanks @ematipico! - Reverts the support of Shiki with CSP. Unfortunately, after exhaustive tests, the highlighter canโt be supported to cover all cases.
Adds a warning when both Content Security Policy (CSP) and Shiki syntax highlighting are enabled, as they are incompatible due to Shikiโs use of inline styles
#15415 cc3c46c Thanks @ematipico! - Fixes an issue where CSP headers were incorrectly injected in the development server.
#15412 c546563 Thanks @florian-lefebvre! - Improves the AstroAdapter type and how legacy adapters are handled
#15322 18e0980 Thanks @matthewp! - Prevents missing CSS when using both SSR and prerendered routes
#15760 f49a27f Thanks @ematipico! - Fixed an issue where queued rendering wasnโt correctly re-using the saved nodes.
#15277 cb99214 Thanks @ematipico! - Fixes an issue where the function createShikiHighlighter would always create a new Shiki highlighter instance. Now the function returns a cached version of the highlighter based on the Shiki options. This should improve the performance for sites that heavily rely on Shiki and code in their pages.
#15394 5520f89 Thanks @florian-lefebvre! - Fixes a case where using the Fonts API with netlify dev wouldnโt work because of query parameters
#15605 f6473fd Thanks @ascorbic! - Improves .astro component SSR rendering performance by up to 2x.
This includes several optimizations to the way that Astro generates and renders components on the server. These are mostly micro-optimizations, but they add up to a significant improvement in performance. Most pages will benefit, but pages with many components will see the biggest improvement, as will pages with lots of strings (e.g. text-heavy pages with lots of HTML elements).
#15721 e6e146c Thanks @matthewp! - Fixes action route handling to return 404 for requests to prototype method names like constructor or toString used as action paths
#15497 a93c81d Thanks @matthewp! - Fix dev reloads for content collection Markdown updates under Vite 7.
#15780 e0ac125 Thanks @ematipico! - Prevents vite.envPrefix misconfiguration from exposing access: "secret" environment variables in client-side bundles. Astro now throws a clear error at startup if any vite.envPrefix entry matches a variable declared with access: "secret" in env.schema.
For example, the following configuration will throw an error for API_SECRET because itโs defined as secret its name matches ['PUBLIC_', 'API_'] defined in env.schema:
import { defineConfig } from 'astro/config';
export default defineConfig({ env: { schema: { API_SECRET: envField.string({ context: 'server', access: 'secret', optional: true }), API_URL: envField.string({ context: 'server', access: 'public', optional: true }), }, }, vite: { envPrefix: ['PUBLIC_', 'API_'], },});#15514 999a7dd Thanks @veeceey! - Fixes font flash (FOUT) during ClientRouter navigation by preserving inline <style> elements and font preload links in the head during page transitions.
Previously, @font-face declarations from the <Font> component were removed and re-inserted on every client-side navigation, causing the browser to re-evaluate them.
#15560 170ed89 Thanks @z0mt3c! - Fix X-Forwarded-Proto validation when allowedDomains includes both protocol and hostname fields. The protocol check no longer fails due to hostname mismatch against the hardcoded test URL.
#15704 862d77b Thanks @umutkeltek! - Fixes i18n fallback middleware intercepting non-404 responses
The fallback middleware was triggering for all responses with status >= 300, including legitimate 3xx redirects, 403 forbidden, and 5xx server errors. This broke auth flows and form submissions on localized server routes. The fallback now correctly only triggers for 404 (page not found) responses.
#15661 7150a2e Thanks @ematipico! - Fixes a build error when generating projects with 100k+ static routes.
#15580 a92333c Thanks @ematipico! - Fixes a build error when generating projects with a large number of static routes
#15176 9265546 Thanks @matthewp! - Fixes hydration for framework components inside MDX when using Astro.slots.render()
Previously, when multiple framework components with client:* directives were passed as named slots to an Astro component in MDX, only the first slot would hydrate correctly. Subsequent slots would render their HTML but fail to include the necessary hydration scripts.
#15506 074901f Thanks @ascorbic! - Fixes a race condition where concurrent requests to dynamic routes in the dev server could produce incorrect params.
#15444 10b0422 Thanks @AhmadYasser1! - Fixes Astro.rewrite returning 404 when rewriting to a URL with non-ASCII characters
When rewriting to a path containing non-ASCII characters (e.g., /redirected/hรฉllo), the route lookup compared encoded distURL hrefs against decoded pathnames, causing the comparison to always fail and resulting in a 404. This fix compares against the encoded pathname instead.
#15728 12ca621 Thanks @SvetimFM! - Improves internal state retention for persisted elements during view transitions, especially avoiding WebGL context loss in Safari and resets of CSS transitions and iframes in modern Chromium and Firefox browsers
#15279 8983f17 Thanks @ematipico! - Fixes an issue where the dev server would serve files like /README.md from the project root when they shouldnโt be accessible. A new route guard middleware now blocks direct URL access to files that exist outside of srcDir and publicDir, returning a 404 instead.
#15703 829182b Thanks @matthewp! - Fixes server islands returning a 500 error in dev mode for adapters that do not set adapterFeatures.buildOutput (e.g. @astrojs/netlify)
#15749 573d188 Thanks @ascorbic! - Fixes a bug that caused session.regenerate() to silently lose session data
Previously, regenerated session data was not saved under the new session ID unless set() was also called.
#15549 be1c87e Thanks @0xRozier! - Fixes an issue where original (unoptimized) images from prerendered pages could be kept in the build output during SSR builds.
#15454 b47a4e1 Thanks @Fryuni! - Fixes a race condition in the content layer which could result in dropped content collection entries.
#15685 1a323e5 Thanks @jcayzac! - Fix regression where SVG images in content collection image() fields could not be rendered as inline components. This behavior is now restored while preserving the TLA deadlock fix.
#15603 5bc2b2c Thanks @0xRozier! - Fixes a deadlock that occurred when using SVG images in content collections
#15385 9e16d63 Thanks @matthewp! - Fixes content layer loaders that use dynamic imports
Content collection loaders can now use await import() and import.meta.glob() to dynamically import modules during build. Previously, these would fail with โVite module runner has been closed.โ
#15565 30cd6db Thanks @ematipico! - Fixes an issue where the use of the Code component would result in an unexpected error.
#15125 6feb0d7 Thanks @florian-lefebvre! - Fixes remote images Etag header handling by disabling internal cache
#15317 7e1e35a Thanks @matthewp! - Fixes ?raw imports failing when used in both SSR and prerendered routes
#15809 94b4a46 Thanks @Princesseuh! - Fixes fit defaults not being applied unless layout was also specified
#15563 e959698 Thanks @ematipico! - Fixes an issue where warnings would be logged during the build using one of the official adapters
#15121 06261e0 Thanks @ematipico! - Fixes a bug where the Astro, with the Cloudflare integration, couldnโt correctly serve certain routes in the development server.
#15585 98ea30c Thanks @matthewp! - Add a default body size limit for server actions to prevent oversized requests from exhausting memory.
#15264 11efb05 Thanks @florian-lefebvre! - Lower the Node version requirement to allow running on Stackblitz until it supports v22
#15778 4ebc1e3 Thanks @ematipico! - Fixes an issue where the computed clientAddress was incorrect in cases of a Request header with multiple values. The clientAddress is now also validated to contain only characters valid in IP addresses, rejecting injection payloads.
#15565 30cd6db Thanks @ematipico! - Fixes an issue where the new Astro v6 development server didnโt log anything when navigating the pages.
#15024 22c48ba Thanks @florian-lefebvre! - Fixes a case where JSON schema generation would fail for unrepresentable types
#15669 d5a888b Thanks @florian-lefebvre! - Removes the cssesc dependency
This CommonJS dependency could sometimes cause errors because Astro is ESM-only. It is now replaced with a built-in ESM-friendly implementation.
#15740 c5016fc Thanks @matthewp! - Removes an escape hatch that skipped attribute escaping for URL values containing &, ensuring all dynamic attribute values are consistently escaped
#15756 b6c64d1 Thanks @matthewp! - Hardens the dev server by validating Sec-Fetch metadata headers to restrict cross-origin subresource requests
#15744 fabb710 Thanks @matthewp! - Fixes cookie handling during error page rendering to ensure cookies set by middleware are consistently included in the response
#15776 e9a9cc6 Thanks @matthewp! - Hardens error page response merging to ensure framing headers from the original response are not carried over to the rendered error page
#15759 39ff2a5 Thanks @matthewp! - Adds a new bodySizeLimit option to the @astrojs/node adapter
You can now configure a maximum allowed request body size for your Node.js standalone server. The default limit is 1 GB. Set the value in bytes, or pass 0 to disable the limit entirely:
import node from '@astrojs/node';import { defineConfig } from 'astro/config';
export default defineConfig({ adapter: node({ mode: 'standalone', bodySizeLimit: 1024 * 1024 * 100, // 100 MB }),});#15777 02e24d9 Thanks @matthewp! - Fixes CSRF origin check mismatch by passing the actual server listening port to createRequest, ensuring the constructed URL origin includes the correct port (e.g., http://localhost:4321 instead of http://localhost). Also restricts X-Forwarded-Proto to only be trusted when allowedDomains is configured.
#15742 9d9699c Thanks @matthewp! - Hardens clientAddress resolution to respect security.allowedDomains for X-Forwarded-For, consistent with the existing handling of X-Forwarded-Host, X-Forwarded-Proto, and X-Forwarded-Port. The X-Forwarded-For header is now only used to determine Astro.clientAddress when the requestโs host has been validated against an allowedDomains entry. Without a matching domain, clientAddress falls back to the socketโs remote address.
#15768 6328f1a Thanks @matthewp! - Hardens internal cookie parsing to use a null-prototype object consistently for the fallback path, aligning with how the cookie library handles parsed values
#15125 6feb0d7 Thanks @florian-lefebvre! - Fixes images not working in development when using setups with port forwarding
#15811 2ba0db5 Thanks @ematipico! - Fixes integration-injected scripts (e.g. Alpine.js via injectScript()) not being loaded in the dev server when using non-runnable environment adapters like @astrojs/cloudflare.
#15208 8dbdd8e Thanks @matthewp! - Makes session.driver optional in config schema, allowing adapters to provide default drivers
Adapters like Cloudflare, Netlify, and Node provide default session drivers, so users can now configure session options (like ttl) without explicitly specifying a driver.
#15260 abca1eb Thanks @ematipico! - Fixes an issue where adding new pages werenโt correctly shown when using the development server.
#15591 1ed07bf Thanks @renovate! - Upgrades devalue to v5.6.3
#15137 2f70bf1 Thanks @matthewp! - Adds legacy.collectionsBackwardsCompat flag that restores v5 backwards compatibility behavior for legacy content collections - (v6 upgrade guidance)
When enabled, this flag allows:
type: 'content' or type: 'data'src/content/config.ts (legacy location)entry.slug and entry.render() methodsexport default defineConfig({ legacy: { collectionsBackwardsCompat: true, },});This is a temporary migration helper for v6 upgrades. Migrate collections to the Content Layer API, then disable this flag.
#15550 58df907 Thanks @florian-lefebvre! - Improves the JSDoc annotations for the AstroAdapter type
#15696 a9fd221 Thanks @Princesseuh! - Fixes images not working in MDX when using the Cloudflare adapter in certain cases
#15386 a0234a3 Thanks @OliverSpeir! - Updates astro add cloudflare to use the latest valid compatibility_date in the wrangler config, if available
#15036 f125a73 Thanks @florian-lefebvre! - Fixes certain aliases not working when using images in JSON files with the content layer
#15693 4db2089 Thanks @ArmandPhilippot! - Fixes the links to Astro Docs to match the v6 structure.
#15093 8d5f783 Thanks @matthewp! - Reduces build memory by filtering routes per environment so each only builds the pages it needs
#15268 54e5cc4 Thanks @rururux! - fix: avoid creating unused images during build in Picture component
#15757 631aaed Thanks @matthewp! - Hardens URL pathname normalization to consistently handle backslash characters after decoding, ensuring middleware and router see the same canonical pathname
#15337 7ff7b11 Thanks @ematipico! - Fixes a bug where the development server couldnโt serve newly created new pages while the development server is running.
#15535 dfe2e22 Thanks @florian-lefebvre! - Fixes the types of createApp() exported from astro/app/entrypoint
#15073 2a39c32 Thanks @ascorbic! - Donโt log an error when there is no content config
#15717 4000aaa Thanks @matthewp! - Ensures that URLs with multiple leading slashes (e.g. //admin) are normalized to a single slash before reaching middleware, so that pathname checks like context.url.pathname.startsWith('/admin') work consistently regardless of the request URL format
#15450 50c9129 Thanks @florian-lefebvre! - Fixes a case where build.serverEntry would not be respected when using the new Adapter API
#15331 4592be5 Thanks @matthewp! - Fixes an issue where API routes would overwrite public files during build. Public files now correctly take priority over generated routes in both dev and build modes.
#15414 faedcc4 Thanks @sapphi-red! - Fixes a bug where some requests to the dev server didnโt start with the leading /.
#15419 a18d727 Thanks @ematipico! - Fixes an issue where the add command could accept any arbitrary value, leading the possible command injections. Now add and --add accepts
values that are only acceptable npmjs.org names.
#15507 07f6610 Thanks @matthewp! - Avoid bundling SSR renderers when only API endpoints are dynamic
#15125 6feb0d7 Thanks @florian-lefebvre! - Reduces Astroโs install size by around 8 MB
#15752 918d394 Thanks @ascorbic! - Fixes an issue where a session ID from a cookie with no matching server-side data was accepted as-is. The session now generates a new ID when the cookie value has no corresponding storage entry.
#15743 3b4252a Thanks @matthewp! - Hardens config-based redirects with catch-all parameters to prevent producing protocol-relative URLs (e.g. //example.com) in the Location header
#15761 8939751 Thanks @ematipico! - Fixes an issue where it wasnโt possible to set experimental.queuedRendering.poolSize to 0.
#15633 9d293c2 Thanks @jwoyo! - Fixes a case where <script> tags from components passed as slots to server islands were not included in the response
#15491 6c60b05 Thanks @matthewp! - Fixes a case where setting vite.server.allowedHosts: true was turned into an invalid array
#15459 a4406b4 Thanks @florian-lefebvre! - Fixes a case where context.csp was logging warnings in development that should be logged in production only
#15125 6feb0d7 Thanks @florian-lefebvre! - Enables the ClientRouter to preserve the original hash part of the target URL during server side redirects.
#15133 53b125b Thanks @HiDeoo! - Fixes an issue where adding or removing <style> tags in Astro components would not visually update styles during development without restarting the development server.
#15362 dbf71c0 Thanks @jcayzac! - Fixes inferSize being kept in the HTML attributes of the emitted <img> when that option is used with an image that is not remote.
#15421 bf62b6f Thanks @Princesseuh! - Removes unintended logging
#15732 2ce9e74 Thanks @florian-lefebvre! - Updates docs links to point to the stable release
#15718 14f37b8 Thanks @florian-lefebvre! - Fixes a case where internal headers may leak when rendering error pages
#15214 6bab8c9 Thanks @ematipico! - Fixes an issue where the internal performance timers werenโt correctly updated to reflect new build pipeline.
#15112 5751d2b Thanks @HiDeoo! - Fixes a Windows-specific build issue when importing an Astro component with a <script> tag using an import alias.
#15345 840fbf9 Thanks @matthewp! - Fixes an issue where .sql files (and other non-asset module types) were incorrectly moved to the client assets folder during SSR builds, causing โno such moduleโ errors at runtime.
The ssrMoveAssets function now reads the Vite manifest to determine which files are actual client assets (CSS and static assets like images) and only moves those, leaving server-side module files in place.
#15259 8670a69 Thanks @ematipico! - Fixes an issue where styles werenโt correctly reloaded when using the @astrojs/cloudflare adapter.
#15473 d653b86 Thanks @matthewp! - Improves Host header handling for SSR deployments behind proxies
#15047 5580372 Thanks @matthewp! - Fixes wrangler config template in astro add cloudflare to use correct entrypoint and compatibility date
#15586 35bc814 Thanks @matthewp! - Fixes an issue where allowlists were not being enforced when handling remote images
#15422 68770ef Thanks @matthewp! - Upgrade to @astrojs/compiler@3.0.0-beta
#15205 12adc55 Thanks @martrapp! - Fixes an issue where the astro:page-load event did not fire on initial page loads.
#15125 6feb0d7 Thanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API only
Changes the font format downloaded by default when using the experimental Fonts API. Additionally, adds a new formats configuration option to specify which font formats to download.
Previously, Astro was opinionated about which font sources would be kept for usage, mainly keeping woff2 and woff files.
You can now specify what font formats should be downloaded (if available). Only woff2 files are downloaded by default.
If you were previously relying on Astro downloading the woff format, you will now need to specify this explicitly with the new formats configuration option. Additionally, you may also specify any additional file formats to download if available:
import { defineConfig, fontProviders } from 'astro/config'
export default defineConfig({ experimental: { fonts: [{ name: 'Roboto', cssVariable: '--font-roboto', provider: fontProviders.google(), formats: ['woff2', 'woff', 'otf'] }] }})#15179 8c8aee6 Thanks @HiDeoo! - Fixes an issue when importing using an import alias a file with a name matching a directory name.
#15036 f125a73 Thanks @florian-lefebvre! - Fixes a vite warning log during builds when using npm
#15269 6f82aae Thanks @ematipico! - Fixes a regression where build.serverEntry stopped working as expected.
#15053 674b63f Thanks @matthewp! - Excludes astro:* and virtual:astro:* from client optimizeDeps in core. Needed for prefetch users since virtual modules are now in the dependency graph.
#15764 44daecf Thanks @matthewp! - Fixes form actions incorrectly auto-executing during error page rendering. When an error page (e.g. 404) is rendered, form actions from the original request are no longer executed, since the full request handling pipeline is not active.
#15788 a91da9f Thanks @florian-lefebvre! - Reverts changes made to TSConfig templates
#15657 cb625b6 Thanks @qzio! - Adds a new security.actionBodySizeLimit option to configure the maximum size of Astro Actions request bodies.
This lets you increase the default 1 MB limit when your actions need to accept larger payloads. For example, actions that handle file uploads or large JSON payloads can now opt in to a higher limit.
If you do not set this option, Astro continues to enforce the 1 MB default to help prevent abuse.
export default defineConfig({ security: { actionBodySizeLimit: 10 * 1024 * 1024, // set to 10 MB },});#15176 9265546 Thanks @matthewp! - Fixes scripts in components not rendering when a sibling <Fragment slot="..."> exists but is unused
Updated dependencies [bbb5811, 4ebc1e3, cb99214, 80f0225, 727b0a2, 4e7f3e8, a164c77, 1fa4177, 7c55f80, cf6ea6b, 6f19ecc, f94d3c5, a18d727, 240c317, 745e632]:
33d6146 Thanks @Princesseuh! - Throws an error when getImage() from astro:assets is called on the client - (v6 upgrade guidance)#15700 4e7f3e8 Thanks @ocavue! - Updates the internal logic during SSR by providing additional metadata for UI framework integrations.
#15781 2de969d Thanks @ematipico! - Adds a new clientAddress option to the createContext() function
Providing this value gives adapter and middleware authors explicit control over the client IP address. When not provided, accessing clientAddress throws an error consistent with other contexts where it is not set by the adapter.
Additionally, both of the official Netlify and Vercel adapters have been updated to provide this information in their edge middleware.
import { createContext } from 'astro/middleware';
createContext({ clientAddress: context.headers.get('x-real-ip'),});#15755 f9ee868 Thanks @matthewp! - Adds a new security.serverIslandBodySizeLimit configuration option
Server island POST endpoints now enforce a body size limit, similar to the existing security.actionBodySizeLimit for Actions. The new option defaults to 1048576 (1 MB) and can be configured independently.
Requests exceeding the limit are rejected with a 413 response. You can customize the limit in your Astro config:
export default defineConfig({ security: { serverIslandBodySizeLimit: 2097152, // 2 MB },});#15712 7ac43c7 Thanks @florian-lefebvre! - Improves astro info by supporting more operating systems when copying the information to the clipboard.
#15780 e0ac125 Thanks @ematipico! - Prevents vite.envPrefix misconfiguration from exposing access: "secret" environment variables in client-side bundles. Astro now throws a clear error at startup if any vite.envPrefix entry matches a variable declared with access: "secret" in env.schema.
For example, the following configuration will throw an error for API_SECRET because itโs defined as secret its name matches ['PUBLIC_', 'API_'] defined in env.schema:
import { defineConfig } from 'astro/config';
export default defineConfig({ env: { schema: { API_SECRET: envField.string({ context: 'server', access: 'secret', optional: true }), API_URL: envField.string({ context: 'server', access: 'public', optional: true }), }, }, vite: { envPrefix: ['PUBLIC_', 'API_'], },});#15778 4ebc1e3 Thanks @ematipico! - Fixes an issue where the computed clientAddress was incorrect in cases of a Request header with multiple values. The clientAddress is now also validated to contain only characters valid in IP addresses, rejecting injection payloads.
#15776 e9a9cc6 Thanks @matthewp! - Hardens error page response merging to ensure framing headers from the original response are not carried over to the rendered error page
#15759 39ff2a5 Thanks @matthewp! - Adds a new bodySizeLimit option to the @astrojs/node adapter
You can now configure a maximum allowed request body size for your Node.js standalone server. The default limit is 1 GB. Set the value in bytes, or pass 0 to disable the limit entirely:
import node from '@astrojs/node';import { defineConfig } from 'astro/config';
export default defineConfig({ adapter: node({ mode: 'standalone', bodySizeLimit: 1024 * 1024 * 100, // 100 MB }),});#15777 02e24d9 Thanks @matthewp! - Fixes CSRF origin check mismatch by passing the actual server listening port to createRequest, ensuring the constructed URL origin includes the correct port (e.g., http://localhost:4321 instead of http://localhost). Also restricts X-Forwarded-Proto to only be trusted when allowedDomains is configured.
#15768 6328f1a Thanks @matthewp! - Hardens internal cookie parsing to use a null-prototype object consistently for the fallback path, aligning with how the cookie library handles parsed values
#15757 631aaed Thanks @matthewp! - Hardens URL pathname normalization to consistently handle backslash characters after decoding, ensuring middleware and router see the same canonical pathname
#15761 8939751 Thanks @ematipico! - Fixes an issue where it wasnโt possible to set experimental.queuedRendering.poolSize to 0.
#15764 44daecf Thanks @matthewp! - Fixes form actions incorrectly auto-executing during error page rendering. When an error page (e.g. 404) is rendered, form actions from the original request are no longer executed, since the full request handling pipeline is not active.
#15788 a91da9f Thanks @florian-lefebvre! - Reverts changes made to TSConfig templates
Updated dependencies [4ebc1e3, 4e7f3e8]:
#15760 f49a27f Thanks @ematipico! - Fixed an issue where queued rendering wasnโt correctly re-using the saved nodes.
#15728 12ca621 Thanks @SvetimFM! - Improves internal state retention for persisted elements during view transitions, especially avoiding WebGL context loss in Safari and resets of CSS transitions and iframes in modern Chromium and Firefox browsers
#15756 b6c64d1 Thanks @matthewp! - Hardens the dev server by validating Sec-Fetch metadata headers to restrict cross-origin subresource requests
#15414 faedcc4 Thanks @sapphi-red! - Fixes a bug where some requests to the dev server didnโt start with the leading /.
Updated dependencies [745e632]:
#15668 1118ac4 Thanks @florian-lefebvre! - Changes TypeScript configuration - (v6 upgrade guidance)
#15726 6f19ecc Thanks @ocavue! - Updates dependency shiki to v4
Check Shikiโs upgrade guide.
#15694 66449c9 Thanks @matthewp! - Adds preserveBuildClientDir option to adapter features
Adapters can now opt in to preserving the client/server directory structure for static builds by setting preserveBuildClientDir: true in their adapter features. When enabled, static builds will output files to build.client instead of directly to outDir.
This is useful for adapters that require a consistent directory structure regardless of the build output type, such as deploying to platforms with specific file organization requirements.
export default function myAdapter() { return { name: 'my-adapter', hooks: { 'astro:config:done': ({ setAdapter }) => { setAdapter({ name: 'my-adapter', adapterFeatures: { buildOutput: 'static', preserveBuildClientDir: true, }, }); }, }, };}#15579 08437d5 Thanks @ascorbic! - Adds two new experimental flags for a Route Caching API and further configuration-level Route Rules for controlling SSR response caching.
Route caching gives you a platform-agnostic way to cache server-rendered responses, based on web standard cache headers. You set caching directives in your routes using Astro.cache (in .astro pages) or context.cache (in API routes and middleware), and Astro translates them into the appropriate headers or runtime behavior depending on your adapter. You can also define cache rules for routes declaratively in your config using experimental.routeRules, without modifying route code.
This feature requires on-demand rendering. Prerendered pages are already static and do not use route caching.
Enable the feature by configuring experimental.cache with a cache provider in your Astro config:
import { defineConfig } from 'astro/config';import node from '@astrojs/node';import { memoryCache } from 'astro/config';
export default defineConfig({ adapter: node({ mode: 'standalone' }), experimental: { cache: { provider: memoryCache(), }, },});Astro.cache and context.cacheIn .astro pages, use Astro.cache.set() to control caching:
---Astro.cache.set({ maxAge: 120, // Cache for 2 minutes swr: 60, // Serve stale for 1 minute while revalidating tags: ['home'], // Tag for targeted invalidation});---
<html><body>Cached page</body></html>In API routes and middleware, use context.cache:
export function GET(context) { context.cache.set({ maxAge: 300, tags: ['api', 'data'], }); return Response.json({ ok: true });}cache.set() accepts the following options:
maxAge (number): Time in seconds the response is considered fresh.swr (number): Stale-while-revalidate window in seconds. During this window, stale content is served while a fresh response is generated in the background.tags (string[]): Cache tags for targeted invalidation. Tags accumulate across multiple set() calls within a request.lastModified (Date): When multiple set() calls provide lastModified, the most recent date wins.etag (string): Entity tag for conditional requests.Call cache.set(false) to explicitly opt out of caching for a request.
Multiple calls to cache.set() within a single request are merged: scalar values use last-write-wins, lastModified uses most-recent-wins, and tags accumulate.
Purge cached entries by tag or path using cache.invalidate():
// Invalidate all entries tagged 'data'await context.cache.invalidate({ tags: ['data'] });
// Invalidate a specific pathawait context.cache.invalidate({ path: '/api/data' });Use experimental.routeRules to set default cache options for routes without modifying route code. Supports Nitro-style shortcuts for ergonomic configuration:
import { memoryCache } from 'astro/config';
export default defineConfig({ experimental: { cache: { provider: memoryCache(), }, routeRules: { // Shortcut form (Nitro-style) '/api/*': { swr: 600 },
// Full form with nested cache '/products/*': { cache: { maxAge: 3600, tags: ['products'] } }, }, },});Route patterns support static paths, dynamic parameters ([slug]), and rest parameters ([...path]). Per-route cache.set() calls merge with (and can override) the config-level defaults.
You can also read the current cache state via cache.options:
const { maxAge, swr, tags } = context.cache.options;Cache behavior is determined by the configured cache provider. There are two types:
CDN-Cache-Control, Cache-Tag) and let the CDN handle caching. Astro strips these headers before sending the response to the client.onRequest() to intercept and cache responses in-process, adding an X-Astro-Cache header (HIT/MISS/STALE) for observability.Astro includes a built-in, in-memory LRU runtime cache provider. Import memoryCache from astro/config to configure it.
Features:
X-Astro-Cache response header: HIT, MISS, or STALE?b=2&a=1 and ?a=1&b=2 hit the same entry)utm_*, fbclid, gclid, etc.) excluded from cache keys by defaultVary header support โ responses that set Vary automatically get separate cache entries per variantquery.exclude (glob patterns) and query.include (allowlist)For more information on enabling and using this feature in your project, see the Experimental Route Caching docs. For a complete overview and to give feedback on this experimental API, see the Route Caching RFC.
#15721 e6e146c Thanks @matthewp! - Fixes action route handling to return 404 for requests to prototype method names like constructor or toString used as action paths
#15704 862d77b Thanks @umutkeltek! - Fixes i18n fallback middleware intercepting non-404 responses
The fallback middleware was triggering for all responses with status >= 300, including legitimate 3xx redirects, 403 forbidden, and 5xx server errors. This broke auth flows and form submissions on localized server routes. The fallback now correctly only triggers for 404 (page not found) responses.
#15703 829182b Thanks @matthewp! - Fixes server islands returning a 500 error in dev mode for adapters that do not set adapterFeatures.buildOutput (e.g. @astrojs/netlify)
#15749 573d188 Thanks @ascorbic! - Fixes a bug that caused session.regenerate() to silently lose session data
Previously, regenerated session data was not saved under the new session ID unless set() was also called.
#15685 1a323e5 Thanks @jcayzac! - Fix regression where SVG images in content collection image() fields could not be rendered as inline components. This behavior is now restored while preserving the TLA deadlock fix.
#15740 c5016fc Thanks @matthewp! - Removes an escape hatch that skipped attribute escaping for URL values containing &, ensuring all dynamic attribute values are consistently escaped
#15744 fabb710 Thanks @matthewp! - Fixes cookie handling during error page rendering to ensure cookies set by middleware are consistently included in the response
#15742 9d9699c Thanks @matthewp! - Hardens clientAddress resolution to respect security.allowedDomains for X-Forwarded-For, consistent with the existing handling of X-Forwarded-Host, X-Forwarded-Proto, and X-Forwarded-Port. The X-Forwarded-For header is now only used to determine Astro.clientAddress when the requestโs host has been validated against an allowedDomains entry. Without a matching domain, clientAddress falls back to the socketโs remote address.
#15696 a9fd221 Thanks @Princesseuh! - Fixes images not working in MDX when using the Cloudflare adapter in certain cases
#15693 4db2089 Thanks @ArmandPhilippot! - Fixes the links to Astro Docs to match the v6 structure.
#15717 4000aaa Thanks @matthewp! - Ensures that URLs with multiple leading slashes (e.g. //admin) are normalized to a single slash before reaching middleware, so that pathname checks like context.url.pathname.startsWith('/admin') work consistently regardless of the request URL format
#15752 918d394 Thanks @ascorbic! - Fixes an issue where a session ID from a cookie with no matching server-side data was accepted as-is. The session now generates a new ID when the cookie value has no corresponding storage entry.
#15743 3b4252a Thanks @matthewp! - Hardens config-based redirects with catch-all parameters to prevent producing protocol-relative URLs (e.g. //example.com) in the Location header
#15718 14f37b8 Thanks @florian-lefebvre! - Fixes a case where internal headers may leak when rendering error pages
Updated dependencies [6f19ecc, f94d3c5]:
#15495 5b99e90 Thanks @leekeh! - Adds a new middlewareMode adapter feature to replace the previous edgeMiddleware option.
This feature only impacts adapter authors. If your adapter supports edgeMiddleware, you should upgrade to the new middlewareMode option to specify the middleware mode for your adapter as soon as possible. The edgeMiddleware feature is deprecated and will be removed in a future major release.
export default function createIntegration() { return { name: '@example/my-adapter', hooks: { 'astro:config:done': ({ setAdapter }) => { setAdapter({ name: '@example/my-adapter', serverEntrypoint: '@example/my-adapter/server.js', adapterFeatures: { edgeMiddleware: true middlewareMode: 'edge' } }); }, }, };}#15657 cb625b6 Thanks @qzio! - Adds a new security.actionBodySizeLimit option to configure the maximum size of Astro Actions request bodies.
This lets you increase the default 1 MB limit when your actions need to accept larger payloads. For example, actions that handle file uploads or large JSON payloads can now opt in to a higher limit.
If you do not set this option, Astro continues to enforce the 1 MB default to help prevent abuse.
export default defineConfig({ security: { actionBodySizeLimit: 10 * 1024 * 1024, // set to 10 MB },});Updated dependencies [1fa4177]:
#15646 0dd9d00 Thanks @delucis! - Removes redundant fetchpriority attributes from the output of Astroโs <Image> component
Previously, Astro would always include fetchpriority="auto" on images not using the priority attribute.
However, this is the default value, so specifying it is redundant. This change omits the attribute by default.
#15661 7150a2e Thanks @ematipico! - Fixes a build error when generating projects with 100k+ static routes.
#15603 5bc2b2c Thanks @0xRozier! - Fixes a deadlock that occurred when using SVG images in content collections
#15669 d5a888b Thanks @florian-lefebvre! - Removes the cssesc dependency
This CommonJS dependency could sometimes cause errors because Astro is ESM-only. It is now replaced with a built-in ESM-friendly implementation.
#15589 b7dd447 Thanks @qzio! - Adds a new security.actionBodySizeLimit option to configure the maximum size of Astro Actions request bodies.
This lets you increase the default 1 MB limit when your actions need to accept larger payloads. For example, actions that handle file uploads or large JSON payloads can now opt in to a higher limit.
If you do not set this option, Astro continues to enforce the 1 MB default to help prevent abuse.
export default defineConfig({ security: { actionBodySizeLimit: 10 * 1024 * 1024, // set to 10 MB },});#15471 32b4302 Thanks @ematipico! - Adds a new experimental flag queuedRendering to enable a queue-based rendering engine
The new engine is based on a two-pass process, where the first pass traverses the tree of components, emits an ordered queue, and then the queue is rendered.
The new engine does not use recursion, and comes with two customizable options.
Early benchmarks showed significant speed improvements and memory efficiency in big projects.
The new engine can be enabled in your Astro config with experimental.queuedRendering.enabled set to true, and can be further customized with additional sub-features.
export default defineConfig({ experimental: { queuedRendering: { enabled: true, }, },});With the new engine enabled, you now have the option to have a pool of nodes that can be saved and reused across page rendering. Node pooling has no effect when rendering pages on demand (SSR) because these rendering requests donโt share memory. However, it can be very useful for performance when building static pages.
export default defineConfig({ experimental: { queuedRendering: { enabled: true, poolSize: 2000, // store up to 2k nodes to be reused across renderers }, },});The new engine additionally unlocks a new contentCache option. This allows you to cache values of nodes during the rendering phase. This is currently a boolean feature with no further customization (e.g. size of cache) that uses sensible defaults for most large content collections:
When disabled, the pool engine wonโt cache strings, but only types.
export default defineConfig({ experimental: { queuedRendering: { enabled: true, contentCache: true, // enable re-use of node values }, },});For more information on enabling and using this feature in your project, see the experimental queued rendering docs for more details.
#15543 d43841d Thanks @Princesseuh! - Adds a new experimental.rustCompiler flag to opt into the experimental Rust-based Astro compiler
This experimental compiler is faster, provides better error messages, and generally has better support for modern JavaScript, TypeScript, and CSS features.
After enabling in your Astro config, the @astrojs/compiler-rs package must also be installed into your project separately:
import { defineConfig } from 'astro/config';
export default defineConfig({ experimental: { rustCompiler: true, },});This new compiler is still in early development and may exhibit some differences compared to the existing Go-based compiler. Notably, this compiler is generally more strict in regard to invalid HTML syntax and may throw errors in cases where the Go-based compiler would have been more lenient. For example, unclosed tags (e.g. <p>My paragraph) will now result in errors.
For more information about using this experimental feature in your project, especially regarding expected differences and limitations, please see the experimental Rust compiler reference docs. To give feedback on the compiler, or to keep up with its development, see the RFC for a new compiler for Astro for more information and discussion.
#15565 30cd6db Thanks @ematipico! - Fixes an issue where the use of the Astro internal logger couldnโt work with Cloudflare Vite plugin.
#15562 e14a51d Thanks @florian-lefebvre! - Removes types for the astro:ssr-manifest module, which was removed
#15435 957b9fe Thanks @rururux! - Improves compatibility of the built-in image endpoint with runtimes that donโt support CJS dependencies correctly
#15640 4c1a801 Thanks @ematipico! - Reverts the support of Shiki with CSP. Unfortunately, after exhaustive tests, the highlighter canโt be supported to cover all cases.
Adds a warning when both Content Security Policy (CSP) and Shiki syntax highlighting are enabled, as they are incompatible due to Shikiโs use of inline styles
#15605 f6473fd Thanks @ascorbic! - Improves .astro component SSR rendering performance by up to 2x.
This includes several optimizations to the way that Astro generates and renders components on the server. These are mostly micro-optimizations, but they add up to a significant improvement in performance. Most pages will benefit, but pages with many components will see the biggest improvement, as will pages with lots of strings (e.g. text-heavy pages with lots of HTML elements).
#15514 999a7dd Thanks @veeceey! - Fixes font flash (FOUT) during ClientRouter navigation by preserving inline <style> elements and font preload links in the head during page transitions.
Previously, @font-face declarations from the <Font> component were removed and re-inserted on every client-side navigation, causing the browser to re-evaluate them.
#15580 a92333c Thanks @ematipico! - Fixes a build error when generating projects with a large number of static routes
#15549 be1c87e Thanks @0xRozier! - Fixes an issue where original (unoptimized) images from prerendered pages could be kept in the build output during SSR builds.
#15565 30cd6db Thanks @ematipico! - Fixes an issue where the use of the Code component would result in an unexpected error.
#15585 98ea30c Thanks @matthewp! - Add a default body size limit for server actions to prevent oversized requests from exhausting memory.
#15565 30cd6db Thanks @ematipico! - Fixes an issue where the new Astro v6 development server didnโt log anything when navigating the pages.
#15591 1ed07bf Thanks @renovate! - Upgrades devalue to v5.6.3
#15633 9d293c2 Thanks @jwoyo! - Fixes a case where <script> tags from components passed as slots to server islands were not included in the response
#15586 35bc814 Thanks @matthewp! - Fixes an issue where allowlists were not being enforced when handling remote images
#15573 d789452 Thanks @matthewp! - Clear the route cache on content changes so slug pages reflect updated data during dev.
#15560 170ed89 Thanks @z0mt3c! - Fix X-Forwarded-Proto validation when allowedDomains includes both protocol and hostname fields. The protocol check no longer fails due to hostname mismatch against the hardcoded test URL.
#15563 e959698 Thanks @ematipico! - Fixes an issue where warnings would be logged during the build using one of the official adapters
84d6efd Thanks @ematipico! - Changes how styles applied to code blocks are emitted to support CSP - (v6 upgrade guidance)#15529 a509941 Thanks @florian-lefebvre! - Adds a new build-in font provider npm to access fonts installed as NPM packages
You can now add web fonts specified in your package.json through Astroโs type-safe Fonts API. The npm font provider allows you to add fonts either from locally installed packages in node_modules or from a CDN.
Set fontProviders.npm() as your fonts provider along with the required name and cssVariable values, and add options as needed:
import { defineConfig, fontProviders } from 'astro/config';
export default defineConfig({ experimental: { fonts: [ { name: 'Roboto', provider: fontProviders.npm(), cssVariable: '--font-roboto', }, ], },});See the NPM font provider reference documentation for more details.
#15548 5b8f573 Thanks @florian-lefebvre! - Adds a new optional embeddedLangs prop to the <Code /> component to support languages beyond the primary lang
This allows, for example, highlighting .vue files with a <script setup lang="tsx"> block correctly:
---import { Code } from 'astro:components';
const code = `<script setup lang="tsx">const Text = ({ text }: { text: string }) => <div>{text}</div>;</script>
<template> <Text text="hello world" /></template>`;---
<Code {code} lang="vue" embeddedLangs={['tsx']} />See the <Code /> component documentation for more details.
#15483 7be3308 Thanks @florian-lefebvre! - Adds streaming option to the createApp() function in the Adapter API, mirroring the same functionality available when creating a new App instance
An adapterโs createApp() function now accepts streaming (defaults to true) as an option. HTML streaming breaks a document into chunks to send over the network and render on the page in order. This normally results in visitors seeing your HTML as fast as possible but factors such as network conditions and waiting for data fetches can block page rendering.
HTML streaming helps with performance and generally provides a better visitor experience. In most cases, disabling streaming is not recommended.
However, when you need to disable HTML streaming (e.g. your host only supports non-streamed HTML caching at the CDN level), you can opt out of the default behavior by passing streaming: false to createApp():
import { createApp } from 'astro/app/entrypoint';
const app = createApp({ streaming: false });See more about the createApp() function in the Adapter API reference.
#15542 9760404 Thanks @rururux! - Improves rendering by preserving hidden="until-found" value in attribues
#15550 58df907 Thanks @florian-lefebvre! - Improves the JSDoc annotations for the AstroAdapter type
#15507 07f6610 Thanks @matthewp! - Avoid bundling SSR renderers when only API endpoints are dynamic
#15459 a4406b4 Thanks @florian-lefebvre! - Fixes a case where context.csp was logging warnings in development that should be logged in production only
Updated dependencies [84d6efd]:
#15535 dfe2e22 Thanks @florian-lefebvre! - Deprecates loadManifest() and loadApp() from astro/app/node (Adapter API) - (v6 upgrade guidance)
#15461 9f21b24 Thanks @florian-lefebvre! - BREAKING CHANGE to the v6 beta Adapter API only: renames entryType to entrypointResolution and updates possible values
Astro 6 introduced a way to let adapters have more control over the entrypoint by passing entryType: 'self' to setAdapter(). However during beta development, the name was unclear and confusing.
entryType is now renamed to entrypointResolution and its possible values are updated:
legacy-dynamic becomes explicit.self becomes auto.If you are building an adapter with v6 beta and specifying entryType, update it:
setAdapter({ // ... entryType: 'legacy-dynamic' entrypointResolution: 'explicit'})
setAdapter({ // ... entryType: 'self' entrypointResolution: 'auto'})#15461 9f21b24 Thanks @florian-lefebvre! - Deprecates createExports() and start() (Adapter API) - (v6 upgrade guidance)
#15535 dfe2e22 Thanks @florian-lefebvre! - Deprecates NodeApp from astro/app/node (Adapter API) - (v6 upgrade guidance)
#15407 aedbbd8 Thanks @ematipico! - Changes how styles of responsive images are emitted - (v6 upgrade guidance)
#15535 dfe2e22 Thanks @florian-lefebvre! - Exports new createRequest() and writeResponse() utilities from astro/app/node
To replace the deprecated NodeApp.createRequest() and NodeApp.writeResponse() methods, the astro/app/node module now exposes new createRequest() and writeResponse() utilities. These can be used to convert a NodeJS IncomingMessage into a web-standard Request and stream a web-standard Response into a NodeJS ServerResponse:
import { createApp } from 'astro/app/entrypoint';import { createRequest, writeResponse } from 'astro/app/node';import { createServer } from 'node:http';
const app = createApp();
const server = createServer(async (req, res) => { const request = createRequest(req); const response = await app.render(request); await writeResponse(response, res);});#15407 aedbbd8 Thanks @ematipico! - Adds support for responsive images when security.csp is enabled, out of the box.
Astroโs implementation of responsive image styles has been updated to be compatible with a configured Content Security Policy.
Instead of, injecting style elements at runtime, Astro will now generate your styles at build time using a combination of class="" and data-* attributes. This means that your processed styles are loaded and hashed out of the box by Astro.
If you were previously choosing between Astroโs CSP feature and including responsive images on your site, you may now use them together.
#15508 2c6484a Thanks @KTibow! - Fixes behavior when shortcuts are used before server is ready
#15497 a93c81d Thanks @matthewp! - Fix dev reloads for content collection Markdown updates under Vite 7.
#15535 dfe2e22 Thanks @florian-lefebvre! - Fixes the types of createApp() exported from astro/app/entrypoint
#15491 6c60b05 Thanks @matthewp! - Fixes a case where setting vite.server.allowedHosts: true was turned into an invalid array
8780ff2 Thanks @Princesseuh! - Adds support for converting SVGs to raster images (PNGs, WebP, etc) to the default Sharp image service - (v6 upgrade guidance)#15460 ee7e53f Thanks @florian-lefebvre! - Updates the Adapter API to allow providing a serverEntrypoint when using entryType: 'self'
Astro 6 introduced a new powerful yet simple Adapter API for defining custom server entrypoints. You can now call setAdapter() with the entryType: 'self' option and specify your custom serverEntrypoint:
export function myAdapter() { return { name: 'my-adapter', hooks: { 'astro:config:done': ({ setAdapter }) => { setAdapter({ name: 'my-adapter', entryType: 'self', serverEntrypoint: 'my-adapter/server.js', supportedAstroFeatures: { // ... }, }); }, }, };}If you need further customization at the Vite level, you can omit serverEntrypoint and instead specify your custom server entrypoint with vite.build.rollupOptions.input.
#15454 b47a4e1 Thanks @Fryuni! - Fixes a race condition in the content layer which could result in dropped content collection entries.
#15450 50c9129 Thanks @florian-lefebvre! - Fixes a case where build.serverEntry would not be respected when using the new Adapter API
#15473 d653b86 Thanks @matthewp! - Improves Host header handling for SSR deployments behind proxies
#15231 3928b87 Thanks @rururux! - Adds a new optional getRemoteSize() method to the Image Service API.
Previously, inferRemoteSize() had a fixed implementation that fetched the entire image to determine its dimensions.
With this new helper function that extends inferRemoteSize(), you can now override or extend how remote image metadata is retrieved.
This enables use cases such as:
For example, you can add a simple cache layer to your existing image service:
const cache = new Map();
const myService = { ...baseService, async getRemoteSize(url, imageConfig) { if (cache.has(url)) return cache.get(url);
const result = await baseService.getRemoteSize(url, imageConfig); cache.set(url, result); return result; },};See the Image Services API reference documentation for more information.
#15077 a164c77 Thanks @matthewp! - Updates the Integration API to add setPrerenderer() to the astro:build:start hook, allowing adapters to provide custom prerendering logic.
The new API accepts either an AstroPrerenderer object directly, or a factory function that receives the default prerenderer:
'astro:build:start': ({ setPrerenderer }) => { setPrerenderer((defaultPrerenderer) => ({ name: 'my-prerenderer', async setup() { // Optional: called once before prerendering starts }, async getStaticPaths() { // Returns array of { pathname: string, route: RouteData } return defaultPrerenderer.getStaticPaths(); }, async render(request, { routeData }) { // request: Request // routeData: RouteData // Returns: Response }, async teardown() { // Optional: called after all pages are prerendered } }));}Also adds the astro:static-paths virtual module, which exports a StaticPaths class for adapters to collect all prerenderable paths from within their target runtime. This is useful when implementing a custom prerenderer that runs in a non-Node environment:
// In your adapter's request handler (running in target runtime)import { App } from 'astro/app';import { StaticPaths } from 'astro:static-paths';
export function createApp(manifest) { const app = new App(manifest);
return { async fetch(request) { const { pathname } = new URL(request.url);
// Expose endpoint for prerenderer to get static paths if (pathname === '/__astro_static_paths') { const staticPaths = new StaticPaths(app); const paths = await staticPaths.getAll(); return new Response(JSON.stringify({ paths })); }
// Normal request handling return app.render(request); }, };}See the adapter reference for more details on implementing a custom prerenderer.
#15345 840fbf9 Thanks @matthewp! - Adds a new emitClientAsset function to astro/assets/utils for integration authors. This function allows emitting assets that will be moved to the client directory during SSR builds, useful for assets referenced in server-rendered content that need to be available on the client.
import { emitClientAsset } from 'astro/assets/utils';
// Inside a Vite plugin's transform or load hookconst handle = emitClientAsset(this, { type: 'asset', name: 'my-image.png', source: imageBuffer,});#15423 c5ea720 Thanks @matthewp! - Improves error message when a dynamic redirect destination does not match any existing route.
Previously, configuring a redirect like /categories/[category] โ /categories/[category]/1 in static output mode would fail with a misleading โgetStaticPaths requiredโ error. Now, Astro detects this early and provides a clear error explaining that the destination does not match any existing route.
#15444 10b0422 Thanks @AhmadYasser1! - Fixes Astro.rewrite returning 404 when rewriting to a URL with non-ASCII characters
When rewriting to a path containing non-ASCII characters (e.g., /redirected/hรฉllo), the route lookup compared encoded distURL hrefs against decoded pathnames, causing the comparison to always fail and resulting in a 404. This fix compares against the encoded pathname instead.
#15419 a18d727 Thanks @ematipico! - Fixes an issue where the add command could accept any arbitrary value, leading the possible command injections. Now add and --add accepts
values that are only acceptable npmjs.org names.
#15345 840fbf9 Thanks @matthewp! - Fixes an issue where .sql files (and other non-asset module types) were incorrectly moved to the client assets folder during SSR builds, causing โno such moduleโ errors at runtime.
The ssrMoveAssets function now reads the Vite manifest to determine which files are actual client assets (CSS and static assets like images) and only moves those, leaving server-side module files in place.
#15422 68770ef Thanks @matthewp! - Upgrade to @astrojs/compiler@3.0.0-beta
Updated dependencies [a164c77, a18d727]:
#15415 cc3c46c Thanks @ematipico! - Fixes an issue where CSP headers were incorrectly injected in the development server.
#15412 c546563 Thanks @florian-lefebvre! - Improves the AstroAdapter type and how legacy adapters are handled
#15421 bf62b6f Thanks @Princesseuh! - Removes unintended logging
#15258 d339a18 Thanks @ematipico! - Stabilizes the adapter feature experimentalStatiHeaders. If you were using this feature in any of the supported adapters, youโll need to change the name of the flag:
export default defineConfig({ adapter: netlify({ experimentalStaticHeaders: true staticHeaders: true })})#15167 4fca170 Thanks @HiDeoo! - Fixes an issue where CSS from unused components, when using content collections, could be incorrectly included between page navigations in development mode.
#15268 54e5cc4 Thanks @rururux! - fix: avoid creating unused images during build in Picture component
#15133 53b125b Thanks @HiDeoo! - Fixes an issue where adding or removing <style> tags in Astro components would not visually update styles during development without restarting the development server.
Updated dependencies [80f0225]:
#14888 4cd3fe4 Thanks @OliverSpeir! - Updates astro add cloudflare to better setup types, by adding ./worker-configuration.d.ts to tsconfig includes and a generate-types script to package.json
#15349 a257c4c Thanks @ascorbic! - Passes collection name to live content loaders
Live content collection loaders now receive the collection name as part of their parameters. This is helpful for loaders that manage multiple collections or need to differentiate behavior based on the collection being accessed.
export function storeLoader({ field, key }) { return { name: 'store-loader', loadCollection: async ({ filter, collection }) => { // ... }, loadEntry: async ({ filter, collection }) => { // ... }, };}#15394 5520f89 Thanks @florian-lefebvre! - Fixes a case where using the Fonts API with netlify dev wouldnโt work because of query parameters
#15385 9e16d63 Thanks @matthewp! - Fixes content layer loaders that use dynamic imports
Content collection loaders can now use await import() and import.meta.glob() to dynamically import modules during build. Previously, these would fail with โVite module runner has been closed.โ
#15386 a0234a3 Thanks @OliverSpeir! - Updates astro add cloudflare to use the latest valid compatibility_date in the wrangler config, if available
#15362 dbf71c0 Thanks @jcayzac! - Fixes inferSize being kept in the HTML attributes of the emitted <img> when that option is used with an image that is not remote.
Updated dependencies [240c317]:
#15332 7c55f80 Thanks @matthewp! - Adds frontmatter parsing support to renderMarkdown in content loaders. When markdown content includes frontmatter, it is now extracted and available in metadata.frontmatter, and excluded from the HTML output. This makes renderMarkdown behave consistently with the glob loader.
const loader = { name: 'my-loader', load: async ({ store, renderMarkdown }) => { const content = `---title: My Post---
# Hello World`; const rendered = await renderMarkdown(content); // rendered.metadata.frontmatter is now { title: 'My Post' } // rendered.html contains only the content, not the frontmatter },};#15291 89b6cdd Thanks @florian-lefebvre! - Removes the experimental.fonts flag and replaces it with a new configuration option fonts - (v6 upgrade guidance)
#15332 7c55f80 Thanks @matthewp! - Adds a fileURL option to renderMarkdown in content loaders, enabling resolution of relative image paths. When provided, relative image paths in markdown will be resolved relative to the specified file URL and included in metadata.localImagePaths.
const loader = { name: 'my-loader', load: async ({ store, renderMarkdown }) => { const content = `# My Post
`; // Provide a fileURL to resolve relative image paths const fileURL = new URL('./posts/my-post.md', import.meta.url); const rendered = await renderMarkdown(content, { fileURL }); // rendered.metadata.localImagePaths now contains the resolved image path },};#15291 89b6cdd Thanks @florian-lefebvre! - Adds a new Fonts API to provide first-party support for adding custom fonts in Astro.
This feature allows you to use fonts from both your file system and several built-in supported providers (e.g. Google, Fontsource, Bunny) through a unified API. Keep your site performant thanks to sensible defaults and automatic optimizations including preloading and fallback font generation.
To enable this feature, configure fonts with one or more fonts:
import { defineConfig, fontProviders } from 'astro/config';
export default defineConfig({ fonts: [ { provider: fontProviders.fontsource(), name: 'Roboto', cssVariable: '--font-roboto', }, ],});Import and include the <Font /> component with the required cssVariable property in the head of your page, usually in a dedicated Head.astro component or in a layout component directly:
---import { Font } from 'astro:assets';---
<html> <head> <Font cssVariable="--font-roboto" preload /> </head> <body> <slot /> </body></html>In any page rendered with that layout, including the layout component itself, you can now define styles with your fontโs cssVariable to apply your custom font.
In the following example, the <h1> heading will have the custom font applied, while the paragraph <p> will not.
---import Layout from '../layouts/Layout.astro';---
<Layout> <h1>In a galaxy far, far away...</h1>
<p>Custom fonts make my headings much cooler!</p>
<style> h1 { font-family: var('--font-roboto'); } </style></Layout>Visit the updated fonts guide to learn more about adding custom fonts to your project.
#15337 7ff7b11 Thanks @ematipico! - Fixes a bug where the development server couldnโt serve newly created new pages while the development server is running.
#15331 4592be5 Thanks @matthewp! - Fixes an issue where API routes would overwrite public files during build. Public files now correctly take priority over generated routes in both dev and build modes.
Updated dependencies [7c55f80]:
#15334 d715f1f Thanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API only
Removes the getFontBuffer() helper function exported from astro:assets when using the experimental Fonts API
This experimental feature introduced in v15.6.13 ended up causing significant memory usage during build. This feature has been removed and will be reintroduced after further exploration and testing.
If you were relying on this function, you can replicate the previous behavior manually:
node:fsfontData and context.url
#14932 b19d816 Thanks @patrickarlt! - Adds support for returning a Promise from the parser() option of the file() loader
This enables you to run asynchronous code such as fetching remote data or using async parsers when loading files with the Content Layer API.
For example:
import { defineCollection } from 'astro:content';import { file } from 'astro/loaders';
const blog = defineCollection({ loader: file('src/data/blog.json', { parser: async (text) => { const data = JSON.parse(text);
// Perform async operations like fetching additional data const enrichedData = await fetch(`https://api.example.com/enrich`, { method: 'POST', body: JSON.stringify(data), }).then((res) => res.json());
return enrichedData; }, }),});
export const collections = { blog };See the parser() reference documentation for more information.
#15171 f220726 Thanks @mark-ignacio! - Adds a new, optional kernel configuration option to select a resize algorithm in the Sharp image service
By default, Sharp resizes images with the lanczos3 kernel. This new config option allows you to set the default resizing algorithm to any resizing option supported by Sharp (e.g. linear, mks2021).
Kernel selection can produce quite noticeable differences depending on various characteristics of the source image - especially drawn art - so changing the kernel gives you more control over the appearance of images on your site:
export default defineConfig({ image: { service: { entrypoint: 'astro/assets/services/sharp', config: { kernel: "mks2021" } }})This selection will apply to all images on your site, and is not yet configurable on a per-image basis. For more information, see Sharps documentation on resizing images.
#15063 08e0fd7 Thanks @jmortlock! - Adds a new partitioned option when setting a cookie to allow creating partitioned cookies.
Partitioned cookies can only be read within the context of the top-level site on which they were set. This allows cross-site tracking to be blocked, while still enabling legitimate uses of third-party cookies.
You can create a partitioned cookie by passing partitioned: true when setting a cookie. Note that partitioned cookies must also be set with secure: true:
Astro.cookies.set('my-cookie', 'value', { partitioned: true, secure: true,});For more information, see the AstroCookieSetOptions API reference.
#15022 f1fce0e Thanks @ascorbic! - Adds a new retainBody option to the glob() loader to allow reducing the size of the data store.
Currently, the glob() loader stores the raw body of each content file in the entry, in addition to the rendered HTML.
The retainBody option defaults to true, but you can set it to false to prevent the raw body of content files from being stored in the data store. This significantly reduces the deployed size of the data store and helps avoid hitting size limits for sites with very large collections.
The rendered body will still be available in the entry.rendered.html property for markdown files, and the entry.filePath property will still point to the original file.
import { defineCollection } from 'astro:content';import { glob } from 'astro/loaders';
const blog = defineCollection({ loader: glob({ pattern: '**/*.md', base: './src/content/blog', retainBody: false, }),});When retainBody is false, entry.body will be undefined instead of containing the raw file contents.
#15153 928529f Thanks @jcayzac! - Adds a new background property to the <Image /> component.
This optional property lets you pass a background color to flatten the image with. By default, Sharp uses a black background when flattening an image that is being converted to a format that does not support transparency (e.g. jpeg). Providing a value for background on an <Image /> component, or passing it to the getImage() helper, will flatten images using that color instead.
This is especially useful when the requested output format doesnโt support an alpha channel (e.g. jpeg) and canโt support transparent backgrounds.
---import { Image } from 'astro:assets';---
<Image src="/transparent.png" alt="A JPEG with a white background!" format="jpeg" background="#ffffff"/>See more about this new property in the image reference docs
#15015 54f6006 Thanks @tony! - Adds optional placement config option for the dev toolbar.
You can now configure the default toolbar position ('bottom-left', 'bottom-center', or 'bottom-right') via devToolbar.placement in your Astro config. This option is helpful for sites with UI elements (chat widgets, cookie banners) that are consistently obscured by the toolbar in the dev environment.
You can set a project default that is consistent across environments (e.g. dev machines, browser instances, team members):
export default defineConfig({ devToolbar: { placement: 'bottom-left', },});User preferences from the toolbar UI (stored in localStorage) still take priority, so this setting can be overridden in individual situations as necessary.
#15281 a1b80c6 Thanks @matthewp! - Ensures server island requests carry an encrypted component export identifier so they do not accidentally resolve to the wrong component.
#15304 02ee3c7 Thanks @cameronapak! - Fix: Remove await from getActionResult example
#15324 ab41c3e Thanks @Princesseuh! - Fixes an issue where certain unauthorized links could be rendered as clickable in the error overlay
#15308 89cbcfa Thanks @matthewp! - Fixes styles missing in dev for prerendered pages when using Cloudflare adapter
#15279 8983f17 Thanks @ematipico! - Fixes an issue where the dev server would serve files like /README.md from the project root when they shouldnโt be accessible. A new route guard middleware now blocks direct URL access to files that exist outside of srcDir and publicDir, returning a 404 instead.
#15277 cb99214 Thanks @ematipico! - Fixes an issue where the function createShikiHighlighter would always create a new Shiki highlighter instance. Now the function returns a cached version of the highlighter based on the Shiki options. This should improve the performance for sites that heavily rely on Shiki and code in their pages.
#15264 11efb05 Thanks @florian-lefebvre! - Lower the Node version requirement to allow running on Stackblitz until it supports v22
Updated dependencies [cb99214]:
0aafc83 Thanks @florian-lefebvre! - Fixes a case where font providers provided as class instances may not work when using the experimental Fonts API. It affected the local provider#15213 c775fce Thanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API only
Updates how the local provider must be used when using the experimental Fonts API
Previously, there were 2 kinds of font providers: remote and local.
Font providers are now unified. If you are using the local provider, the process for configuring local fonts must be updated:
import { defineConfig } from "astro/config";import { defineConfig, fontProviders } from "astro/config";
export default defineConfig({ experimental: { fonts: [{ name: "Custom", cssVariable: "--font-custom", provider: "local", provider: fontProviders.local(), options: { variants: [ { weight: 400, style: "normal", src: ["./src/assets/fonts/custom-400.woff2"] }, { weight: 700, style: "normal", src: ["./src/assets/fonts/custom-700.woff2"] } // ... ] } }] }});Once configured, there is no change to using local fonts in your project. However, you should inspect your deployed site to confirm that your new font configuration is being applied.
See the experimental Fonts API docs for more information.
#15213 c775fce Thanks @florian-lefebvre! - Exposes root on FontProvider init() context
When building a custom FontProvider for the experimental Fonts API, the init() method receives a context. This context now exposes a root URL, useful for resolving local files:
import type { FontProvider } from "astro";
export function registryFontProvider(): FontProvider { return { // ... init: async ({ storage }) => { init: async ({ storage, root }) => { // ... }, };}#15185 edabeaa Thanks @EricGrill! - Add .vercel to .gitignore when adding the Vercel adapter via astro add vercel
#15192 ada2808 Thanks @gameroman! - Removes support for CommonJS config files - (v6 upgrade guidance)
#15266 f7c9365 Thanks @florian-lefebvre! - Allows Astro.csp and context.csp to be undefined instead of throwing errors when csp: true is not configured
When using the experimental Content Security Policy feature in Astro 5.x, context.csp was always defined but would throw if experimental.csp was not enabled in the Astro config.
For the stable version of this API in Astro 6, context.csp can now be undefined if CSP is not enabled and its methods will never throw.
If you were using experimental CSP runtime utilities, you must now access methods conditionally:
Astro.csp.insertDirective("default-src 'self'");Astro.csp?.insertDirective("default-src 'self'");#15208 8dbdd8e Thanks @matthewp! - Makes session.driver optional in config schema, allowing adapters to provide default drivers
Adapters like Cloudflare, Netlify, and Node provide default session drivers, so users can now configure session options (like ttl) without explicitly specifying a driver.
#15260 abca1eb Thanks @ematipico! - Fixes an issue where adding new pages werenโt correctly shown when using the development server.
#15214 6bab8c9 Thanks @ematipico! - Fixes an issue where the internal perfomance timers werenโt correctly updated to reflect new build pipeline.
#15259 8670a69 Thanks @ematipico! - Fixes an issue where styles werenโt correctly reloaded when using the @astrojs/cloudflare adapter.
#15205 12adc55 Thanks @martrapp! - Fixes an issue where the astro:page-load event did not fire on initial page loads.
#15269 6f82aae Thanks @ematipico! - Fixes a regression where build.serverEntry stopped working as expected.
#15182 cb60ee1 Thanks @florian-lefebvre! - Adds a new getFontBuffer() method to retrieve font file buffers when using the experimental Fonts API
The getFontData() helper function from astro:assets was introduced in 5.14.0 to provide access to font family data for use outside of Astro. One of the goals of this API was to be able to retrieve buffers using URLs.
However, it turned out to be impactical and even impossible during prerendering.
Astro now exports a new getFontBuffer() helper function from astro:assets to retrieve font file buffers from URL returned by getFontData(). For example, when using satori to generate OpenGraph images:
import type{ APIRoute } from "astro"import { getFontData } from "astro:assets"import { getFontData, getFontBuffer } from "astro:assets"import satori from "satori"
export const GET: APIRoute = (context) => { const data = getFontData("--font-roboto")
const svg = await satori( <div style={{ color: "black" }}>hello, world</div>, { width: 600, height: 400, fonts: [ { name: "Roboto", data: await fetch(new URL(data[0].src[0].url, context.url.origin)).then(res => res.arrayBuffer()), data: await getFontBuffer(data[0].src[0].url), weight: 400, style: "normal", }, ], }, )
// ...}See the experimental Fonts API documentation for more information.
#15175 47ae148 Thanks @florian-lefebvre! - Allows experimental Font providers to specify family options
Previously, an Astro FontProvider could only accept options at the provider level when called. That could result in weird data structures for family-specific options.
Astro FontProviders can now declare family-specific options, by specifying a generic:
import type { FontProvider } from "astro";import { retrieveFonts, type Fonts } from "./utils.js",
interface Config { token: string;}
interface FamilyOptions { minimal?: boolean;}
export function registryFontProvider(config: Config): FontProvider {export function registryFontProvider(config: Config): FontProvider<FamilyOptions> { let data: Fonts = {}
return { name: "registry", config, init: async () => { data = await retrieveFonts(token); }, listFonts: () => { return Object.keys(data); }, resolveFont: ({ familyName, ...rest }) => { // options is typed as FamilyOptions resolveFont: ({ familyName, options, ...rest }) => { const fonts = data[familyName]; if (fonts) { return { fonts }; } return undefined; }, };}Once the font provider is registered in the Astro config, types are automatically inferred:
import { defineConfig } from "astro/config";import { registryFontProvider } from "./font-provider";
export default defineConfig({ experimental: { fonts: [{ provider: registryFontProvider({ token: "..." }), name: "Custom", cssVariable: "--font-custom", options: { minimal: true } }] }});#15175 47ae148 Thanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API only
Updates how options are passed to the Google and Google Icons font providers when using the experimental Fonts API
Previously, the Google and Google Icons font providers accepted options that were specific to given font families.
These options must now be set using the options property instead. For example using the Google provider:
import { defineConfig, fontProviders } from "astro/config";
export default defineConfig({ experimental: { fonts: [{ name: 'Inter', cssVariable: '--astro-font-inter', weights: ['300 900'], provider: fontProviders.google({ experimental: { variableAxis: { Inter: { opsz: ['14..32'] } } } }), provider: fontProviders.google(), options: { experimental: { variableAxis: { opsz: ['14..32'] } } } }] }})#15200 c0595b3 Thanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API only
Removes getFontData() exported from astro:assets with fontData when using the experimental Fonts API
Accessing font data can be useful for advanced use cases, such as generating meta tags or Open Graph images. Before, we exposed a getFontData() helper function to retrieve the font data for a given cssVariable. That was however limiting for programmatic usages that need to access all font data.
The getFontData() helper function is removed and replaced by a new fontData object:
import { getFontData } from "astro:assets";const data = getFontData("--font-roboto")
import { fontData } from "astro:assets";const data = fontData["--font-roboto"]We may reintroduce getFontData() later on for a more friendly DX, based on your feedback.
#15254 8d84b30 Thanks @lamalex! - Fixes CSS assetsPrefix with remote URLs incorrectly prepending a forward slash
When using build.assetsPrefix with a remote URL (e.g., https://cdn.example.com) for CSS assets, the generated <link> elements were incorrectly getting a / prepended to the full URL, resulting in invalid URLs like /https://cdn.example.com/assets/style.css.
This fix checks if the stylesheet link is a remote URL before prepending the forward slash.
#15178 731f52d Thanks @kedarvartak! - Fixes an issue where stopping the dev server with q+enter incorrectly created a dist folder and copied font files when using the experimental Fonts API
#15230 3da6272 Thanks @rahuld109! - Fixes greedy regex in error message markdown rendering that caused link syntax examples to capture extra characters
#15253 2a6315a Thanks @matthewp! - Fixes hydration for React components nested inside HTML elements in MDX files
#15227 9a609f4 Thanks @matthewp! - Fixes styles not being included for conditionally rendered Svelte 5 components in production builds
#14607 ee52160 Thanks @simensfo! - Reintroduces css deduplication for hydrated client components. Ensures assets already added to a client chunk are not flagged as orphaned
2fa19c4 - Improved error handling in the rendering phase
Added defensive validation in App.render() and #renderError() to provide a descriptive error message when a route module doesnโt have a valid page function.
#15199 d8e64ef Thanks @ArmandPhilippot! - Fixes the links to Astro Docs so that they match the current docs structure.
#15169 b803d8b Thanks @rururux! - fix: fix image 500 error when moving dist directory in standalone Node
#14622 9b35c62 Thanks @aprici7y! - Fixes CSS url() references to public assets returning 404 in dev mode when base path is configured
#15219 43df4ce Thanks @matthewp! - Upgrades the diff package to v8
bbb5811]:
#15125 6feb0d7 Thanks @florian-lefebvre! - Improves JSDoc annotations for AstroGlobal, AstroSharedContext and APIContext types
#15176 9265546 Thanks @matthewp! - Fixes hydration for framework components inside MDX when using Astro.slots.render()
Previously, when multiple framework components with client:* directives were passed as named slots to an Astro component in MDX, only the first slot would hydrate correctly. Subsequent slots would render their HTML but fail to include the necessary hydration scripts.
#15125 6feb0d7 Thanks @florian-lefebvre! - Fixes remote images Etag header handling by disabling internal cache
#15121 06261e0 Thanks @ematipico! - Fixes a bug where the Astro, with the Cloudlfare integration, couldnโt correctly serve certain routes in the development server.
#15125 6feb0d7 Thanks @florian-lefebvre! - Fixes images not working in development when using setups with port forwarding
#15137 2f70bf1 Thanks @matthewp! - Adds legacy.collectionsBackwardsCompat flag that restores v5 backwards compatibility behavior for legacy content collections - (v6 upgrade guidance)
When enabled, this flag allows:
type: 'content' or type: 'data'src/content/config.ts (legacy location)entry.slug and entry.render() methodsexport default defineConfig({ legacy: { collectionsBackwardsCompat: true, },});This is a temporary migration helper for v6 upgrades. Migrate collections to the Content Layer API, then disable this flag.
#15125 6feb0d7 Thanks @florian-lefebvre! - Reduces Astroโs install size by around 8 MB
#15125 6feb0d7 Thanks @florian-lefebvre! - Enables the ClientRouter to preserve the original hash part of the target URL during server side redirects.
#15125 6feb0d7 Thanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API only
Changes the font format downloaded by default when using the experimental Fonts API. Additionally, adds a new formats configuration option to specify which font formats to download.
Previously, Astro was opinionated about which font sources would be kept for usage, mainly keeping woff2 and woff files.
You can now specify what font formats should be downloaded (if available). Only woff2 files are downloaded by default.
If you were previously relying on Astro downloading the woff format, you will now need to specify this explicitly with the new formats configuration option. Additionally, you may also specify any additional file formats to download if available:
import { defineConfig, fontProviders } from 'astro/config'
export default defineConfig({ experimental: { fonts: [{ name: 'Roboto', cssVariable: '--font-roboto', provider: fontProviders.google(), formats: ['woff2', 'woff', 'otf'] }] }})#15179 8c8aee6 Thanks @HiDeoo! - Fixes an issue when importing using an import alias a file with a name matching a directory name.
#15176 9265546 Thanks @matthewp! - Fixes scripts in components not rendering when a sibling <Fragment slot="..."> exists but is unused
#15174 37ab65a Thanks @florian-lefebvre! - Adds Google Icons to built-in font providers
To start using it, access it on fontProviders:
import { defineConfig, fontProviders } from 'astro/config';
export default defineConfig({ experimental: { fonts: [ { name: 'Material Symbols Outlined', provider: fontProviders.googleicons(), cssVariable: '--font-material', }, ], },});#15150 a77c4f4 Thanks @matthewp! - Fixes hydration for framework components inside MDX when using Astro.slots.render()
Previously, when multiple framework components with client:* directives were passed as named slots to an Astro component in MDX, only the first slot would hydrate correctly. Subsequent slots would render their HTML but fail to include the necessary hydration scripts.
#15130 9b726c4 Thanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API only
Changes how font providers are implemented with updates to the FontProvider type
This is an implementation detail that changes how font providers are created. This process allows Astro to take more control rather than relying directly on unifont types. All of Astroโs built-in font providers have been updated to reflect this new type, and can be configured as before. However, using third-party unifont providers that rely on unifont types will require an update to your project code.
Previously, an Astro FontProvider was made of a config and a runtime part. It relied directly on unifont types, which allowed a simple configuration for third-party unifont providers, but also coupled Astroโs implementation to unifont, which was limiting.
Astroโs font provider implementation is now only made of a config part with dedicated hooks. This allows for the separation of config and runtime, but requires you to create a font provider object in order to use custom font providers (e.g. third-party unifont providers, or private font registeries).
If you were using a 3rd-party unifont font provider, you will now need to write an Astro FontProvider using it under the hood. For example:
import { defineConfig } from "astro/config";import { acmeProvider, type AcmeOptions } from '@acme/unifont-provider'import type { FontProvider } from "astro";import type { InitializedProvider } from 'unifont';
function acme(config?: AcmeOptions): FontProvider { const provider = acmeProvider(config); let initializedProvider: InitializedProvider | undefined; return { name: provider._name, config, async init(context) { initializedProvider = await provider(context); }, async resolveFont({ familyName, ...rest }) { return await initializedProvider?.resolveFont(familyName, rest); }, async listFonts() { return await initializedProvider?.listFonts?.(); }, };}
export default defineConfig({ experimental: { fonts: [{ provider: acmeProvider({ /* ... */ }), provider: acme({ /* ... */ }), name: "Material Symbols Outlined", cssVariable: "--font-material" }] }});#15147 9cd5b87 Thanks @matthewp! - Fixes scripts in components not rendering when a sibling <Fragment slot="..."> exists but is unused
#15124 81db3c0 Thanks @leonace924! - Fixes an issue where requests with query parameters to the base path would return a 404 if trailingSlash was not 'ignore' in development
#15152 39ee41f Thanks @rururux! - Fixes a case where context.cookies.set() would be overriden when setting cookies via response headers in development
#15140 6f6f8f8 Thanks @cameronraysmith! - Fixes esbuild warning due to dead code in assets virtual module
#15127 2cff904 Thanks @Princesseuh! - Updates โUnsupported page types foundโ error to only appear in more realistic cases
#15149 34f84c2 Thanks @rahuld109! - Skips โUse the Image componentโ audit warning for images inside framework components (React, Vue, Svelte, etc.)
#15122 b137946 Thanks @florian-lefebvre! - Improves JSDoc annotations for AstroGlobal, AstroSharedContext and APIContext types
#15123 3f58fa2 Thanks @43081j! - Improves rendering performance by grouping render chunks when emitting from async iterables to avoid encoding costs
#14954 7bec4bd Thanks @volpeon! - Fixes remote images Etag header handling by disabling internal cache
#15052 b2bcd5a Thanks @Princesseuh! - Fixes images not working in development when using setups with port forwarding
#15028 87b19b8 Thanks @Princesseuh! - Fixes certain aliases not working when using images in JSON files with the content layer
#15118 cfa382b Thanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API only
Removes the defineAstroFontProvider() type helper.
If you are building a custom font provider, remove any occurrence of defineAstroFontProvider() and use the FontProvider type instead:
import { defineAstroFontProvider } from 'astro/config';
export function myProvider() { return defineAstroFontProvider({ entrypoint: new URL('./implementation.js', import.meta.url) });};
import type { FontProvider } from 'astro';
export function myProvider(): FontProvider { return { entrypoint: new URL('./implementation.js', import.meta.url) },}#15055 4e28db8 Thanks @delucis! - Reduces Astroโs install size by around 8 MB
#15088 a19140f Thanks @martrapp! - Enables the ClientRouter to preserve the original hash part of the target URL during server side redirects.
#15117 b1e8e32 Thanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API only
Changes the font format downloaded by default when using the experimental Fonts API. Additionally, adds a new formats configuration option to specify which font formats to download.
Previously, Astro was opinionated about which font sources would be kept for usage, mainly keeping woff2 and woff files.
You can now specify what font formats should be downloaded (if available). Only woff2 files are downloaded by default.
If you were previously relying on Astro downloading the woff format, you will now need to specify this explicitly with the new formats configuration option. Additionally, you may also specify any additional file formats to download if available:
import { defineConfig, fontProviders } from 'astro/config'
export default defineConfig({ experimental: { fonts: [{ name: 'Roboto', cssVariable: '--font-roboto', provider: fontProviders.google(), formats: ['woff2', 'woff', 'otf'] }] }})#15034 8115752 Thanks @florian-lefebvre! - Fixes a vite warning log during builds when using npm
#15064 caf5621 Thanks @ascorbic! - Fixes a bug that caused incorrect warnings of duplicate entries to be logged by the glob loader when editing a file
#15093 8d5f783 Thanks @matthewp! - Reduces build memory by filtering routes per environment so each only builds the pages it needs
#15073 2a39c32 Thanks @ascorbic! - Donโt log an error when there is no content config
#15112 5751d2b Thanks @HiDeoo! - Fixes a Windows-specific build issue when importing an Astro component with a <script> tag using an import alias.
beddfeb Thanks @Ntale3! - Removes the ability to render Astro components in Vitest client environments - (v6 upgrade guidance)#15006 f361730 Thanks @florian-lefebvre! - Removes session test driver - (v6 upgrade guidance)
#15006 f361730 Thanks @florian-lefebvre! - Deprecates session driver string signature - (v6 upgrade guidance)
#15006 f361730 Thanks @florian-lefebvre! - Adds new session driver object shape
For greater flexibility and improved consistency with other Astro code, session drivers are now specified as an object:
import { defineConfig } from 'astro/config'import { defineConfig, sessionDrivers } from 'astro/config'
export default defineConfig({ session: { driver: 'redis', options: { url: process.env.REDIS_URL }, driver: sessionDrivers.redis({ url: process.env.REDIS_URL }), }})Specifying the session driver as a string has been deprecated, but will continue to work until this feature is removed completely in a future major version. The object shape is the current recommended and documented way to configure a session driver.
#15044 7cac71b Thanks @florian-lefebvre! - Removes an exposed internal API of the preview server
#15047 5580372 Thanks @matthewp! - Fixes wrangler config template in astro add cloudflare to use correct entrypoint and compatibility date
#15053 674b63f Thanks @matthewp! - Excludes astro:* and virtual:astro:* from client optimizeDeps in core. Needed for prefetch users since virtual modules are now in the dependency graph.
#15024 22c48ba Thanks @florian-lefebvre! - Fixes a case where JSON schema generation would fail for unrepresentable types
#15036 f125a73 Thanks @florian-lefebvre! - Fixes certain aliases not working when using images in JSON files with the content layer
#15036 f125a73 Thanks @florian-lefebvre! - Fixes a vite warning log during builds when using npm
#14982 6849e38 Thanks @Princesseuh! - Fixes images outside the project directory not working when using astro:assets in development mode
#14987 9dd9fca Thanks @Princesseuh! - Fixes SVGs not working in dev mode when using the passthrough image service
#15014 a178422 Thanks @delucis! - Adds support for extending the type of the props accepted by Astroโs <Image> component, <Picture> component, and getImage() API.
#14956 0ff51df Thanks @matthewp! - Astro v6.0 upgrades to Zod v4 for schema validation - (v6 upgrade guidance)
#14759 d7889f7 Thanks @florian-lefebvre! - Updates how schema types are inferred for content loaders with schemas (Loader API) - (v6 upgrade guidance)
#14306 141c4a2 Thanks @ematipico! - Removes support for routes with percent-encoded percent signs (e.g. %25) - (v6 upgrade guidance)
#14759 d7889f7 Thanks @florian-lefebvre! - Removes the option to define dynamic schemas in content loaders as functions and adds a new equivalent createSchema() property (Loader API) - (v6 upgrade guidance)
#14306 141c4a2 Thanks @ematipico! - Removes RouteData.generate from the Integration API - (v6 upgrade guidance)
#14989 73e8232 Thanks @florian-lefebvre! - Deprecates exposed astro:transitions internals - (v6 upgrade guidance)
#14758 010f773 Thanks @florian-lefebvre! - Removes the setManifestData method from App and NodeApp (Adapter API) - (v6 upgrade guidance)
#14826 170f64e Thanks @florian-lefebvre! - Removes the experimental.failOnPrerenderConflict flag and replaces it with a new configuration option prerenderConflictBehavior - (v6 upgrade guidance)
#14923 95a1969 Thanks @florian-lefebvre! - Deprecates astro:schema and z from astro:content in favor of astro/zod - (v6 upgrade guidance)
#14844 8d43b1d Thanks @trueberryless! - Removes exposed astro:actions internals - (v6 upgrade guidance)
#14306 141c4a2 Thanks @ematipico! - Changes the shape of SSRManifest properties and adds several new required properties in the Adapter API - (v6 upgrade guidance)
#14306 141c4a2 Thanks @ematipico! - Changes integration hooks and HMR access patterns in the Integration API - (v6 upgrade guidance)
#14306 141c4a2 Thanks @ematipico! - Removes the unused astro:ssr-manifest virtual module - (v6 upgrade guidance)
#14306 141c4a2 Thanks @ematipico! - Adds new optional properties to setAdapter() for adapter entrypoint handling in the Adapter API
Changes:
devEntrypoint?: string | URL - specifies custom dev server entrypointentryType?: 'self' | 'legacy-dynamic' - determines if the adapter provides its own entrypoint ('self') or if Astro constructs one ('legacy-dynamic', default)Migration: Adapter authors can optionally add these properties to support custom dev entrypoints. If not specified, adapters will use the legacy behavior.
#14826 170f64e Thanks @florian-lefebvre! - Adds an option prerenderConflictBehavior to configure the behavior of conflicting prerendered routes
By default, Astro warns you during the build about any conflicts between multiple dynamic routes that can result in the same output path. For example /blog/[slug] and /blog/[...all] both could try to prerender the /blog/post-1 path. In such cases, Astro renders only the highest priority route for the conflicting path. This allows your site to build successfully, although you may discover that some pages are rendered by unexpected routes.
With the new prerenderConflictBehavior configuration option, you can now configure this further:
prerenderConflictBehavior: 'error' fails the buildprerenderConflictBehavior: 'warn' (default) logs a warning and the highest-priority route winsprerenderConflictBehavior: 'ignore' silently picks the highest-priority route when conflicts occurimport { defineConfig } from 'astro/config';
export default defineConfig({ prerenderConflictBehavior: 'error',});#14946 95c40f7 Thanks @ematipico! - Removes the experimental.csp flag and replaces it with a new configuration option security.csp - (v6 upgrade guidance)
6849e38 Thanks @Princesseuh! - Fixes images outside the project directory not working when using astro:assets in development mode#14985 c016f10 Thanks @florian-lefebvre! - Fixes a case where JSDoc annotations wouldnโt show for fonts related APIs in the Astro config
#14973 ed7cc2f Thanks @amankumarpandeyin! - Fixes performance regression and OOM errors when building medium-sized blogs with many content entries. Replaced O(nยฒ) object spread pattern with direct mutation in generateLookupMap.
#14958 70eb542 Thanks @ascorbic! - Gives a helpful error message if a user sets output: "hybrid" in their Astro config.
The option was removed in Astro 5, but lots of content online still references it, and LLMs often suggest it. Itโs not always clear that the replacement is output: "static", rather than output: "server". This change adds a helpful error message to guide humans and robots.
#14901 ef53716 Thanks @Darknab! - Updates the glob() loader to log a warning when duplicated IDs are detected
Updated dependencies [d8305f8]:
#14940 2cf79c2 Thanks @ematipico! - Fixes a bug where Astro didnโt properly combine CSP resources from the csp configuration with those added using the runtime API (Astro.csp.insertDirective()) to form grammatically correct CSP headers
Now Astro correctly deduplicate CSP resources. For example, if you have a global resource in the configuration file, and then you add a a new one using the runtime APIs.
#14889 4bceeb0 Thanks @florian-lefebvre! - Fixes actions types when using specific TypeScript configurations
#14929 e0f277d Thanks @matthewp! - Fixes authentication bypass via double URL encoding in middleware
Prevents attackers from bypassing path-based authentication checks using multi-level URL encoding (e.g., /%2561dmin instead of /%61dmin). Pathnames are now validated after decoding to ensure no additional encoding remains.
#14876 b43dc7f Thanks @florian-lefebvre! - Fixes a vite warning log during builds when using npm
#14884 10273e0 Thanks @florian-lefebvre! - Fixes a case where setting the status of a page to 404 in ssr would show an empty page (or 404.astro page if provided) instead of using the current page
#14769 b43ee71 Thanks @adriandlam! - Fixes an unhandled rejection issue when using Astro with Vercel Workflow DevKit
#14761 345eb22 Thanks @ooga! - Updates button attributes types to allow command and commandfor
#14866 65e214b Thanks @GameRoMan! - Fixes Astro.glob to be correctly marked as deprecated
#14894 1ad9a5b Thanks @delucis! - Fixes support for Astro component rendering in Vitest test suites using a โclientโ environment such as happy-dom or jsdom
#14782 abed929 Thanks @florian-lefebvre! - Improves syncing
#13880 1a2ed01 Thanks @azat-io! - Adds experimental SVGO optimization support for SVG assets
Astro now supports automatic SVG optimization using SVGO during build time. This experimental feature helps reduce SVG file sizes while maintaining visual quality, improving your siteโs performance.
To enable SVG optimization with default settings, add the following to your astro.config.mjs:
import { defineConfig } from 'astro/config';
export default defineConfig({ experimental: { svgo: true, },});To customize optimization, pass a SVGO configuration object:
export default defineConfig({ experimental: { svgo: { plugins: [ 'preset-default', { name: 'removeViewBox', active: false, }, ], }, },});For more information on enabling and using this feature in your project, see the experimental SVG optimization docs.
#14810 2e845fe Thanks @ascorbic! - Adds a hint for code agents to use the --yes flag to skip prompts when running astro add
#14698 f42ff9b Thanks @mauriciabad! - Adds the ActionInputSchema utility type to automatically infer the TypeScript type of an actionโs input based on its Zod schema
For example, this type can be used to retrieve the input type of a form action:
import { type ActionInputSchema, defineAction } from 'astro:actions';import { z } from 'astro/zod';
const action = defineAction({ accept: 'form', input: z.object({ name: z.string() }), handler: ({ name }) => ({ message: `Welcome, ${name}!` }),});
type Schema = ActionInputSchema<typeof action>;// typeof z.object({ name: z.string() })
type Input = z.input<Schema>;// { name: string }#14574 4356485 Thanks @jacobdalamb! - Adds new CLI shortcuts available when running astro preview:
o + enter: open the site in your browserq + enter: quit the previewh + enter: print all available shortcuts#14813 e1dd377 Thanks @ematipico! - Removes picocolors as dependency in favor of the fork piccolore.
#14609 d774306 Thanks @florian-lefebvre! - Improves astro info
#14796 c29a785 Thanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API only
Updates the default subsets to ["latin"]
Subsets have been a common source of confusion: they caused a lot of files to be downloaded by default. You now have to manually pick extra subsets.
Review your Astro config and update subsets if you need, for example if you need greek characters:
import { defineConfig, fontProviders } from "astro/config"
export default defineConfig({ experimental: { fonts: [{ name: "Roboto", cssVariable: "--font-roboto", provider: fontProviders.google(), subsets: ["latin", "greek"] }] }})#14786 758a891 Thanks @mef! - Add handling of invalid encrypted props and slots in server islands.
#14783 504958f Thanks @florian-lefebvre! - Improves the experimental Fonts API build log to show the number of downloaded files. This can help spotting excessive downloading because of misconfiguration
#14791 9e9c528 Thanks @Princesseuh! - Changes the remote protocol checks for images to require explicit authorization in order to use data URIs.
In order to allow data URIs for remote images, you will need to update your astro.config.mjs file to include the following configuration:
import { defineConfig } from 'astro/config';
export default defineConfig({ images: { remotePatterns: [ { protocol: 'data', }, ], },});#14787 0f75f6b Thanks @matthewp! - Fixes wildcard hostname pattern matching to correctly reject hostnames without dots
Previously, hostnames like localhost or other single-part names would incorrectly match patterns like *.example.com. The wildcard matching logic has been corrected to ensure that only valid subdomains matching the pattern are accepted.
#14776 3537876 Thanks @ktym4a! - Fixes the behavior of passthroughImageService so it does not generate webp.
Updated dependencies [9e9c528, 0f75f6b]:
#14772 00c579a Thanks @matthewp! - Improves the security of Server Islands slots by encrypting them before transmission to the browser, matching the security model used for props. This improves the integrity of slot content and prevents injection attacks, even when component templates donโt explicitly support slots.
Slots continue to work as expected for normal usageโthis change has no breaking changes for legitimate requests.
#14771 6f80081 Thanks @matthewp! - Fix middleware pathname matching by normalizing URL-encoded paths
Middleware now receives normalized pathname values, ensuring that encoded paths like /%61dmin are properly decoded to /admin before middleware checks. This prevents potential security issues where middleware checks might be bypassed through URL encoding.
#14765 03fb47c Thanks @florian-lefebvre! - Fixes a case where process.env wouldnโt be properly populated during the build
#14690 ae7197d Thanks @fredriknorlin! - Fixes a bug where Astroโs i18n fallback system with fallbackType: 'rewrite' would not generate fallback files for pages whose filename started with a locale key.
#14751 18c55e1 Thanks @delucis! - Fixes hydration of client components when running the dev server and using a barrel file that re-exports both Astro and UI framework components.
#14750 35122c2 Thanks @florian-lefebvre! - Updates the experimental Fonts API to log a warning if families with a conflicting cssVariable are provided
#14737 74c8852 Thanks @Arecsu! - Fixes an error when using transition:persist with components that use declarative Shadow DOM. Astro now avoids re-attaching a shadow root if one already exists, preventing "Unable to re-attach to existing ShadowDOM" navigation errors.
#14750 35122c2 Thanks @florian-lefebvre! - Updates the experimental Fonts API to allow for more granular configuration of remote font families
A font family is defined by a combination of properties such as weights and styles (e.g. weights: [500, 600] and styles: ["normal", "bold"]), but you may want to download only certain combinations of these.
For greater control over which font files are downloaded, you can specify the same font (ie. with the same cssVariable, name, and provider properties) multiple times with different combinations. Astro will merge the results and download only the required files. For example, it is possible to download normal 500 and 600 while downloading only italic 500:
import { defineConfig, fontProviders } from 'astro/config';
export default defineConfig({ experimental: { fonts: [ { name: 'Roboto', cssVariable: '--roboto', provider: fontProviders.google(), weights: [500, 600], styles: ['normal'], }, { name: 'Roboto', cssVariable: '--roboto', provider: fontProviders.google(), weights: [500], styles: ['italic'], }, ], },});#14712 91780cf Thanks @florian-lefebvre! - Fixes a case where buildโs process.env would be inlined in the server output
#14713 666d5a7 Thanks @florian-lefebvre! - Improves fallbacks generation when using the experimental Fonts API
#14743 dafbb1b Thanks @matthewp! - Improves X-Forwarded header validation to prevent cache poisoning and header injection attacks. Now properly validates X-Forwarded-Proto, X-Forwarded-Host, and X-Forwarded-Port headers against configured allowedDomains patterns, rejecting malformed or suspicious values. This is especially important when running behind a reverse proxy or load balancer.
#14703 970ac0f Thanks @ArmandPhilippot! - Adds missing documentation for some public utilities exported from astro:i18n.
#14715 3d55c5d Thanks @ascorbic! - Adds support for client hydration in getContainerRenderer()
The getContainerRenderer() function is exported by Astro framework integrations to simplify the process of rendering framework components when using the experimental Container API inside a Vite or Vitest environment. This update adds the client hydration entrypoint to the returned object, enabling client-side interactivity for components rendered using this function. Previously this required users to manually call container.addClientRenderer() with the appropriate client renderer entrypoint.
See the container-with-vitest demo for a usage example, and the Container API documentation for more information on using framework components with the experimental Container API.
#14711 a4d284d Thanks @deining! - Fixes typos in documenting our error messages and public APIs.
#14701 9be54c7 Thanks @florian-lefebvre! - Fixes a case where the experimental Fonts API would filter available font files too aggressively, which could prevent the download of woff files when using the google provider
#14627 b368de0 Thanks @matthewp! - Fixes skew protection support for images and font URLs
Adapter-level query parameters (assetQueryParams) are now applied to all image and font asset URLs, including:
/_image endpoint#14631 3ad33f9 Thanks @KurtGokhan! - Adds the astro/jsx-dev-runtime export as an alias for astro/jsx-runtime
#14623 c5fe295 Thanks @delucis! - Fixes a leak of server runtime code when importing SVGs in client-side code. Previously, when importing an SVG file in client code, Astro could end up adding code for rendering SVGs on the server to the client bundle.
#14621 e3175d9 Thanks @GameRoMan! - Updates vite version to fix CVE
#14543 9b3241d Thanks @matthewp! - Adds two new adapter configuration options assetQueryParams and internalFetchHeaders to the Adapter API.
Official and community-built adapters can now use client.assetQueryParams to specify query parameters that should be appended to asset URLs (CSS, JavaScript, images, fonts, etc.). The query parameters are automatically appended to all generated asset URLs during the build process.
Adapters can also use client.internalFetchHeaders to specify headers that should be included in Astroโs internal fetch calls (Actions, View Transitions, Server Islands, Prefetch).
This enables features like Netlifyโs skew protection, which requires the deploy ID to be sent with both internal requests and asset URLs to ensure client and server versions match during deployments.
#14489 add4277 Thanks @dev-shetty! - Adds a new Copy to Clipboard button to the error overlay stack trace.
When an error occurs in dev mode, you can now copy the stack trace with a single click to more easily share it in a bug report, a support thread, or with your favorite LLM.
#14564 5e7cebb Thanks @florian-lefebvre! - Updates astro add cloudflare to scaffold more configuration files
Running astro add cloudflare will now emit wrangler.jsonc and public/.assetsignore, allowing your Astro project to work out of the box as a worker.
#14591 3e887ec Thanks @matthewp! - Adds TypeScript support for the components prop on MDX Content component when using await render(). Developers now get proper IntelliSense and type checking when passing custom components to override default MDX element rendering.
#14598 7b45c65 Thanks @delucis! - Reduces terminal text styling dependency size by switching from kleur to picocolors
#13826 8079482 Thanks @florian-lefebvre! - Adds the option to specify in the preload directive which weights, styles, or subsets to preload for a given font family when using the experimental Fonts API:
---import { Font } from 'astro:assets';---
<Font cssVariable="--font-roboto" preload={[{ subset: 'latin', style: 'normal' }, { weight: '400' }]}/>Variable weight font files will be preloaded if any weight within its range is requested. For example, a font file for font weight 100 900 will be included when 400 is specified in a preload object.
18552c7 Thanks @ematipico! - Fixes a regression introduced in Astro v5.14.7 that caused ?url imports to not work correctly. This release reverts #14142.577d051 Thanks @matthewp! - Fixes image path resolution in content layer collections to support bare filenames. The image() helper now normalizes bare filenames like "cover.jpg" to relative paths "./cover.jpg" for consistent resolution behavior between markdown frontmatter and JSON content collections.#14582 7958c6b Thanks @florian-lefebvre! - Fixes a regression that caused Actions to throw errors while loading
#14567 94500bb Thanks @matthewp! - Fixes the actions endpoint to return 404 for non-existent actions instead of throwing an unhandled error
#14566 946fe68 Thanks @matthewp! - Fixes handling malformed cookies gracefully by returning the unparsed value instead of throwing
When a cookie with an invalid value is present (e.g., containing invalid URI sequences), Astro.cookies.get() now returns the raw cookie value instead of throwing a URIError. This aligns with the behavior of the underlying cookie package and prevents crashes when manually-set or corrupted cookies are encountered.
#14142 73c5de9 Thanks @P4tt4te! - Updates handling of CSS for hydrated client components to prevent duplicates
#14576 2af62c6 Thanks @aprici7y! - Fixes a regression that caused Astro.site to always be undefined in getStaticPaths()
#14562 722bba0 Thanks @erbierc! - Fixes a bug where the behavior of the โmutedโ HTML attribute was inconsistent with that of other attributes.
#14538 51ebe6a Thanks @florian-lefebvre! - Improves how Actions are implemented
#14548 6cdade4 Thanks @ascorbic! - Removes support for the maxAge property in cacheHint objects returned by live loaders.
Feedback showed that this did not make sense to set at the loader level, since the loader does not know how long each individual entry should be cached for.
If your live loader returns cache hints with maxAge, you need to remove this property:
return { entries: [...], cacheHint: { tags: ['my-tag'], maxAge: 60, lastModified: new Date(), },};The cacheHint object now only supports tags and lastModified properties. If you want to set the max age for a page, you can set the headers manually:
---Astro.headers.set('cdn-cache-control', 'max-age=3600');---#14548 6cdade4 Thanks @ascorbic! - Adds missing rendered property to experimental live collections entry type
Live collections support a rendered property that allows you to provide pre-rendered HTML for each entry. While this property was documented and implemented, it was missing from the TypeScript types. This could lead to type errors when trying to use it in a TypeScript project.
No changes to your project code are necessary. You can continue to use the rendered property as before, and it will no longer produce TypeScript errors.
#14525 4f55781 Thanks @penx! - Fixes defineLiveCollection() types
#14441 62ec8ea Thanks @upsuper! - Updates redirect handling to be consistent across static and server output, aligning with the behavior of other adapters.
Previously, the Node.js adapter used default HTML files with meta refresh tags when in static output. This often resulted in an extra flash of the page on redirect, while also not applying the proper status code for redirections. Itโs also likely less friendly to search engines.
This update ensures that configured redirects are always handled as HTTP redirects regardless of output mode, and the default HTML files for the redirects are no longer generated in static output. It makes the Node.js adapter more consistent with the other official adapters.
No change to your project is required to take advantage of this new adapter functionality. It is not expected to cause any breaking changes. However, if you relied on the previous redirecting behavior, you may need to handle your redirects differently now. Otherwise you should notice smoother redirects, with more accurate HTTP status codes, and may potentially see some SEO gains.
#14506 ec3cbe1 Thanks @abdo-spices! - Updates the <Font /> component so that preload links are generated after the style tag, as recommended by capo.js
7e04caf Thanks @ArmandPhilippot! - Fixes an error in the docs that specified an incorrect version for the security.allowedDomains release.#14505 28b2a1d Thanks @matthewp! - Fixes Cannot set property manifest error in test utilities by adding a protected setter for the manifest property
#14235 c4d84bb Thanks @toxeeec! - Fixes a bug where the โtapโ prefetch strategy worked only on the first clicked link with view transitions enabled
a3e16ab Thanks @florian-lefebvre! - Fixes a case where the URLs generated by the experimental Fonts API would be incorrect in dev
#13520 a31edb8 Thanks @openscript! - Adds a new property routePattern available to GetStaticPathsOptions
This provides the original, dynamic segment definition in a routing file path (e.g. /[...locale]/[files]/[slug]) from the Astro render context that would not otherwise be available within the scope of getStaticPaths(). This can be useful to calculate the params and props for each page route.
For example, you can now localize your route segments and return an array of static paths by passing routePattern to a custom getLocalizedData() helper function. The params object will be set with explicit values for each route segment (e.g. locale, files, and slug). Then, these values will be used to generate the routes and can be used in your page template via Astro.params.
import { getLocalizedData } from "../../../utils/i18n"; export async function getStaticPaths({ routePattern}) { const response = await fetch('...'); const data = await response.json(); console.log(routePattern);// [...locale]/[files]/[slug] // Call your custom helper with `routePattern` to generate the staticpaths return data.flatMap((file) => getLocalizedData(file, routePattern)); } const { locale, files,slug } = Astro.params;For more information about this advanced routing pattern, see Astroโs routing reference.
#13651 dcfbd8c Thanks @ADTC! - Adds a new SvgComponent type
You can now more easily enforce type safety for your .svg assets by directly importing SVGComponent from astro/types:
---import type { SvgComponent } from 'astro/types';import HomeIcon from './Home.svg';interface Link { url: string; text: string; icon: SvgComponent;}const links: Link[] = [ { url: '/', text: 'Home', icon: HomeIcon, },];---#14206 16a23e2 Thanks @Fryuni! - Warn on prerendered routes collision.
Previously, when two dynamic routes /[foo] and /[bar] returned values on their getStaticPaths that resulted in the same final path, only one of the routes would be rendered while the other would be silently ignored. Now, when this happens, a warning will be displayed explaining which routes collided and on which path.
Additionally, a new experimental flag failOnPrerenderConflict can be used to fail the build when such a collision occurs.
#13811 69572c0 Thanks @florian-lefebvre! - Adds a new getFontData() method to retrieve lower-level font family data programmatically when using the experimental Fonts API
The getFontData() helper function from astro:assets provides access to font family data for use outside of Astro. This can then be used in an API Route or to generate your own meta tags.
import { getFontData } from 'astro:assets';
const data = getFontData('--font-roboto');For example, getFontData() can get the font buffer from the URL when using satori to generate OpenGraph images:
import type { APIRoute } from 'astro';import { getFontData } from 'astro:assets';import satori from 'satori';
export const GET: APIRoute = (context) => { const data = getFontData('--font-roboto');
const svg = await satori(<div style={{ color: 'black' }}>hello, world</div>, { width: 600, height: 400, fonts: [ { name: 'Roboto', data: await fetch(new URL(data[0].src[0].url, context.url.origin)).then((res) => res.arrayBuffer(), ), weight: 400, style: 'normal', }, ], });
// ...};See the experimental Fonts API documentation for more information.
#14409 250a595 Thanks @louisescher! - Fixes an issue where astro info would log errors to console in certain cases.
#14398 a7df80d Thanks @idawnlight! - Fixes an unsatisfiable type definition when calling addServerRenderer on an experimental container instance
#13747 120866f Thanks @jp-knj! - Adds automatic request signal abortion when the underlying socket closes in the Node.js adapter
The Node.js adapter now automatically aborts the request.signal when the client connection is terminated. This enables better resource management and allows applications to properly handle client disconnections through the standard AbortSignal API.
#14428 32a8acb Thanks @drfuzzyness! - Force sharpService to return a Uint8Array if Sharp returns a SharedArrayBuffer
#14411 a601186 Thanks @GameRoMan! - Fixes relative links to docs that could not be opened in the editor.
1e2499e]:
54dcd04 Thanks @FredKSchott! - Removes warning that caused unexpected console spam when using Bun#14300 bd4a70b Thanks @louisescher! - Adds Vite version & integration versions to output of astro info
#14341 f75fd99 Thanks @delucis! - Fixes support for declarative Shadow DOM when using the <ClientRouter> component
#14350 f59581f Thanks @ascorbic! - Improves error reporting for content collections by adding logging for configuration errors that had previously been silently ignored. Also adds a new error that is thrown if a live collection is used in content.config.ts rather than live.config.ts.
#14343 13f7d36 Thanks @florian-lefebvre! - Fixes a regression in non node runtimes
#14294 e005855 Thanks @martrapp! - Restores the ability to use Google Analytics History change trigger with the <ClientRouter />.
#14326 c24a8f4 Thanks @jsparkdev! - Updates vite version to fix CVE
#14108 218e070 Thanks @JusticeMatthew! - Updates dynamic route split regex to avoid infinite retries/exponential complexity
#14327 c1033be Thanks @ascorbic! - Pins simple-swizzle to avoid compromised version
#14286 09c5db3 Thanks @ematipico! - BREAKING CHANGES only to the experimental CSP feature
The following runtime APIs of the Astro global have been renamed:
Astro.insertDirective to Astro.csp.insertDirectiveAstro.insertStyleResource to Astro.csp.insertStyleResourceAstro.insertStyleHash to Astro.csp.insertStyleHashAstro.insertScriptResource to Astro.csp.insertScriptResourceAstro.insertScriptHash to Astro.csp.insertScriptHashThe following runtime APIs of the APIContext have been renamed:
ctx.insertDirective to ctx.csp.insertDirectivectx.insertStyleResource to ctx.csp.insertStyleResourcectx.insertStyleHash to ctx.csp.insertStyleHashctx.insertScriptResource to ctx.csp.insertScriptResourcectx.insertScriptHash to ctx.csp.insertScriptHash#14283 3224637 Thanks @ematipico! - Fixes an issue where CSP headers were incorrectly injected in the development server.
#14275 3e2f20d Thanks @florian-lefebvre! - Adds support for experimental CSP when using experimental fonts
Experimental fonts now integrate well with experimental CSP by injecting hashes for the styles it generates, as well as font-src directives.
No action is required to benefit from it.
#14280 4b9fb73 Thanks @ascorbic! - Fixes a bug that caused cookies to not be correctly set when using middleware sequences
#14276 77281c4 Thanks @ArmandPhilippot! - Adds a missing export for resolveSrc, a documented image services utility.
#14260 86a1e40 Thanks @jp-knj! - Fixes Astro.url.pathname to respect trailingSlash: 'never' configuration when using a base path. Previously, the root path with a base would incorrectly return /base/ instead of /base when trailingSlash was set to โneverโ.
#14248 e81c4bd Thanks @julesyoungberg! - Fixes a bug where actions named โapplyโ do not work due to being a function prototype method.
#14239 d7d93e1 Thanks @wtchnm! - Fixes a bug where the types for the live content collections were not being generated correctly in dev mode
#14221 eadc9dd Thanks @delucis! - Fixes JSON schema support for content collections using the file() loader
#14229 1a9107a Thanks @jonmichaeldarby! - Ensures Astro.currentLocale returns the correct locale during SSG for pages that use a locale param (such as [locale].astro or [locale]/index.astro, which produce [locale].html)
760acc8 Thanks @ematipico! - Fixes an issue where remote paths werenโt correctly computed when generating assets4d16de7 Thanks @ematipico! - Improves the detection of remote paths in the _image endpoint. Now href parameters that start with // are considered remote paths.
Updated dependencies [4d16de7]:
#14173 39911b8 Thanks @florian-lefebvre! - Adds an experimental flag staticImportMetaEnv to disable the replacement of import.meta.env values with process.env calls and their coercion of environment variable values. This supersedes the rawEnvValues experimental flag, which is now removed.
Astro allows you to configure a type-safe schema for your environment variables, and converts variables imported via astro:env into the expected type. This is the recommended way to use environment variables in Astro, as it allows you to easily see and manage whether your variables are public or secret, available on the client or only on the server at build time, and the data type of your values.
However, you can still access environment variables through process.env and import.meta.env directly when needed. This was the only way to use environment variables in Astro before astro:env was added in Astro 5.0, and Astroโs default handling of import.meta.env includes some logic that was only needed for earlier versions of Astro.
The experimental.staticImportMetaEnv flag updates the behavior of import.meta.env to align with Viteโs handling of environment variables and for better ease of use with Astroโs current implementations and features. This will become the default behavior in Astro 6.0, and this early preview is introduced as an experimental feature.
Currently, non-public import.meta.env environment variables are replaced by a reference to process.env. Additionally, Astro may also convert the value type of your environment variables used through import.meta.env, which can prevent access to some values such as the strings "true" (which is converted to a boolean value), and "1" (which is converted to a number).
The experimental.staticImportMetaEnv flag simplifies Astroโs default behavior, making it easier to understand and use. Astro will no longer replace any import.meta.env environment variables with a process.env call, nor will it coerce values.
To enable this feature, add the experimental flag in your Astro config and remove rawEnvValues if it was enabled:
import { defineConfig } from "astro/config";
export default defineConfig({ experimental: { staticImportMetaEnv: true rawEnvValues: false }});If you were relying on Astroโs default coercion, you may need to update your project code to apply it manually:
const enabled: boolean = import.meta.env.ENABLED; const enabled: boolean = import.meta.env.ENABLED === "true";If you were relying on the transformation into process.env calls, you may need to update your project code to apply it manually:
const enabled: boolean = import.meta.env.DB_PASSWORD; const enabled: boolean = process.env.DB_PASSWORD;You may also need to update types:
interface ImportMetaEnv { readonly PUBLIC_POKEAPI: string; readonly DB_PASSWORD: string; readonly ENABLED: boolean; readonly ENABLED: string;}
interface ImportMeta { readonly env: ImportMetaEnv;}
namespace NodeJS { interface ProcessEnv { DB_PASSWORD: string; } }See the experimental static import.meta.env documentation for more information about this feature. You can learn more about using environment variables in Astro, including astro:env, in the environment variables documentation.
#14122 41ed3ac Thanks @ascorbic! - Adds experimental support for automatic Chrome DevTools workspace folders
This feature allows you to edit files directly in the browser and have those changes reflected in your local file system via a connected workspace folder. This allows you to apply edits such as CSS tweaks without leaving your browser tab!
With this feature enabled, the Astro dev server will automatically configure a Chrome DevTools workspace for your project. Your project will then appear as a workspace source, ready to connect. Then, changes that you make in the โSourcesโ panel are automatically saved to your project source code.
To enable this feature, add the experimental flag chromeDevtoolsWorkspace to your Astro config:
import { defineConfig } from 'astro/config';
export default defineConfig({ experimental: { chromeDevtoolsWorkspace: true, },});See the experimental Chrome DevTools workspace feature documentation for more information.
#14020 9518975 Thanks @jp-knj and @asieradzk! - Prevent double-prefixed redirect paths when using fallback and redirectToDefaultLocale together
Fixes an issue where i18n fallback routes would generate double-prefixed paths (e.g., /es/es/test/item1/) when fallback and redirectToDefaultLocale configurations were used together. The fix adds proper checks to prevent double prefixing in route generation.
#14199 3e4cb8e Thanks @ascorbic! - Fixes a bug that prevented HMR from working with inline styles
0567fb7 Thanks @ascorbic! - Adds // to list of internal path prefixes that do not have automated trailing slash handling
#13894 b36e72f Thanks @florian-lefebvre! - Removes Astro Studio commands from the CLI help
Updated dependencies [0567fb7]:
#14169 f4e8889 Thanks @ascorbic! - Skips trailing slash handling for paths that start with /..
#14170 34e6b3a Thanks @ematipico! - Fixes an issue where static redirects couldnโt correctly generate a redirect when the destination is a prerendered route, and the output is set to "server".
#14169 f4e8889 Thanks @ascorbic! - Fixes a bug that prevented images from being displayed in dev when using the Netlify adapter with trailingSlash set to always
Updated dependencies [f4e8889]:
#14153 29e9283 Thanks @jp-knj! - Fixes a regression introduced by a recent optimisation of how SVG images are emitted during the build.
#14156 592f08d Thanks @TheOtterlord! - Fix the client router not submitting forms if the active URL contained a hash
#14160 d2e25c6 Thanks @ascorbic! - Fixes a bug that meant some remote image URLs could cause invalid filenames to be used for processed images
#14167 62bd071 Thanks @ascorbic! - Fixes a bug that prevented destroyed sessions from being deleted from storage unless the session had been loaded
#14059 19f53eb Thanks @benosmac! - Fixes a bug in i18n implementation, where Astro didnโt emit the correct pages when fallback is enabled, and a locale uses a catch-all route, e.g. src/pages/es/[...catchAll].astro
#14155 31822c3 Thanks @ascorbic! - Fixes a bug that caused an error โserverEntrypointModule[_start] is not a functionโ in some adapters
#14031 e9206c1 Thanks @jp-knj! - Optimized the build pipeline for SVG images. Now, Astro doesnโt reprocess images that have already been processed.
#14132 976879a Thanks @ematipico! - Fixes a bug where the property Astro.routePattern/context.routePattern wasnโt updated when using a rewrite via middleware.
#14131 aafc4d7 Thanks @florian-lefebvre! - Fixes a case where an error occurring in a middleware would show the dev overlay instead of the custom 500.astro page
#14127 2309ada Thanks @florian-lefebvre! - Upgrades zod
#14134 186c201 Thanks @ascorbic! - Throws a more helpful error in dev if trying to use a server island without an adapter
#14129 3572d85 Thanks @ematipico! - Fixes a bug where the CSP headers was incorrectly added to a page when using an adapter.
#14119 14807a4 Thanks @ascorbic! - Fixes a bug that caused builds to fail if a client directive was mistakenly added to an Astro component
#14001 4b03d9c Thanks @dnek! - Fixes an issue where getImage() assigned the resized base URL to the srcset URL of ImageTransform, which matched the width, height, and format of the original image.
#14071 d2cb35d Thanks @Grisoly! - Exposes the Code component lang prop type:
import type { CodeLanguage } from 'astro';#14111 5452ee6 Thanks @ascorbic! - Fixes a bug that prevented โkeyโ from being used as a prop for Astro components in MDX
#14106 b5b39e4 Thanks @ascorbic! - Exits with non-zero exit code when config has an error
#14112 37458b3 Thanks @ascorbic! - Fixes a bug that meant that SVG components could no longer be serialized with JSON.stringify
#14061 c7a7dd5 Thanks @jonasgeiler! - Add module declaration for ?no-inline asset imports
#14109 5a08fa2 Thanks @ascorbic! - Throw a more helpful error if defineLiveCollection is used outside of a live.config file
#14110 e7dd4e1 Thanks @ascorbic! - Warn if duplicate IDs are found by file loader
#14094 22e9087 Thanks @ascorbic! - Correct types to allow priority on all images
#14091 26c6b6d Thanks @ascorbic! - Fixes a bug that caused a type error when defining session options without a driver
#14082 93322cb Thanks @louisescher! - Fixes an issue where Astroโs default 404 route would incorrectly match routes containing โ/404โ in dev
#14089 687d253 Thanks @florian-lefebvre! - Fixes a case where astro:env would not load the right environments variables in dev
#14092 6692c71 Thanks @ascorbic! - Improves error handling in live collections
#14074 144a950 Thanks @abcfy2! - Fixes a bug that caused some image service builds to fail
#14092 6692c71 Thanks @ascorbic! - Fixes a case where zod could not be imported from astro:content virtual module in live collection config
#13971 fe35ee2 Thanks @adamhl8! - Adds an experimental flag rawEnvValues to disable coercion of import.meta.env values (e.g. converting strings to other data types) that are populated from process.env
Astro allows you to configure a type-safe schema for your environment variables, and converts variables imported via astro:env into the expected type.
However, Astro also converts your environment variables used through import.meta.env in some cases, and this can prevent access to some values such as the strings "true" (which is converted to a boolean value), and "1" (which is converted to a number).
The experimental.rawEnvValues flag disables coercion of import.meta.env values that are populated from process.env, allowing you to use the raw value.
To enable this feature, add the experimental flag in your Astro config:
import { defineConfig } from "astro/config"
export default defineConfig({ experimental: { rawEnvValues: true, }})If you were relying on this coercion, you may need to update your project code to apply it manually:
- const enabled: boolean = import.meta.env.ENABLED+ const enabled: boolean = import.meta.env.ENABLED === "true"See the experimental raw environment variables reference docs for more information.
#13941 6bd5f75 Thanks @aditsachde! - Adds support for TOML files to Astroโs built-in glob() and file() content loaders.
In Astro 5.2, Astro added support for using TOML frontmatter in Markdown files instead of YAML. However, if you wanted to use TOML files as local content collection entries themselves, you needed to write your own loader.
Astro 5.12 now directly supports loading data from TOML files in content collections in both the glob() and the file() loaders.
If you had added your own TOML content parser for the file() loader, you can now remove it as this functionality is now included:
import { defineCollection } from "astro:content";import { file } from "astro/loaders"; import { parse as parseToml } from "toml";const dogs = defineCollection({ loader: file("src/data/dogs.toml", { parser: (text) => parseToml(text) }), loader: file("src/data/dogs.toml") schema: /* ... */})Note that TOML does not support top-level arrays. Instead, the file() loader considers each top-level table to be an independent entry. The table header is populated in the id field of the entry object.
See Astroโs content collections guide for more information on using the built-in content loaders.
6bd5f75]:
#14045 3276b79 Thanks @ghubo! - Fixes a problem where importing animated .avif files returns a NoImageMetadata error.
#14041 0c4d5f8 Thanks @dixslyf! - Fixes a <ClientRouter /> bug where the fallback view transition animations when exiting a page
ran too early for browsers that do not support the View Transition API.
This bug prevented event.viewTransition?.skipTransition() from skipping the page exit animation
when used in an astro:before-swap event hook.
#13972 db8f8be Thanks @ematipico! - Updates the NodeApp.match() function in the Adapter API to accept a second, optional parameter to allow adapter authors to add headers to static, prerendered pages.
NodeApp.match(request) currently checks whether there is a route that matches the given Request. If there is a prerendered route, the function returns undefined, because static routes are already rendered and their headers cannot be updated.
When the new, optional boolean parameter is passed (e.g. NodeApp.match(request, true)), Astro will return the first matched route, even when itโs a prerendered route. This allows your adapter to now access static routes and provides the opportunity to set headers for these pages, for example, to implement a Content Security Policy (CSP).
#14029 42562f9 Thanks @ematipico! - Fixes a bug where server islands wouldnโt be correctly rendered when they are rendered inside fragments.
Now the following examples work as expected:
---import { Cart } from '../components/Cart.astro';---
<> <Cart server:defer /></>
<Fragment slot="rest"> <Cart server:defer> <div slot="fallback">Not working</div> </Cart></Fragment>#14017 8d238bc Thanks @dmgawel! - Fixes a bug where i18n fallback rewrites didnโt work in dynamic pages.
#14000 3cbedae Thanks @feelixe! - Fix routePattern JSDoc examples to show correct return values
#13990 de6cfd6 Thanks @isVivek99! - Fixes a case where astro:config/client and astro:config/server virtual modules would not contain config passed to integrations updateConfig() during the build
#14019 a160d1e Thanks @ascorbic! - Removes the requirement to set type: 'live' when defining experimental live content collections
Previously, live collections required a type and loader configured. Now, Astro can determine that your collection is a live collection without defining it explicitly.
This means it is now safe to remove type: 'live' from your collections defined in src/live.config.ts:
import { defineLiveCollection } from 'astro:content';import { storeLoader } from '@mystore/astro-loader';
const products = defineLiveCollection({ type: 'live', loader: storeLoader({ apiKey: process.env.STORE_API_KEY, endpoint: 'https://api.mystore.com/v1', }),});
export const collections = { products };This is not a breaking change: your existing live collections will continue to work even if you still include type: 'live'. However, we suggest removing this line at your earliest convenience for future compatibility when the feature becomes stable and this config option may be removed entirely.
#13966 598da21 Thanks @msamoylov! - Fixes a broken link on the default 404 page in development
#13988 609044c Thanks @ascorbic! - Fixes a bug in live collections that caused it to incorrectly complain about the collection being defined in the wrong file
#13909 b258d86 Thanks @isVivek99! - Fixes rendering of special boolean attributes for custom elements
#13983 e718375 Thanks @florian-lefebvre! - Fixes a case where the toolbar audit would incorrectly flag images processed by Astro in content collections documents
#13999 f077b68 Thanks @ascorbic! - Adds lastModified field to experimental live collection cache hints
Live loaders can now set a lastModified field in the cache hints for entries and collections to indicate when the data was last modified. This is then available in the cacheHint field returned by getCollection and getEntry.
#13987 08f34b1 Thanks @ematipico! - Adds an informative message in dev mode when the CSP feature is enabled.
#14005 82aad62 Thanks @ematipico! - Fixes a bug where inline styles and scripts didnโt work when CSP was enabled. Now when adding <styles> elements inside an Astro component, their hashes care correctly computed.
#13985 0b4c641 Thanks @jsparkdev! - Updates wrong link
#13917 e615216 Thanks @ascorbic! - Adds a new priority attribute for Astroโs image components.
This change introduces a new priority option for the <Image /> and <Picture /> components, which automatically sets the loading, decoding, and fetchpriority attributes to their optimal values for above-the-fold images which should be loaded immediately.
It is a boolean prop, and you can use the shorthand syntax by simply adding priority as a prop to the <Image /> or <Picture /> component. When set, it will apply the following attributes:
loading="eager"decoding="sync"fetchpriority="high"The individual attributes can still be set manually if you need to customize your images further.
By default, the Astro <Image /> component generates <img> tags that lazy-load their content by setting loading="lazy" and decoding="async". This improves performance by deferring the loading of images that are not immediately visible in the viewport, and gives the best scores in performance audits like Lighthouse.
The new priority attribute will override those defaults and automatically add the best settings for your high-priority assets.
This option was previously available for experimental responsive images, but now it is a standard feature for all images.
<Image src="/path/to/image.jpg" alt="An example image" priority />[!Note] You should only use the
priorityoption for images that are critical to the initial rendering of the page, and ideally only one image per page. This is often an image identified as the LCP element when running Lighthouse tests. Using it for too many images will lead to performance issues, as it forces the browser to load those images immediately, potentially blocking the rendering of other content.
#13917 e615216 Thanks @ascorbic! - The responsive images feature introduced behind a flag in v5.0.0 is no longer experimental and is available for general use.
The new responsive images feature in Astro automatically generates optimized images for different screen sizes and resolutions, and applies the correct attributes to ensure that images are displayed correctly on all devices.
Enable the image.responsiveStyles option in your Astro config. Then, set a layout attribute on any or
image.layout, for instantly responsive images with automatically generated srcset and sizes attributes based on the imageโs dimensions and the layout type.
Displaying images correctly on the web can be challenging, and is one of the most common performance issues seen in sites. This new feature simplifies the most challenging part of the process: serving your site visitor an image optimized for their viewing experience, and for your websiteโs performance.
For full details, see the updated Image guide.
The experimental.responsiveImages flag has been removed, and all experimental image configuration options have been renamed to their final names.
If you were using the experimental responsive images feature, youโll need to update your configuration:
export default defineConfig({ experimental: { responsiveImages: true, },});During the experimental phase, default styles were applied automatically to responsive images. Now, you need to explicitly set the responsiveStyles option to true if you want these styles applied.
export default defineConfig({ image: { responsiveStyles: true, },});The experimental image configuration options have been renamed:
Before:
export default defineConfig({ image: { experimentalLayout: 'constrained', experimentalObjectFit: 'cover', experimentalObjectPosition: 'center', experimentalBreakpoints: [640, 750, 828, 1080, 1280], experimentalDefaultStyles: true, }, experimental: { responsiveImages: true, },});After:
export default defineConfig({ image: { layout: 'constrained', objectFit: 'cover', objectPosition: 'center', breakpoints: [640, 750, 828, 1080, 1280], responsiveStyles: true, // This is now *false* by default },});The layout, fit, and position props on <Image> and <Picture> components work exactly the same as before:
<Image src={myImage} alt="A responsive image" layout="constrained" fit="cover" position="center"/>If you werenโt using the experimental responsive images feature, no changes are required.
Please see the Image guide for more information on using responsive images in Astro.
#13685 3c04c1f Thanks @ascorbic! - Adds experimental support for live content collections
Live content collections are a new type of content collection that fetch their data at runtime rather than build time. This allows you to access frequently-updated data from CMSs, APIs, databases, or other sources using a unified API, without needing to rebuild your site when the data changes.
In Astro 5.0, the content layer API added support for adding diverse content sources to content collections. You can create loaders that fetch data from any source at build time, and then access it inside a page via getEntry() and getCollection(). The data is cached between builds, giving fast access and updates.
However there is no method for updating the data store between builds, meaning any updates to the data need a full site deploy, even if the pages are rendered on-demand. This means that content collections are not suitable for pages that update frequently. Instead, today these pages tend to access the APIs directly in the frontmatter. This works, but leads to a lot of boilerplate, and means users donโt benefit from the simple, unified API that content loaders offer. In most cases users tend to individually create loader libraries that they share between pages.
Live content collections solve this problem by allowing you to create loaders that fetch data at runtime, rather than build time. This means that the data is always up-to-date, without needing to rebuild the site.
To enable live collections add the experimental.liveContentCollections flag to your astro.config.mjs file:
{ experimental: { liveContentCollections: true, },}Then create a new src/live.config.ts file (alongside your src/content.config.ts if you have one) to define your live collections with a live loader and optionally a schema using the new defineLiveCollection() function from the astro:content module.
import { defineLiveCollection } from 'astro:content';import { storeLoader } from '@mystore/astro-loader';
const products = defineLiveCollection({ type: 'live', loader: storeLoader({ apiKey: process.env.STORE_API_KEY, endpoint: 'https://api.mystore.com/v1', }),});
export const collections = { products };You can then use the dedicated getLiveCollection() and getLiveEntry() functions to access your live data:
---import { getLiveCollection, getLiveEntry, render } from 'astro:content';
// Get all productsconst { entries: allProducts, error } = await getLiveCollection('products');if (error) { // Handle error appropriately console.error(error.message);}
// Get products with a filter (if supported by your loader)const { entries: electronics } = await getLiveCollection('products', { category: 'electronics' });
// Get a single product by ID (string syntax)const { entry: product, error: productError } = await getLiveEntry('products', Astro.params.id);if (productError) { return Astro.redirect('/404');}
// Get a single product with a custom query (if supported by your loader) using a filter objectconst { entry: productBySlug } = await getLiveEntry('products', { slug: Astro.params.slug });
const { Content } = await render(product);---
<h1>{product.title}</h1><Content />See the docs for the experimental live content collections feature for more details on how to use this feature, including how to create a live loader. Please give feedback on the RFC PR if you have any suggestions or issues.
#13957 304df34 Thanks @ematipico! - Fixes an issue where report-uri wasnโt available in experimental.csp.directives, causing a typing error and a runtime validation error.
#13957 304df34 Thanks @ematipico! - Fixes a type error for the CSP directives upgrade-insecure-requests, sandbox, and trusted-type.
#13862 fe8f61a Thanks @florian-lefebvre! - Fixes a case where the dev toolbar would crash if it could not retrieve some essential data
#13976 0a31d99 Thanks @florian-lefebvre! - Fixes a case where Astro Actions types would be broken when using a tsconfig.json with "moduleResolution": "nodenext"
#13923 a9ac5ed Thanks @ematipico! - BREAKING CHANGE to the experimental Content Security Policy (CSP) only
Changes the behavior of experimental Content Security Policy (CSP) to now serve hashes differently depending on whether or not a page is prerendered:
<meta> element for static pages.Response header content-security-policy for on-demand rendered pages.This new strategy allows you to add CSP content that is not supported in a <meta> element (e.g. report-uri, frame-ancestors, and sandbox directives) to on-demand rendered pages.
No change to your project code is required as this is an implementation detail. However, this will result in a different HTML output for pages that are rendered on demand. Please check your production site to verify that CSP is working as intended.
To keep up to date with this developing feature, or to leave feedback, visit the CSP Roadmap proposal.
#13926 953a249 Thanks @ematipico! - Adds a new Astro Adapter Feature called experimentalStaticHeaders to allow your adapter to receive the Headers for rendered static pages.
Adapters that enable support for this feature can access header values directly, affecting their handling of some Astro features such as Content Security Policy (CSP). For example, Astro will no longer serve the CSP <meta http-equiv="content-security-policy"> element in static pages to adapters with this support.
Astro will serve the value of the header inside a map that can be retrieved from the hook astro:build:generated. Adapters can read this mapping and use their hosting headers capabilities to create a configuration file.
A new field called experimentalRouteToHeaders will contain a map of Map<IntegrationResolvedRoute, Headers> where the Headers type contains the headers emitted by the rendered static route.
To enable support for this experimental Astro Adapter Feature, add it to your adapterFeatures in your adapter config:
export default function createIntegration() { return { name: '@example/my-adapter', hooks: { 'astro:config:done': ({ setAdapter }) => { setAdapter({ name: '@example/my-adapter', serverEntrypoint: '@example/my-adapter/server.js', adapterFeatures: { experimentalStaticHeaders: true, }, }); }, }, };}See the Adapter API docs for more information about providing adapter features.
#13697 af83b85 Thanks @benosmac! - Fixes issues with fallback route pattern matching when i18n.routing.fallbackType is rewrite.
generatePath when building fallback routes and checking for existing translated pagesNow for a route to be matched it needs to be inside a named [locale] folder. This fixes an issue where route.pattern.test() incorrectly matched dynamic routes, causing the page to be skipped.
findRouteToRewriteNow the requested pathname must exist in route.distURL for a dynamic route to match. This fixes an issue where route.pattern.test() incorrectly matched dynamic routes, causing the build to fail.
#13924 1cd8c3b Thanks @qw-in! - Fixes an edge case where isPrerendered was incorrectly set to false for static redirects.
#13926 953a249 Thanks @ematipico! - Fixes an issue where the experimental CSP meta element wasnโt placed in the <head> element as early as possible, causing these policies to not apply to styles and scripts that came before the meta element.
#13919 423fe60 Thanks @ematipico! - Fixes a bug where Astro added quotes to the CSP resources.
Only certain resources require quotes (e.g. 'self' but not https://cdn.example.com), so Astro no longer adds quotes to any resources. You must now provide the quotes yourself for resources such as 'self' when necessary:
export default defineConfig({ experimental: { csp: { styleDirective: { resources: [ "self", "'self'", "https://cdn.example.com" ] } } }})#13914 76c5480 Thanks @ematipico! - BREAKING CHANGE to the experimental Content Security Policy feature only
Removes support for experimental Content Security Policy (CSP) when using the <ClientRouter /> component for view transitions.
It is no longer possible to enable experimental CSP while using Astroโs view transitions. Support was already unstable with the <ClientRouter /> because CSP required making its underlying implementation asynchronous. This caused breaking changes for several users and therefore, this PR removes support completely.
If you are currently using the component for view transitions, please remove the experimental CSP flag as they cannot be used together.
import { defineConfig } from 'astro/config';
export default defineConfig({ experimental: { csp: true }});Alternatively, to continue using experimental CSP in your project, you can consider migrating to the browser native View Transition API and remove the <ClientRouter /> from your project. You may be able to achieve similar results if you are not using Astroโs enhancements to the native View Transitions and Navigation APIs.
Support might be reintroduced in future releases. You can follow this experimental featureโs development in the CSP RFC.
#13899 7a1303d Thanks @reknih! - Fix bug where error pages would return invalid bodies if the upstream response was compressed
#13902 051bc30 Thanks @arHSM! - Fixes a bug where vite virtual module ids were incorrectly added in the dev server
#13905 81f71ca Thanks @jsparkdev! - Fixes wrong contents in CSP meta tag.
#13907 8246bcc Thanks @martrapp! - Fixes a bug that caused view transition names to be lost.
#13901 37fa0a2 Thanks @ansg191! - fix fallback not being removed when server island is rendered
#13802 0eafe14 Thanks @ematipico! - Adds experimental Content Security Policy (CSP) support
CSP is an important feature to provide fine-grained control over resources that can or cannot be downloaded and executed by a document. In particular, it can help protect against cross-site scripting (XSS) attacks.
Enabling this feature adds additional security to Astroโs handling of processed and bundled scripts and styles by default, and allows you to further configure these, and additional, content types. This new experimental feature has been designed to work in every Astro rendering environment (static pages, dynamic pages and single page applications), while giving you maximum flexibility and with type-safety in mind.
It is compatible with most of Astroโs features such as client islands, and server islands, although Astroโs view transitions using the <ClientRouter /> are not yet fully supported. Inline scripts are not supported out of the box, but you can provide your own hashes for external and inline scripts.
To enable this feature, add the experimental flag in your Astro config:
import { defineConfig } from 'astro/config';
export default defineConfig({ experimental: { csp: true, },});For more information on enabling and using this feature in your project, see the Experimental CSP docs.
For a complete overview, and to give feedback on this experimental API, see the Content Security Policy RFC.
#13850 1766d22 Thanks @ascorbic! - Provides a Markdown renderer to content loaders
When creating a content loader, you will now have access to a renderMarkdown function that allows you to render Markdown content directly within your loaders. It uses the same settings and plugins as the renderer used for Markdown files in Astro, and follows any Markdown settings you have configured in your Astro project.
This allows you to render Markdown content from various sources, such as a CMS or other data sources, directly in your loaders without needing to preprocess the Markdown content separately.
import type { Loader } from 'astro/loaders';import { loadFromCMS } from './cms';
export function myLoader(settings): Loader { return { name: 'my-loader', async load({ renderMarkdown, store }) { const entries = await loadFromCMS();
store.clear();
for (const entry of entries) { // Assume each entry has a 'content' field with markdown content store.set(entry.id, { id: entry.id, data: entry, rendered: await renderMarkdown(entry.content), }); } }, };}The return value of renderMarkdown is an object with two properties: html and metadata. These match the rendered property of content entries in content collections, so you can use them to render the content in your components or pages.
---import { getEntry, render } from 'astro:content';const entry = await getEntry('my-collection', Astro.params.id);const { Content } = await render(entry);---
<Content />For more information, see the Content Loader API docs.
#13887 62f0668 Thanks @yanthomasdev! - Adds an option for integration authors to suppress adapter warning/errors in supportedAstroFeatures. This is useful when either an warning/error isnโt applicable in a specific context or the default one might conflict and confuse users.
To do so, you can add suppress: "all" (to suppress both the default and custom message) or suppress: "default" (to only suppress the default one):
setAdapter({ name: 'my-astro-integration', supportedAstroFeatures: { staticOutput: 'stable', hybridOutput: 'stable', sharpImageService: { support: 'limited', message: "The sharp image service isn't available in the deploy environment, but will be used by prerendered pages on build.", suppress: 'default', }, },});For more information, see the Adapter API reference docs.
#13877 5a7797f Thanks @yuhang-dong! - Fixes a bug that caused Astro.rewrite to fail when used in sequenced middleware
#13872 442b841 Thanks @isVivek99! - Fixes rendering of the download attribute when it has a boolean value
#13037 de2fc9b Thanks @nanarino! - Fixes rendering of the popover attribute when it has a boolean value
#13851 45ae95a Thanks @ascorbic! - Allows disabling default styles for responsive images
This change adds a new image.experimentalDefaultStyles option that allows you to disable the default styles applied to responsive images.
When using experimental responsive images, Astro applies default styles to ensure the images resize correctly. In most cases this is what you want โ and they are applied with low specificity so your own styles override them. However in some cases you may want to disable these default styles entirely. This is particularly useful when using Tailwind 4, because it uses CSS cascade layers to apply styles, making it difficult to override the default styles.
image.experimentalDefaultStyles is a boolean option that defaults to true, so you can change it in your Astro config file like this:
export default { image: { experimentalDefaultStyles: false, }, experimental: { responsiveImages: true, },};#13858 cb1a168 Thanks @florian-lefebvre! - Fixes the warning shown when client directives are used on Astro components
#12574 da266d0 Thanks @apatel369! - Allows using server islands in mdx files
#13843 fbcfa68 Thanks @z1haze! - Export type AstroSession to allow use in explicitly typed safe code.
#13809 3c3b492 Thanks @ascorbic! - Increases minimum Node.js version to 18.20.8
Node.js 18 has now reached end-of-life and should not be used. For now, Astro will continue to support Node.js 18.20.8, which is the final LTS release of Node.js 18, as well as Node.js 20 and Node.js 22 or later. We will drop support for Node.js 18 in a future release, so we recommend upgrading to Node.js 22 as soon as possible. See Astroโs Node.js support policy for more details.
:warning: Important note for users of Cloudflare Pages: The current build image for Cloudflare Pages uses Node.js 18.17.1 by default, which is no longer supported by Astro. If you are using Cloudflare Pages you should override the default Node.js version to Node.js 22. This does not affect users of Cloudflare Workers, which uses Node.js 22 by default.
3c3b492]:
#13773 3aa5337 Thanks @sijad! - Ignores lightningcss unsupported pseudo-class warning.
#13833 5a6d2ae Thanks @ascorbic! - Fixes an issue where session modules would fail to resolve in Node.js < 20.6
#13383 f7f712c Thanks @Haberkamp! - Stop toolbar settings from overflowing
#13794 85b19d8 Thanks @alexcarpenter! - Exclude pre tags from a11y-no-noninteractive-tabindex audit check.
#13373 50ef568 Thanks @jpwienekus! - Fixes a bug where highlights and tooltips render over the audit list window.
#13769 e9fc456 Thanks @romanstetsyk! - Expand ActionError codes to include all IANA-registered HTTP error codes.
#13668 866285a Thanks @sapphi-red! - Replaces internal CSS chunking behavior for Astro componentsโ scoped styles to use Viteโs cssScopeTo feature. The feature is a port of Astroโs implementation so this should not change the behavior.
#13761 a2e8463 Thanks @jp-knj! - Adds new content collections errors
#13788 7d0b7ac Thanks @florian-lefebvre! - Fixes a case where an error would not be thrown when using the <Font /> component from the experimental fonts API without adding fonts in the Astro config
#13784 d7a1889 Thanks @florian-lefebvre! - Fixes the experimental fonts API to correctly take config.base, config.build.assets and config.build.assetsPrefix into account
#13777 a56b8ea Thanks @L4Ph! - Fixed an issue where looping GIF animation would stop when converted to WebP
#13566 0489d8f Thanks @TheOtterlord! - Fix build errors being ignored when build.concurrency > 1
#13752 a079c21 Thanks @florian-lefebvre! - Improves handling of font URLs not ending with a file extension when using the experimental fonts API
#13750 7d3127d Thanks @martrapp! - Allows the ClientRouter to open new tabs or windows when submitting forms by clicking while holding the Cmd, Ctrl, or Shift key.
#13765 d874fe0 Thanks @florian-lefebvre! - Fixes a case where font sources with relative protocol URLs would fail when using the experimental fonts API
#13640 5e582e7 Thanks @florian-lefebvre! - Allows inferring weight and style when using the local provider of the experimental fonts API
If you want Astro to infer those properties directly from your local font files, leave them undefined:
{ // No weight specified: infer style: 'normal'; // Do not infer}#13734 30aec73 Thanks @ascorbic! - Loosen content layer schema types
#13751 5816b8a Thanks @florian-lefebvre! - Updates unifont to support subsets when using the google provider with the experimental fonts API
#13756 d4547ba Thanks @florian-lefebvre! - Adds a terminal warning when a remote provider returns no data for a family when using the experimental fonts API
#13742 f599463 Thanks @florian-lefebvre! - Fixes optimized fallback css generation to properly add a src when using the experimental fonts API
#13740 6935540 Thanks @vixalien! - Fix cookies set after middleware did a rewrite with next(url) not being applied
#13759 4a56d0a Thanks @jp-knj! - Improved the error handling of certain error cases.
c3e80c2 Thanks @jsparkdev! - update vite to latest version for fixing CVEb32dffa Thanks @florian-lefebvre! - Updates unifont to fix a case where a unicodeRange related error would be thrown when using the experimental fonts API#13705 28f8716 Thanks @florian-lefebvre! - Updates unifont to latest and adds support for fetch options from remote providers when using the experimental fonts API
#13692 60d5be4 Thanks @Le0Developer! - Fixes a bug where Astro couldnโt probably use inferSize for images that contain apostrophe ' in their name.
#13698 ab98f88 Thanks @sarah11918! - Improves the configuration reference docs for the adapter entry with more relevant text and links.
#13706 b4929ae Thanks @ascorbic! - Fixes typechecking for content config schema
#13653 a7b2dc6 Thanks @florian-lefebvre! - Reduces the amount of preloaded files for the local provider when using the experimental fonts API
#13653 a7b2dc6 Thanks @florian-lefebvre! - Fixes a case where invalid CSS was emitted when using an experimental fonts API family name containing a space
#13703 659904b Thanks @florian-lefebvre! - Fixes a bug where empty fallbacks could not be provided when using the experimental fonts API
#13680 18e1b97 Thanks @florian-lefebvre! - Improves the UnsupportedExternalRedirect error message to include more details such as the concerned destination
#13703 659904b Thanks @ascorbic! - Simplifies styles for experimental responsive images
:warning: BREAKING CHANGE FOR EXPERIMENTAL RESPONSIVE IMAGES ONLY :warning:
The generated styles for image layouts are now simpler and easier to override. Previously the responsive image component used CSS to set the size and aspect ratio of the images, but this is no longer needed. Now the styles just include object-fit and object-position for all images, and sets max-width: 100% for constrained images and width: 100% for full-width images.
This is an implementation change only, and most users will see no change. However, it may affect any custom styles you have added to your responsive images. Please check your rendered images to determine whether any change to your CSS is needed.
The styles now use the :where() pseudo-class, which has a specificity of 0, meaning that it is easy to override with your own styles. You can now be sure that your own classes will always override the applied styles, as will global styles on img.
An exception is Tailwind 4, which uses cascade layers, meaning the rules are always lower specificity. Astro supports browsers that do not support cascade layers, so we cannot use this. If you need to override the styles using Tailwind 4, you must use !important classes. Do check if this is needed though: there may be a layout that is more appropriate for your use case.
#13703 659904b Thanks @ascorbic! - Adds warnings about using local font files in the publicDir when the experimental fonts API is enabled.
#13703 659904b Thanks @ascorbic! - Renames experimental responsive image layout option from โresponsiveโ to โconstrainedโ
:warning: BREAKING CHANGE FOR EXPERIMENTAL RESPONSIVE IMAGES ONLY :warning:
The layout option called "responsive" is renamed to "constrained" to better reflect its behavior.
The previous name was causing confusion, because it is also the name of the feature. The responsive layout option is specifically for images that are displayed at the requested size, unless they do not fit the width of their container, at which point they would be scaled down to fit. They do not get scaled beyond the intrinsic size of the source image, or the width prop if provided.
It became clear from user feedback that many people (understandably) thought that they needed to set layout to responsive if they wanted to use responsive images. They then struggled with overriding styles to make the image scale up for full-width hero images, for example, when they should have been using full-width layout. Renaming the layout to constrained should make it clearer that this layout is for when you want to constrain the maximum size of the image, but allow it to scale-down.
If you set a default image.experimentalLayout in your astro.config.mjs, or set it on a per-image basis using the layout prop, you will need to change all occurences to constrained:
export default { image: { experimentalLayout: 'responsive', experimentalLayout: 'constrained', },}---import { Image } from 'astro:assets';--- <Image src="/image.jpg" layout="responsive" /> <Image src="/image.jpg" layout="constrained" />Please give feedback on the RFC if you have any questions or comments about the responsive images API.
#13660 620d15d Thanks @mingjunlu! - Adds server.allowedHosts docs comment to AstroUserConfig
#13591 5dd2d3f Thanks @florian-lefebvre! - Removes unused code
#13669 73f24d4 Thanks @ematipico! - Fixes an issue where Astro.originPathname wasnโt returning the correct value when using rewrites.
#13674 42388b2 Thanks @florian-lefebvre! - Fixes a case where an experimental fonts API error would be thrown when using another astro:assets API
#13654 4931457 Thanks @florian-lefebvre! - Fixes fontProviders.google() so it can forward options to the unifont provider, when using the experimental fonts API
Updated dependencies [5dd2d3f]:
#13647 ffbe8f2 Thanks @ascorbic! - Fixes a bug that caused a session error to be logged when using actions without sessions
#13646 6744842 Thanks @florian-lefebvre! - Fixes a case where extra font sources were removed when using the experimental fonts API
#13635 d75cac4 Thanks @florian-lefebvre! - The experimental fonts API now generates optimized fallbacks for every weight and style
#13643 67b7493 Thanks @tanishqmanuja! - Fixes a case where the font face src format would be invalid when using the experimental fonts API
#13639 23410c6 Thanks @florian-lefebvre! - Fixes a case where some font families would not be downloaded when using the same font provider several times, using the experimental fonts API
#13632 cb05cfb Thanks @florian-lefebvre! - Improves the optimized fallback name generated by the experimental Fonts API
#13630 3e7db4f Thanks @florian-lefebvre! - Fixes a case where fonts using a local provider would not work because of an invalid generated src
#13634 516de7d Thanks @ematipico! - Fixes a regression where using next('/') didnโt correctly return the requested route.
#13632 cb05cfb Thanks @florian-lefebvre! - Improves the quality of optimized fallbacks generated by the experimental Fonts API
#13616 d475afc Thanks @lfilho! - Fixes a regression where relative static redirects didnโt work as expected.
#13594 dc4a015 Thanks @florian-lefebvre! - Reduces the number of font files downloaded
#13627 7f1a624 Thanks @florian-lefebvre! - Fixes a case where using the <Font /> component would throw a Rollup error during the build
#13626 3838efe Thanks @florian-lefebvre! - Updates fallback font generation to always read font files returned by font providers
#13625 f1311d2 Thanks @florian-lefebvre! - Updates the <Font /> component so that preload links are generated before the style tag if preload is passed
#13622 a70d32a Thanks @ascorbic! - Improve autocomplete for session keys
#13527 2fd6a6b Thanks @ascorbic! - The experimental session API introduced in Astro 5.1 is now stable and ready for production use.
Sessions are used to store user state between requests for on-demand rendered pages. You can use them to store user data, such as authentication tokens, shopping cart contents, or any other data that needs to persist across requests:
---export const prerender = false; // Not needed with 'server' outputconst cart = await Astro.session.get('cart');---
<a href="/checkout">๐ {cart?.length ?? 0} items</a>Sessions require a storage driver to store the data. The Node, Cloudflare and Netlify adapters automatically configure a default driver for you, but other adapters currently require you to specify a custom storage driver in your configuration.
If you are using an adapter that doesnโt have a default driver, or if you want to choose a different driver, you can configure it using the session configuration option:
import { defineConfig } from 'astro/config';import vercel from '@astrojs/vercel';
export default defineConfig({ adapter: vercel(), session: { driver: 'upstash', },});Sessions are available in on-demand rendered pages, API endpoints, actions and middleware.
In pages and components, you can access the session using Astro.session:
---const cart = await Astro.session.get('cart');---
<a href="/checkout">๐ {cart?.length ?? 0} items</a>In endpoints, actions, and middleware, you can access the session using context.session:
export async function GET(context) { const cart = await context.session.get('cart'); return Response.json({ cart });}If you attempt to access the session when there is no storage driver configured, or in a prerendered page, the session object will be undefined and an error will be logged in the console:
---export const prerender = true;const cart = await Astro.session?.get('cart'); // Logs an error. Astro.session is undefined---If you were previously using the experimental API, please remove the experimental.session flag from your configuration:
import { defineConfig } from 'astro/config';import node from '@astrojs/node';
export default defineConfig({ adapter: node({ mode: "standalone", }), experimental: { session: true, },});See the sessions guide for more information.
#12775 b1fe521 Thanks @florian-lefebvre! - Adds a new, experimental Fonts API to provide first-party support for fonts in Astro.
This experimental feature allows you to use fonts from both your file system and several built-in supported providers (e.g. Google, Fontsource, Bunny) through a unified API. Keep your site performant thanks to sensible defaults and automatic optimizations including fallback font generation.
To enable this feature, configure an experimental.fonts object with one or more fonts:
import { defineConfig, fontProviders } from "astro/config"
export default defineConfig({ experimental: { fonts: [{ provider: fontProviders.google(), ` name: "Roboto", cssVariable: "--font-roboto", }] }})Then, add a <Font /> component and site-wide styling in your <head>:
---import { Font } from 'astro:assets';---
<Font cssVariable="--font-roboto" preload /><style> body { font-family: var(--font-roboto); }</style>Visit the experimental Fonts documentation for the full API, how to get started, and even how to build your own custom AstroFontProvider if we donโt yet support your preferred font service.
For a complete overview, and to give feedback on this experimental API, see the Fonts RFC and help shape its future.
#13560 df3fd54 Thanks @ematipico! - The virtual module astro:config introduced behind a flag in v5.2.0 is no longer experimental and is available for general use.
This virtual module exposes two sub-paths for type-safe, controlled access to your configuration:
astro:config/client: exposes config information that is safe to expose to the client.astro:config/server: exposes additional information that is safe to expose to the server, such as file and directory paths.Access these in any file inside your project to import and use select values from your Astro config:
import { trailingSlash } from 'astro:config/client';
function addForwardSlash(path) { if (trailingSlash === 'always') { return path.endsWith('/') ? path : path + '/'; } else { return path; }}If you were previously using this feature, please remove the experimental flag from your Astro config:
export default defineConfig({ experimental: { serializeConfig: true }})If you have been waiting for feature stabilization before using configuration imports, you can now do so.
Please see the astro:config reference for more about this feature.
#13578 406501a Thanks @stramel! - The SVG import feature introduced behind a flag in v5.0.0 is no longer experimental and is available for general use.
This feature allows you to import SVG files directly into your Astro project as components and inline them into your HTML.
To use this feature, import an SVG file in your Astro project, passing any common SVG attributes to the imported component.
---import Logo from './path/to/svg/file.svg';---
<Logo width={64} height={64} fill="currentColor" />If you have been waiting for stabilization before using the SVG Components feature, you can now do so.
If you were previously using this feature, please remove the experimental flag from your Astro config:
import { defineConfig } from 'astro'
export default defineConfig({ experimental: { svg: true, }})Additionally, a few features that were available during the experimental stage were removed in a previous release. Please see the v5.6.0 changelog for details if you have not yet already updated your project code for the experimental feature accordingly.
Please see the SVG Components guide in docs for more about this feature.
#13602 3213450 Thanks @natemoo-re! - Updates the Audit dev toolbar app to automatically strip data-astro-source-file and data-astro-source-loc attributes in dev mode.
#13598 f5de51e Thanks @dreyfus92! - Fix routing with base paths when trailingSlash is set to โneverโ. This ensures requests to โ/baseโ are correctly matched when the base path is set to โ/baseโ, without requiring a trailing slash.
#13603 d038030 Thanks @sarah11918! - Adds the minimal starter template to the list of create astro options
Good news if youโre taking the introductory tutorial in docs, making a minimal reproduction, or just want to start a project with as little to rip out as possible. Astroโs minimal (empty) template is now back as one of the options when running create astro@latest and starting a new project!
#13606 793ecd9 Thanks @natemoo-re! - Fixes a regression that allowed prerendered code to leak into the server bundle.
#13576 1c60ec3 Thanks @ascorbic! - Reduces duplicate code in server islands scripts by extracting shared logic into a helper function.
#13588 57e59be Thanks @natemoo-re! - Fixes a memory leak when using SVG assets.
#13589 5a0563d Thanks @ematipico! - Deprecates the asset utility function emitESMImage() and adds a new emitImageMetadata() to be used instead
The function
emitESMImage() is now deprecated. It will continue to function, but it is no longer recommended nor supported. This function will be completely removed in a next major release of Astro.
Please replace it with the new functionemitImageMetadata() as soon as you are able to do so:
import { emitESMImage } from "astro/assets/utils";import { emitImageMetadata } from "astro/assets/utils";The new function returns the same signature as the previous one. However, the new function removes two deprecated arguments that were not meant to be exposed for public use: _watchMode and experimentalSvgEnabled. Since it was possible to access these with the old function, you may need to verify that your code still works as intended with emitImageMetadata().
#13596 3752519 Thanks @jsparkdev! - update vite to latest version to fix CVE
#13547 360cb91 Thanks @jsparkdev! - Updates vite to the latest version
#13548 e588527 Thanks @ryuapp! - Support for Deno to install npm pacakges.
Deno requires npm prefix to install packages on npm. For example, to install react, we need to run deno add npm:react. But currently the command executed is deno add react, which doesnโt work. So, we change the package names to have an npm prefix if you are using Deno.
#13587 a0774b3 Thanks @robertoms99! - Fixes an issue with the client router where some attributes of the root element were not updated during swap, including the transition scope.
#13519 3323f5c Thanks @florian-lefebvre! - Refactors some internals to improve Rolldown compatibility
#13545 a7aff41 Thanks @stramel! - Prevent empty attributes from appearing in the SVG output
#13552 9cd0fd4 Thanks @ematipico! - Fixes an issue where Astro validated the i18n configuration incorrectly, causing false positives in downstream libraries.
#13403 dcb9526 Thanks @yurynix! - Adds a new optional prerenderedErrorPageFetch option in the Adapter API to allow adapters to provide custom implementations for fetching prerendered error pages.
Now, adapters can override the default fetch() behavior, for example when fetch() is unavailable or when you cannot call the server from itself.
The following example provides a custom fetch for 500.html and 404.html, reading them from disk instead of performing an HTTP call:
return app.render(request, { prerenderedErrorPageFetch: async (url: string): Promise<Response> => { if (url.includes("/500")) { const content = await fs.promises.readFile("500.html", "utf-8"); return new Response(content, { status: 500, headers: { "Content-Type": "text/html" }, }); } const content = await fs.promises.readFile("404.html", "utf-8"); return new Response(content, { status: 404, headers: { "Content-Type": "text/html" }, });});If no value is provided, Astro will fallback to its default behavior for fetching error pages.
Read more about this feature in the Adapter API reference.
#13482 ff257df Thanks @florian-lefebvre! - Updates Astro config validation to also run for the Integration API. An error log will specify which integration is failing the validation.
Now, Astro will first validate the user configuration, then validate the updated configuration after each integration astro:config:setup hook has run. This means updateConfig() calls will no longer accept invalid configuration.
This fixes a situation where integrations could potentially update a project with a malformed configuration. These issues should now be caught and logged so that you can update your integration to only set valid configurations.
#13405 21e7e80 Thanks @Marocco2! - Adds a new eagerness option for prefetch() when using experimental.clientPrerender
With the experimental clientPrerender flag enabled, you can use the eagerness option on prefetch() to suggest to the browser how eagerly it should prefetch/prerender link targets.
This follows the same API described in the Speculation Rules API and allows you to balance the benefit of reduced wait times against bandwidth, memory, and CPU costs for your site visitors.
For example, you can now use prefetch() programmatically with large sets of links and avoid browser limits in place to guard against over-speculating (prerendering/prefetching too many links). Set eagerness: 'moderate' to take advantage of First In, First Out (FIFO) strategies and browser heuristics to let the browser decide when to prerender/prefetch them and in what order:
<a class="link-moderate" href="/nice-link-1">A Nice Link 1</a><a class="link-moderate" href="/nice-link-2">A Nice Link 2</a><a class="link-moderate" href="/nice-link-3">A Nice Link 3</a><a class="link-moderate" href="/nice-link-4">A Nice Link 4</a>...<a class="link-moderate" href="/nice-link-20">A Nice Link 20</a><script> import { prefetch } from 'astro:prefetch'; const linkModerate = document.getElementsByClassName('link-moderate'); linkModerate.forEach((link) => prefetch(link.getAttribute('href'), { eagerness: 'moderate' }));</script>#13482 ff257df Thanks @florian-lefebvre! - Improves integrations error handling
If an error is thrown from an integration hook, an error log will now provide information about the concerned integration and hook
#13539 c43bf8c Thanks @ascorbic! - Adds a new session.load() method to the experimental session API that allows you to load a session by ID.
When using the experimental sessions API, you donโt normally need to worry about managing the session ID and cookies: Astro automatically reads the userโs cookies and loads the correct session when needed. However, sometimes you need more control over which session to load.
The new load() method allows you to manually load a session by ID. This is useful if you are handling the session ID yourself, or if you want to keep track of a session without using cookies. For example, you might want to restore a session from a logged-in user on another device, or work with an API endpoint that doesnโt use cookies.
import type { APIRoute } from 'astro';
export const GET: APIRoute = async ({ session, request }) => { // Load the session from a header instead of cookies const sessionId = request.headers.get('x-session-id'); await session.load(sessionId); const cart = await session.get('cart'); return Response.json({ cart });};If a session with that ID doesnโt exist, a new one will be created. This allows you to generate a session ID in the client if needed.
For more information, see the experimental sessions docs.
#13488 d777420 Thanks @stramel! - BREAKING CHANGE to the experimental SVG Component API only
Removes some previously available prop, attribute, and configuration options from the experimental SVG API. These items are no longer available and must be removed from your code:
The title prop has been removed until we can settle on the correct balance between developer experience and accessibility. Please replace any title props on your components with aria-label:
<Logo title="My Company Logo" /><Logo aria-label="My Company Logo" />Sprite mode has been temporarily removed while we consider a new implementation that addresses how this feature was being used in practice. This means that there are no longer multiple mode options, and all SVGs will be inline. All instances of mode must be removed from your project as you can no longer control a mode:
<Logo mode="inline" /><Logo />import { defineConfig } from 'astro'
export default defineConfig({ experimental: { svg: { mode: 'sprite' }, svg: true }});The default role is no longer applied due to developer feedback. Please add the appropriate role on each component individually as needed:
<Logo /><Logo role="img" /> // To keep the role that was previously applied by defaultThe size prop has been removed to better work in combination with viewBox and additional styles/attributes. Please replace size with explicit width and height attributes:
<Logo size={64} /><Logo width={64} height={64} />#13429 06de673 Thanks @ematipico! - The ActionAPIContext.rewrite method is deprecated and will be removed in a future major version of Astro
#13524 82cd583 Thanks @ematipico! - Fixes a bug where the functions Astro.preferredLocale and Astro.preferredLocaleList would return the incorrect locales
when the Astro configuration specifies a list of codes. Before, the functions would return the path, instead now the functions
return a list built from codes.
#13526 ff9d69e Thanks @jsparkdev! - update vite to the latest version
#13510 5b14d33 Thanks @florian-lefebvre! - Fixes a case where astro:env secrets used in actions would not be available
#13485 018fbe9 Thanks @ascorbic! - Fixes a bug that caused cookies to ignore custom decode function if has() had been called before
#13505 a98ae5b Thanks @ematipico! - Updates the dependency vite to the latest.
#13483 fc2dcb8 Thanks @ematipico! - Fixes a bug where an Astro adapter couldnโt call the middleware when there isnโt a route that matches the incoming request.
#13457 968e713 Thanks @ascorbic! - Sets correct response status text for custom error pages
#13447 d80ba2b Thanks @ematipico! - Fixes an issue where site was added to the generated redirects.
#13481 e9e9245 Thanks @martrapp! - Makes server island work with the client router again.
#13484 8b5e4dc Thanks @ascorbic! - Display useful errors when config loading fails because of Node addons being disabled on Stackblitz
#13437 013fa87 Thanks @Vardhaman619! - Handle server.allowedHosts when the value is true without attempting to push it into an array.
#13324 ea74336 Thanks @ematipico! - Upgrade to shiki v3
#13372 7783dbf Thanks @ascorbic! - Fixes a bug that caused some very large data stores to save incomplete data.
#13358 8c21663 Thanks @ematipico! - Adds a new function called insertPageRoute to the Astro Container API.
The new function is useful when testing routes that, for some business logic, use Astro.rewrite.
For example, if you have a route /blog/post and for some business decision thereโs a rewrite to /generic-error, the container API implementation will look like this:
import Post from '../src/pages/Post.astro';import GenericError from '../src/pages/GenericError.astro';import { experimental_AstroContainer as AstroContainer } from 'astro/container';
const container = await AstroContainer.create();container.insertPageRoute('/generic-error', GenericError);const result = await container.renderToString(Post);console.log(result); // this should print the response from GenericError.astroThis new method only works for page routes, which means that endpoints arenโt supported.
#13426 565583b Thanks @ascorbic! - Fixes a bug that caused the astro add command to ignore the --yes flag for third-party integrations
#13428 9cac9f3 Thanks @matthewp! - Prevent bad value in x-forwarded-host from crashing request
#13432 defad33 Thanks @P4tt4te! - Fix an issue in the Container API, where the renderToString function doesnโt render adequately nested slots when they are components.
Updated dependencies [ea74336]:
#13415 be866a1 Thanks @ascorbic! - Reuses experimental session storage object between requests. This prevents memory leaks and improves performance for drivers that open persistent connections to a database.
#13420 2f039b9 Thanks @ematipico! - It fixes an issue that caused some regressions in how styles are bundled.
#13402 3e7b498 Thanks @ematipico! - Adds a new experimental flag called experimental.preserveScriptOrder that renders <script> and <style> tags in the same order as they are defined.
When rendering multiple <style> and <script> tags on the same page, Astro currently reverses their order in your generated HTML output. This can give unexpected results, for example CSS styles being overridden by earlier defined style tags when your site is built.
With the new preserveScriptOrder flag enabled, Astro will generate the styles in the order they are defined:
import { defineConfig } from 'astro/config';
export default defineConfig({ experimental: { preserveScriptOrder: true, },});For example, the following component has two <style> tags, and both define the same style for the body tag:
<p>I am a component</p><style> body { background: red; }</style><style> body { background: yellow; }</style>Once the project is compiled, Astro will create an inline style where yellow appears first, and then red. Ultimately, the red background is applied:
body { background: #ff0;}body { background: red;}When experimental.preserveScriptOrder is set to true, the order of the two styles is kept as it is, and in the style generated red appears first, and then yellow:
body { background: red;}body { background: #ff0;}This is a breaking change to how Astro renders project code that contains multiple <style> and <script> tags in the same component. If you were previously compensating for Astroโs behavior by writing these out of order, you will need to update your code.
This will eventually become the new default Astro behavior, so we encourage you to add this experimental style and script ordering as soon as you are able! This will help us test the new behavior and ensure your code is ready when this becomes the new normal.
For more information as this feature develops, please see the experimental script order docs.
#13352 cb886dc Thanks @delucis! - Adds support for a new experimental.headingIdCompat flag
By default, Astro removes a trailing - from the end of IDs it generates for headings ending with
special characters. This differs from the behavior of common Markdown processors.
You can now disable this behavior with a new configuration flag:
import { defineConfig } from 'astro/config';
export default defineConfig({ experimental: { headingIdCompat: true, },});This can be useful when heading IDs and anchor links need to behave consistently across your site and other platforms such as GitHub and npm.
If you are using the rehypeHeadingIds plugin directly, you can also pass this new option:
import { defineConfig } from 'astro/config';import { rehypeHeadingIds } from '@astrojs/markdown-remark';import { otherPluginThatReliesOnHeadingIDs } from 'some/plugin/source';
export default defineConfig({ markdown: { rehypePlugins: [ [rehypeHeadingIds, { experimentalHeadingIdCompat: true }], otherPluginThatReliesOnHeadingIDs, ], },});#13311 a3327ff Thanks @chrisirhc! - Adds a new configuration option for Markdown syntax highlighting excludeLangs
This option provides better support for diagramming tools that rely on Markdown code blocks, such as Mermaid.js and D2 by allowing you to exclude specific languages from Astroโs default syntax highlighting.
This option allows you to avoid rendering conflicts with tools that depend on the code not being highlighted without forcing you to disable syntax highlighting for other code blocks.
The following example configuration will exclude highlighting for mermaid and math code blocks:
import { defineConfig } from 'astro/config';
export default defineConfig({ markdown: { syntaxHighlight: { type: 'shiki', excludeLangs: ['mermaid', 'math'], }, },});Read more about this new option in the Markdown syntax highlighting configuration docs.
#13404 4e78b4d Thanks @ascorbic! - Fixes a bug in error handling that saving a content file with a schema error would display an โunhandled rejectionโ error instead of the correct schema error
#13379 d59eb22 Thanks @martrapp! - Fixes an edge case where the client router executed scripts twice when used with a custom swap function that only swaps parts of the DOM.
#13393 6b8fdb8 Thanks @renovate! - Updates primsjs to version 1.30.0, which adds support for more languages and fixes a security advisory which does not affect Astro.
#13374 7b75bc5 Thanks @ArmandPhilippot! - Fixes the documentation of the i18n configuration where manual was presented as a key of routing instead of an available value.
#13380 9bfa6e6 Thanks @martrapp! - Fixes an issue where astro:page-load fires before all scripts are executed
#13407 0efdc22 Thanks @ascorbic! - Displays correct error message when sharp isnโt installed
Updated dependencies [cb886dc, a3327ff]:
#13381 249d52a Thanks @martrapp! - Adds the types property to the viewTransition object when the ClientRouter simulates parts of the View Transition API on browsers w/o native support.
#13367 3ce4ad9 Thanks @ematipico! - Adds documentation to various utility functions used for remote image services
#13347 d83f92a Thanks @bluwy! - Updates internal CSS chunking behavior for Astro componentsโ scoped styles. This may result in slightly more CSS chunks created, but should allow the scoped styles to only be included on pages that use them.
#13388 afadc70 Thanks @ematipico! - Fixes a bug where astro:config/server and astro:config/client had incorrect types.
#13355 042d1de Thanks @ematipico! - Adds documentation to the assets utilities for remote service images.
#13395 6d1c63f Thanks @bluwy! - Uses package-manager-detector to detect the package manager used in the project
#13363 a793636 Thanks @ematipico! - Fixes an issue where the internal function makeSvgComponent was incorrectly exposed as a public API.
Updated dependencies [042d1de]:
#12985 84e94cc Thanks @matthewp! - Prevent re-executing scripts in client router
#13349 50e2e0b Thanks @ascorbic! - Correctly escapes attributes in Markdown images
#13262 0025df3 Thanks @ematipico! - Refactor Astro Actions to not use a middleware. Doing so should avoid unexpected issues when using the Astro middleware at the edge.
#13336 8f632ef Thanks @ematipico! - Fixes a regression where some asset utilities were move across monorepo, and not re-exported anymore.
#13320 b5dabe9 Thanks @{! - Adds support for typing experimental session data
You can add optional types to your session data by creating a src/env.d.ts file in your project that extends the global App.SessionData interface. For example:
declare namespace App { interface SessionData {
id: string; email: string; }; lastLogin: Date; }}Any keys not defined in this interface will be treated as any.
Then when you access Astro.session in your components, any defined keys will be typed correctly:
---const user = await Astro.session.get('user');// ^? const: user: { id: string; email: string; } | undefined
const something = await Astro.session.get('something');// ^? const: something: any
Astro.session.set('user', 1);// ^? Argument of type 'number' is not assignable to parameter of type '{ id: string; email: string; }'.---See the experimental session docs for more information.
#13330 5e7646e Thanks @ematipico! - Fixes an issue with the conditional rendering of scripts.
This change updates a v5.0 breaking change when experimental.directRenderScript became the default script handling behavior.
If you have already successfully upgraded to Astro v5, you may need to review your script tags again and make sure they still behave as desired after this release. See the v5 Upgrade Guide for more details.
#12052 5be12b2 Thanks @Fryuni! - Exposes extra APIs for scripting and testing.
Two new helper functions exported from astro/config:
mergeConfig() allows users to merge partially defined Astro configurations on top of a base config while following the merge rules of updateConfig() available for integrations.validateConfig() allows users to validate that a given value is a valid Astro configuration and fills in default values as necessary.These helpers are particularly useful for integration authors and for developers writing scripts that need to manipulate Astro configurations programmatically.
The build API now receives a second optional BuildOptions argument where users can specify:
devOutput (default false): output a development-based build similar to code transformed in astro dev.teardownCompiler (default true): teardown the compiler WASM instance after build.These options provide more control when running Astro builds programmatically, especially for testing scenarios or custom build pipelines.
#13278 4a43c4b Thanks @ematipico! - Adds a new configuration option server.allowedHosts and CLI option --allowed-hosts.
Now you can specify the hostnames that the dev and preview servers are allowed to respond to. This is useful for allowing additional subdomains, or running the dev server in a web container.
allowedHosts checks the Host header on HTTP requests from browsers and if it doesnโt match, it will reject the request to prevent CSRF and XSS attacks.
astro dev --allowed-hosts=foo.bar.example.com,bar.example.comastro preview --allowed-hosts=foo.bar.example.com,bar.example.comimport { defineConfig } from 'astro/config';
export default defineConfig({ server: { allowedHosts: ['foo.bar.example.com', 'bar.example.com'], },});This feature is the same as Viteโs server.allowHosts configuration.
#13254 1e11f5e Thanks @p0lyw0lf! - Adds the ability to process and optimize remote images in Markdown files
Previously, Astro only allowed local images to be optimized when included using ![]() syntax in plain Markdown files. Astroโs image service could only display remote images without any processing.
Now, Astroโs image service can also optimize remote images written in standard Markdown syntax. This allows you to enjoy the benefits of Astroโs image processing when your images are stored externally, for example in a CMS or digital asset manager.
No additional configuration is required to use this feature! Any existing remote images written in Markdown will now automatically be optimized. To opt-out of this processing, write your images in Markdown using the HTML <img> tag instead. Note that images located in your public/ folder are still never processed.
#13256 509fa67 Thanks @p0lyw0lf! - Adds experimental responsive image support in Markdown
Previously, the experimental.responsiveImages feature could only provide responsive images when using the <Image /> and <Picture /> components.
Now, images written with the ![]() Markdown syntax in Markdown and MDX files will generate responsive images by default when using this experimental feature.
To try this experimental feature, set experimental.responsiveImages to true in your astro.config.mjs file:
{ experimental: { responsiveImages: true, },}Learn more about using this feature in the experimental responsive images feature reference.
For a complete overview, and to give feedback on this experimental API, see the Responsive Images RFC.
#13323 80926fa Thanks @ematipico! - Updates esbuild and vite to the latest to avoid false positives audits warnings caused by esbuild.
#13313 9e7c71d Thanks @martrapp! - Fixes an issue where a form field named โattributesโ shadows the form.attributes property.
#12052 5be12b2 Thanks @Fryuni! - Fixes incorrect config update when calling updateConfig from astro:build:setup hook.
The function previously called a custom update config function made for merging an Astro config. Now it calls the appropriate mergeConfig() utility exported by Vite that updates functional options correctly.
#13303 5f72a58 Thanks @ematipico! - Fixes an issue where the dev server was applying second decoding of the URL of the incoming request, causing issues for certain URLs.
Updated dependencies [1e11f5e, 1e11f5e]:
#13233 32fafeb Thanks @joshmkennedy! - Ensures consistent behaviour of Astro.rewrite/ctx.rewrite when using base and trailingSlash options.
#13003 ea79054 Thanks @chaegumi! - Fixes a bug that caused the vite.base value to be ignored when running astro dev
#13299 2e1321e Thanks @bluwy! - Uses tinyglobby for globbing files
#13233 32fafeb Thanks @joshmkennedy! - Ensures that Astro.url/ctx.url is correctly updated with the base path after rewrites.
This change fixes an issue where Astro.url/ctx.url did not include the configured base path after Astro.rewrite was called. Now, the base path is correctly reflected in Astro.url.
Previously, any rewrites performed through Astro.rewrite/ctx.rewrite failed to append the base path to Astro.url/ctx.rewrite, which could lead to incorrect URL handling in downstream logic. By fixing this, we ensure that all routes remain consistent and predictable after a rewrite.
If you were relying on the work around of including the base path in astro.rewrite you can now remove it from the path.
#13210 344e9bc Thanks @VitaliyR! - Handle HEAD requests to an endpoint when a handler is not defined.
If an endpoint defines a handler for GET, but does not define a handler for HEAD, Astro will call the GET handler and return the headers and status but an empty body.
#13195 3b66955 Thanks @MatthewLymer! - Improves SSR performance for synchronous components by avoiding the use of Promises. With this change, SSR rendering of on-demand pages can be up to 4x faster.
#13145 8d4e566 Thanks @ascorbic! - Adds support for adapters auto-configuring experimental session storage drivers.
Adapters can now configure a default session storage driver when the experimental.session flag is enabled. If a hosting platform has a storage primitive that can be used for session storage, the adapter can automatically configure the session storage using that driver. This allows Astro to provide a more seamless experience for users who want to use sessions without needing to manually configure the session storage.
#13145 8d4e566 Thanks @ascorbic! - :warning: BREAKING CHANGE FOR EXPERIMENTAL SESSIONS ONLY :warning:
Changes the experimental.session option to a boolean flag and moves session config to a top-level value. This change is to allow the new automatic session driver support. You now need to separately enable the experimental.session flag, and then configure the session driver using the top-level session key if providing manual configuration.
defineConfig({ // ... experimental: { session: { driver: 'upstash', }, session: true, }, session: { driver: 'upstash', },});You no longer need to configure a session driver if you are using an adapter that supports automatic session driver configuration and wish to use its default settings.
defineConfig({ adapter: node({ mode: "standalone", }), experimental: { session: { driver: 'fs', cookie: 'astro-cookie', }, session: true, }, session: { cookie: 'astro-cookie', },});However, you can still manually configure additional driver options or choose a non-default driver to use with your adapter with the new top-level session config option. For more information, see the experimental session docs.
#13101 2ed67d5 Thanks @corneliusroemer! - Fixes a bug where HEAD and OPTIONS requests for non-prerendered pages were incorrectly rejected with 403 FORBIDDEN
#13188 7bc8256 Thanks @ematipico! - Fixes the wording of the an error message
#13205 9d56602 Thanks @ematipico! - Fixes and issue where a server island component returns 404 when base is configured in i18n project.
#13212 fb38840 Thanks @joshmkennedy! - An additional has been added during the build command to add clarity around output and buildOutput.
#13213 6bac644 Thanks @joshmkennedy! - Allows readonly arrays to be passed to the paginate() function
#13133 e76aa83 Thanks @ematipico! - Fixes a bug where Astro was failing to build an external redirect when the middleware was triggered
#13119 ac43580 Thanks @Hacksore! - Adds extra guidance in the terminal when using the astro add tailwind CLI command
Now, users are given a friendly reminder to import the stylesheet containing their Tailwind classes into any pages where they want to use Tailwind. Commonly, this is a shared layout component so that Tailwind styling can be used on multiple pages.
#13113 3a26e45 Thanks @unprintable123! - Fixes the bug that rewrite will pass encoded url to the dynamic routing and cause params mismatch.
#13111 23978dd Thanks @ascorbic! - Fixes a bug that caused injected endpoint routes to return not found when trailingSlash was set to always
#13112 0fa5c82 Thanks @ematipico! - Fixes a bug where the i18n middleware was blocking a server island request when the prefixDefaultLocale option is set to true
#12994 5361755 Thanks @ascorbic! - Redirects trailing slashes for on-demand pages
When the trailingSlash option is set to always or never, on-demand rendered pages will now redirect to the correct URL when the trailing slash doesnโt match the configuration option. This was previously the case for static pages, but now works for on-demand pages as well.
Now, it doesnโt matter whether your visitor navigates to /about/, /about, or even /about///. In production, theyโll always end up on the correct page. For GET requests, the redirect will be a 301 (permanent) redirect, and for all other request methods, it will be a 308 (permanent, and preserve the request method) redirect.
In development, youโll see a helpful 404 page to alert you of a trailing slash mismatch so you can troubleshoot routes.
#12979 e621712 Thanks @ematipico! - Adds support for redirecting to external sites with the redirects configuration option.
Now, you can redirect routes either internally to another path or externally by providing a URL beginning with http or https:
import { defineConfig } from 'astro/config';
export default defineConfig({ redirects: { '/blog': 'https://example.com/blog', '/news': { status: 302, destination: 'https://example.com/news', }, },});#13084 0f3be31 Thanks @ematipico! - Adds a new experimental virtual module astro:config that exposes a type-safe subset of your astro.config.mjs configuration
The virtual module exposes two sub-paths for controlled access to your configuration:
astro:config/client: exposes config information that is safe to expose to the client.astro:config/server: exposes additional information that is safe to expose to the server, such as file/dir paths.To enable this new virtual module, add the experimental.serializeManifest feature flag to your Astro config:
import { defineConfig } from 'astro/config';export default defineConfig({ experimental: { serializeManifest: true, },});Then, you can access the module in any file inside your project to import and use values from your Astro config:
import { trailingSlash } from 'astro:config/client';
function addForwardSlash(path) { if (trailingSlash === 'always') { return path.endsWith('/') ? path : path + '/'; } else { return path; }}For a complete overview, and to give feedback on this experimental API, see the Serialized Manifest RFC.
#13049 2ed4bd9 Thanks @florian-lefebvre! - Updates astro add tailwind to add the @tailwindcss/vite plugin instead of the @astrojs/tailwind integration
#12994 5361755 Thanks @ascorbic! - Returns a more helpful 404 page in dev if there is a trailing slash mismatch between the route requested and the trailingSlash configuration
#12666 037495d Thanks @Thodor12! - Added additional generated typings for the content layer
Updated dependencies [5361755, db252e0]:
#13058 1a14b53 Thanks @ascorbic! - Fixes broken type declaration
#13059 e36837f Thanks @ascorbic! - Fixes a bug that caused tsconfig path aliases to break if there was more than one wildcard pattern
#13045 c7f1366 Thanks @mtwilliams-code! - Fixes a bug where the some utility functions of the astro:i18n virtual module would return an incorrect result when trailingSlash is set to never
#12986 8911bda Thanks @wetheredge! - Updates types and dev toolbar for ARIA 1.2 attributes and roles
#12892 8f520f1 Thanks @louisescher! - Adds a more descriptive error when a content collection entry has an invalid ID.
#13031 f576519 Thanks @florian-lefebvre! - Updates the server islands encoding logic to only escape the script end tag open delimiter and opening HTML comment syntax
#13026 1d272f6 Thanks @ascorbic! - Fixes a regression that prevented the import of Markdown files as raw text or URLs.
#12998 9ce0038 Thanks @Kynson! - Fixes the issue that audit incorrectly flag images as above the fold when the scrolling container is not body
#12990 2e12f1d Thanks @ascorbic! - Fixes a bug that caused references to be incorrectly reported as invalid
#12984 2d259cf Thanks @ascorbic! - Fixes a bug in dev where files would stop being watched if the Astro config file was edited
#12984 2d259cf Thanks @ascorbic! - Fixes a bug where the content layer would use an outdated version of the Astro config if it was edited in dev
#12982 429aa75 Thanks @bluwy! - Fixes an issue where server islands do not work in projects that use an adapter but only have prerendered pages. If an adapter is added, the server island endpoint will now be added by default.
#12995 78fd73a Thanks @florian-lefebvre! - Fixes a case where astro:actions types would not work when using src/actions.ts
#12733 bbf1d88 Thanks @ascorbic! - Fixes a bug that caused the dev server to return an error if requesting โ//โ
#13001 627aec3 Thanks @ascorbic! - Fixes a bug that caused Astro to attempt to inject environment variables into non-source files, causing performance problems and broken builds
#12361 3d89e62 Thanks @LunaticMuch! - Upgrades the esbuild version to match vite
#12980 1a026af Thanks @florian-lefebvre! - Fixes a case where setting the status of a page to 404 in development would show the default 404 page (or custom one if provided) instead of using the current page
#12182 c30070b Thanks @braden-w! - Improves matching of 404 and 500 routes
Updated dependencies [3d89e62]:
#12956 3aff68a Thanks @kaytwo! - Removes encryption of empty props to allow server island cacheability
#12977 80067c0 Thanks @florian-lefebvre! - Fixes a case where accessing astro:env APIs or import.meta.env inside the content config file would not work
#12839 57be349 Thanks @mtwilliams-code! - Fix Astro.currentLocale returning the incorrect locale when using fallback rewrites in SSR mode
#12962 4b7a2ce Thanks @ascorbic! - Skips updating content layer files if content is unchanged
#12942 f00c2dd Thanks @liruifengv! - Improves the session error messages
#12966 d864e09 Thanks @ascorbic! - Ensures old content collection entry is deleted if a markdown frontmatter slug is changed in dev
#12934 673a518 Thanks @ematipico! - Fixes a regression where the Astro Container didnโt work during the build, using pnpm
#12955 db447f2 Thanks @martrapp! - Lets TypeScript know about the โblockingโ and โdisabledโ attributes of the <link> element.
#12922 faf74af Thanks @adamchal! - Improves performance of static asset generation by fixing a bug that caused image transforms to be performed serially. This fix ensures that processing uses all CPUs when running in a multi-core environment.
#12947 3c2292f Thanks @ascorbic! - Fixes a bug that caused empty content collections when running dev with NODE_ENV set
#12927 ad2a752 Thanks @ematipico! - Fixes a bug where Astro attempted to decode a request URL multiple times, resulting in an unexpected behaviour when decoding the character %
#12912 0c0c66b Thanks @florian-lefebvre! - Improves the config error for invalid combinations of context and access properties under env.schema
#12935 3d47e6b Thanks @AirBorne04! - Fixes an issue where Astro.locals coming from an adapter werenโt available in the 404.astro, when using the astro dev command,
#12925 44841fc Thanks @ascorbic! - Ensures image styles are not imported unless experimental responsive images are enabled
#12926 8e64bb7 Thanks @oliverlynch! - Improves remote image cache efficiency by separating image data and metadata into a binary and sidecar JSON file.
#12920 8b9d530 Thanks @bluwy! - Processes markdown with empty body as remark and rehype plugins may add additional content or frontmatter
#12918 fd12a26 Thanks @lameuler! - Fixes a bug where the logged output path does not match the actual output path when using build.format: 'preserve'
#12676 2ffc0fc Thanks @koyopro! - Allows configuring Astro modules TypeScript compilation with the vite.esbuild config
#12938 dbb04f3 Thanks @ascorbic! - Fixes a bug where content collections would sometimes appear empty when first running astro dev
#12937 30edb6d Thanks @ematipico! - Fixes a bug where users could use Astro.request.headers during a rewrite inside prerendered routes. This an invalid behaviour, and now Astro will show a warning if this happens.
#12937 30edb6d Thanks @ematipico! - Fixes an issue where the use of Astro.rewrite would trigger the invalid use of Astro.request.headers
#12877 73a0788 Thanks @bluwy! - Fixes sourcemap warning generated by the astro:server-islands Vite plugin
#12906 2d89492 Thanks @ascorbic! - Fixes a bug that caused pages that return an empty array from getStaticPath to match every path
011fa0f Thanks @florian-lefebvre! - Fixes a case where astro:content types would be erased when restarting the dev server
#12907 dbf1275 Thanks @florian-lefebvre! - Fixes a regression around the server islands route, which was not passed to the adapters astro:build:done hook
#12818 579bd93 Thanks @ascorbic! - Fixes race condition where dev server would attempt to load collections before the content had loaded
#12883 fbac92f Thanks @kaytwo! - Fixes a bug where responses can be returned before session data is saved
#12815 3acc654 Thanks @ericswpark! - Some non-index files that were incorrectly being treated as index files are now excluded
#12884 d7e97a7 Thanks @ascorbic! - Adds render() to stub content types
#12883 fbac92f Thanks @kaytwo! - Fixes a bug where session data could be corrupted if it is changed after calling .set()
#12827 7b5dc6f Thanks @sinskiy! - Fixes an issue when crawlers try to index Server Islands thinking that Server Islands are pages
#12798 7b0cb85 Thanks @ascorbic! - Improves warning logs for invalid content collection configuration
#12781 96c4b92 Thanks @ascorbic! - Fixes a regression that caused default() to not work with reference()
#12820 892dd9f Thanks @ascorbic! - Fixes a bug that caused cookies to not be deleted when destroying a session
#12864 440d8a5 Thanks @kaytwo! - Fixes a bug where the session ID wasnโt correctly regenerated
#12768 524c855 Thanks @ematipico! - Fixes an issue where Astro didnโt print error logs when Astro Islands were used in incorrect cases.
#12814 f12f111 Thanks @ematipico! - Fixes an issue where Astro didnโt log anything in case a file isnโt created during the build.
#12875 e109002 Thanks @ascorbic! - Fixes a bug in emulated legacy collections where the entry passed to the getCollection filter function did not include the legacy entry fields.
#12768 524c855 Thanks @ematipico! - Fixes an issue where Astro was printing the incorrect output format when running the astro build command
#12810 70a9f0b Thanks @louisescher! - Fixes server islands failing to check content-type header under certain circumstances
Sometimes a reverse proxy or similar service might modify the content-type header to include the charset or other parameters in the media type of the response. This previously wasnโt handled by the client-side server island script and thus removed the script without actually placing the requested content in the DOM. This fix makes it so the script checks if the header starts with the proper content type instead of exactly matching text/html, so the following will still be considered a valid header: text/html; charset=utf-8
#12816 7fb2184 Thanks @ematipico! - Fixes an issue where an injected route entrypoint wasnโt correctly marked because the resolved file path contained a query parameter.
This fixes some edge case where some injected entrypoint were not resolved when using an adapter.
#12441 b4fec3c Thanks @ascorbic! - Adds experimental session support
Sessions are used to store user state between requests for server-rendered pages, such as login status, shopping cart contents, or other user-specific data.
---export const prerender = false; // Not needed in 'server' modeconst cart = await Astro.session.get('cart');---
<a href="/checkout">๐ {cart?.length ?? 0} items</a>Sessions are available in on-demand rendered/SSR pages, API endpoints, actions and middleware. To enable session support, you must configure a storage driver.
If you are using the Node.js adapter, you can use the fs driver to store session data on the filesystem:
{ adapter: node({ mode: 'standalone' }), experimental: { session: { // Required: the name of the unstorage driver driver: "fs", }, },}If you are deploying to a serverless environment, you can use drivers such as redis, netlify-blobs, vercel-kv, or cloudflare-kv-binding and optionally pass additional configuration options.
For more information, including using the session API with other adapters and a full list of supported drivers, see the docs for experimental session support. For even more details, and to leave feedback and participate in the development of this feature, the Sessions RFC.
#12426 3dc02c5 Thanks @oliverlynch! - Improves asset caching of remote images
Astro will now store entity tags and the Last-Modified date for cached remote images and use them to revalidate the cache when it goes stale.
#12721 c9d5110 Thanks @florian-lefebvre! - Adds a new getActionPath() helper available from astro:actions
Astro 5.1 introduces a new helper function, getActionPath() to give you more flexibility when calling your action.
Calling getActionPath() with your action returns its URL path so you can make a fetch() request with custom headers, or use your action with an API such as navigator.sendBeacon(). Then, you can handle the custom-formatted returned data as needed, just as if you had called an action directly.
This example shows how to call a defined like action passing the Authorization header and the keepalive option:
<script> import { actions, getActionPath } from 'astro:actions';
await fetch(getActionPath(actions.like), { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer YOUR_TOKEN', }, body: JSON.stringify({ id: 'YOUR_ID' }), keepalive: true, });</script>This example shows how to call the same like action using the sendBeacon API:
<script> import { actions, getActionPath } from 'astro:actions';
navigator.sendBeacon( getActionPath(actions.like), new Blob([JSON.stringify({ id: 'YOUR_ID' })], { type: 'application/json', }), );</script>#12786 e56af4a Thanks @ematipico! - Fixes an issue where Astro i18n didnโt properly show the 404 page when using fallback and the option prefixDefaultLocale set to true.
#12758 483da89 Thanks @delucis! - Adds types for ?url&inline and ?url&no-inline import queries added in Vite 6
#12763 8da2318 Thanks @rbsummers! - Fixed changes to vite configuration made in the astro:build:setup integration hook having no effect when target is โclientโ
#12767 36c1e06 Thanks @ascorbic! - Clears the content layer cache when the Astro config is changed
#12597 564ac6c Thanks @florian-lefebvre! - Fixes an issue where image and server islands routes would not be passed to the astro:routes:resolved hook during builds
#12718 ccc5ad1 Thanks @ematipico! - Fixes an issue where Astro couldnโt correctly handle i18n fallback when using the i18n middleware
#12728 ee66a45 Thanks @argyleink! - Adds type support for the closedby attribute for <dialog> elements
#12709 e3bfd93 Thanks @mtwilliams-code! - Fixes a bug where Astro couldnโt correctly parse params and props when receiving i18n fallback URLs
#12657 14dffcc Thanks @darkmaga! - Trailing slash support for actions
#12715 029661d Thanks @ascorbic! - Fixes a bug that caused errors in dev when editing sites with large numbers of MDX pages
#12729 8b1cecd Thanks @JoeMorgan! - โAdded inert to htmlBooleanAttributesโ
#12726 7c7398c Thanks @florian-lefebvre! - Fixes a case where failing content entries in astro check would not be surfaced
#12705 0d1eab5 Thanks @ascorbic! - Fixes a bug where MDX files with certain characters in the name would cause builds to fail
#12707 2aaed2d Thanks @ematipico! - Fixes a bug where the middleware was incorrectly imported during the build
#12697 1c4a032 Thanks @ascorbic! - Fix a bug that caused builds to fail if an image had a quote mark in its name
#12694 495f46b Thanks @ematipico! - Fixes a bug where the experimental feature experimental.svg was incorrectly used when generating ESM images
#12658 3169593 Thanks @jurajkapsz! - Fixes astro info copy to clipboard process not returning to prompt in certain cases.
#12712 b01c74a Thanks @ascorbic! - Fixes a bug which misidentified pages as markdown if a query string ended in a markdown extension
#12653 e21c7e6 Thanks @sarah11918! - Updates a reference in an error message
#12585 a9373c0 Thanks @florian-lefebvre! - Fixes a case where process.env would be frozen despite changes made to environment variables in development
#12695 a203d5d Thanks @ascorbic! - Throws a more helpful error when images are missing
Updated dependencies [f13417b, 87231b1, a71e9b9]:
e7d14c3 Thanks @ematipico! - Fixes an issue where the checkOrigin feature wasnโt correctly checking the content-type header#12645 8704c54 Thanks @sarah11918! - Updates some reference links in error messages for new v5 docs.
#12641 48ca399 Thanks @ascorbic! - Fixes a bug where astro info --copy wasnโt working correctly on macOS systems.
#12461 62939ad Thanks @kyr0! - Removes the misleading log message telling that a custom renderer is not recognized while it clearly is and works.
#12642 ff18b9c Thanks @ematipico! - Provides more information when logging a warning for accessing Astro.request.headers in prerendered pages
#12634 03958d9 Thanks @delucis! - Improves error message formatting for user config and content collection frontmatter
#12547 6b6e18d Thanks @mtwilliams-code! - Fixes a bug where URL search parameters werenโt passed when using the i18n fallback feature.
#12449 e6b8017 Thanks @apatel369! - Fixes an issue where the custom assetFileNames configuration caused assets to be incorrectly moved to the server directory instead of the client directory, resulting in 404 errors when accessed from the client side.
#12518 e216250 Thanks @ematipico! - Fixes an issue where SSR error pages would return duplicated custom headers.
#12625 74bfad0 Thanks @ematipico! - Fixes an issue where the experimental.svg had incorrect type, resulting in some errors in the editors.
#12631 dec0305 Thanks @ascorbic! - Fixes a bug where the class attribute was rendered twice on the image component
#12623 0e4fecb Thanks @ascorbic! - Correctly handles images in content collections with uppercase file extensions
#12633 8a551c1 Thanks @bluwy! - Cleans up content layer sync during builds and programmatic sync() calls
#12640 22e405a Thanks @ascorbic! - Fixes a bug that caused content collections to be returned empty when run in a test environment
#12613 306c9f9 Thanks @matthewp! - Fix use of cloned requests in middleware with clientAddress
When using context.clientAddress or Astro.clientAddress Astro looks up the address in a hidden property. Cloning a request can cause this hidden property to be lost.
The fix is to pass the address as an internal property instead, decoupling it from the request.
#11798 e9e2139 Thanks @matthewp! - Unflag globalRoutePriority
The previously experimental feature globalRoutePriority is now the default in Astro 5.
This was a refactoring of route prioritization in Astro, making it so that injected routes, file-based routes, and redirects are all prioritized using the same logic. This feature has been enabled for all Starlight projects since it was added and should not affect most users.
#11864 ee38b3a Thanks @ematipico! - ### [changed]: entryPoint type inside the hook astro:build:ssr
In Astro v4.x, the entryPoint type was RouteData.
Astro v5.0 the entryPoint type is IntegrationRouteData, which contains a subset of the RouteData type. The fields isIndex and fallbackRoutes were removed.
Update your adapter to change the type of entryPoint from RouteData to IntegrationRouteData.
import type {RouteData} from 'astro';import type {IntegrationRouteData} from "astro"
function useRoute(route: RouteData) {function useRoute(route: IntegrationRouteData) {
}#12524 9f44019 Thanks @bluwy! - Bumps Vite to ^6.0.1 and handles its breaking changes
#10742 b6fbdaa Thanks @ematipico! - The lowest version of Node supported by Astro is now Node v18.17.1 and higher.
#11916 46ea29f Thanks @bluwy! - Updates how the build.client and build.server option values get resolved to match existing documentation. With this fix, the option values will now correctly resolve relative to the outDir option. So if outDir is set to ./dist/nested/, then by default:
build.client will resolve to <root>/dist/nested/client/build.server will resolve to <root>/dist/nested/server/Previously the values were incorrectly resolved:
build.client was resolved to <root>/dist/nested/dist/client/build.server was resolved to <root>/dist/nested/dist/server/If you were relying on the previous build paths, make sure that your project code is updated to the new build paths.
#11982 d84e444 Thanks @Princesseuh! - Adds a default exclude and include value to the tsconfig presets. {projectDir}/dist is now excluded by default, and {projectDir}/.astro/types.d.ts and {projectDir}/**/* are included by default.
Both of these options can be overridden by setting your own values to the corresponding settings in your tsconfig.json file.
#11861 3ab3b4e Thanks @bluwy! - Cleans up Astro-specfic metadata attached to vfile.data in Remark and Rehype plugins. Previously, the metadata was attached in different locations with inconsistent names. The metadata is now renamed as below:
vfile.data.__astroHeadings -> vfile.data.astro.headingsvfile.data.imagePaths -> vfile.data.astro.imagePathsThe types of imagePaths has also been updated from Set<string> to string[]. The vfile.data.astro.frontmatter metadata is left unchanged.
While we donโt consider these APIs public, they can be accessed by Remark and Rehype plugins that want to re-use Astroโs metadata. If you are using these APIs, make sure to access them in the new locations.
#11987 bf90a53 Thanks @florian-lefebvre! - The locals object can no longer be overridden
Middleware, API endpoints, and pages can no longer override the locals object in its entirety. You can still append values onto the object, but you can not replace the entire object and delete its existing values.
If you were previously overwriting like so:
ctx.locals = { one: 1, two: 2,};This can be changed to an assignment on the existing object instead:
Object.assign(ctx.locals, { one: 1, two: 2,});#11908 518433e Thanks @Princesseuh! - The image.endpoint config now allow customizing the route of the image endpoint in addition to the entrypoint. This can be useful in niche situations where the default route /_image conflicts with an existing route or your local server setup.
import { defineConfig } from 'astro/config';
defineConfig({ image: { endpoint: { route: '/image', entrypoint: './src/image_endpoint.ts', }, },});#12008 5608338 Thanks @Princesseuh! - Welcome to the Astro 5 beta! This release has no changes from the latest alpha of this package, but it does bring us one step closer to the final, stable release.
Starting from this release, no breaking changes will be introduced unless absolutely necessary.
To learn how to upgrade, check out the Astro v5.0 upgrade guide in our beta docs site.
#11679 ea71b90 Thanks @florian-lefebvre! - The astro:env feature introduced behind a flag in v4.10.0 is no longer experimental and is available for general use. If you have been waiting for stabilization before using astro:env, you can now do so.
This feature lets you configure a type-safe schema for your environment variables, and indicate whether they should be available on the server or the client.
To configure a schema, add the env option to your Astro config and define your client and server variables. If you were previously using this feature, please remove the experimental flag from your Astro config and move your entire env configuration unchanged to a top-level option.
import { defineConfig, envField } from 'astro/config';
export default defineConfig({ env: { schema: { API_URL: envField.string({ context: 'client', access: 'public', optional: true }), PORT: envField.number({ context: 'server', access: 'public', default: 4321 }), API_SECRET: envField.string({ context: 'server', access: 'secret' }), }, },});You can import and use your defined variables from the appropriate /client or /server module:
---import { API_URL } from 'astro:env/client';import { API_SECRET_TOKEN } from 'astro:env/server';
const data = await fetch(`${API_URL}/users`, { method: 'GET', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${API_SECRET_TOKEN}`, },});---
<script> import { API_URL } from 'astro:env/client';
fetch(`${API_URL}/ping`);</script>Please see our guide to using environment variables for more about this feature.
#11806 f7f2338 Thanks @Princesseuh! - Removes the assets property on supportedAstroFeatures for adapters, as it did not reflect reality properly in many cases.
Now, relating to assets, only a single sharpImageService property is available, determining if the adapter is compatible with the built-in sharp image service.
#11864 ee38b3a Thanks @ematipico! - ### [changed]: routes type inside the hook astro:build:done
In Astro v4.x, the routes type was RouteData.
Astro v5.0 the routes type is IntegrationRouteData, which contains a subset of the RouteData type. The fields isIndex and fallbackRoutes were removed.
Update your adapter to change the type of routes from RouteData to IntegrationRouteData.
import type {RouteData} from 'astro';import type {IntegrationRouteData} from "astro"
function useRoute(route: RouteData) {function useRoute(route: IntegrationRouteData) {
}#11941 b6a5f39 Thanks @Princesseuh! - Merges the output: 'hybrid' and output: 'static' configurations into one single configuration (now called 'static') that works the same way as the previous hybrid option.
It is no longer necessary to specify output: 'hybrid' in your Astro config to use server-rendered pages. The new output: 'static' has this capability included. Astro will now automatically provide the ability to opt out of prerendering in your static site with no change to your output configuration required. Any page route or endpoint can include export const prerender = false to be server-rendered, while the rest of your site is statically-generated.
If your project used hybrid rendering, you must now remove the output: 'hybrid' option from your Astro config as it no longer exists. However, no other changes to your project are required, and you should have no breaking changes. The previous 'hybrid' behavior is now the default, under a new name 'static'.
If you were using the output: 'static' (default) option, you can continue to use it as before. By default, all of your pages will continue to be prerendered and you will have a completely static site. You should have no breaking changes to your project.
import { defineConfig } from "astro/config";
export default defineConfig({ output: 'hybrid',});An adapter is still required to deploy an Astro project with any server-rendered pages. Failure to include an adapter will result in a warning in development and an error at build time.
#11788 7c0ccfc Thanks @ematipico! - Updates the default value of security.checkOrigin to true, which enables Cross-Site Request Forgery (CSRF) protection by default for pages rendered on demand.
If you had previously configured security.checkOrigin: true, you no longer need this set in your Astro config. This is now the default and it is safe to remove.
To disable this behavior and opt out of automatically checking that the โoriginโ header matches the URL sent by each request, you must explicitly set security.checkOrigin: false:
export default defineConfig({ security: { checkOrigin: false }})#11825 560ef15 Thanks @bluwy! - Updates internal Shiki rehype plugin to highlight code blocks as hast (using Shikiโs codeToHast() API). This allows a more direct Markdown and MDX processing, and improves the performance when building the project, but may cause issues with existing Shiki transformers.
If you are using Shiki transformers passed to markdown.shikiConfig.transformers, you must make sure they do not use the postprocess hook as it no longer runs on code blocks in .md and .mdx files. (See the Shiki documentation on transformer hooks for more information).
Code blocks in .mdoc files and <Code /> component do not use the internal Shiki rehype plugin and are unaffected.
#11826 7315050 Thanks @matthewp! - Deprecate Astro.glob
The Astro.glob function has been deprecated in favor of Content Collections and import.meta.glob.
import.meta.glob(https://vitejs.dev/guide/features.html#glob-import).Also consider using glob packages from npm, like fast-glob, especially if statically generating your site, as it is faster for most use-cases.
The easiest path is to migrate to import.meta.glob like so:
const posts = Astro.glob('./posts/*.md');const posts = Object.values(import.meta.glob('./posts/*.md', { eager: true }));#12268 4e9a3ac Thanks @ematipico! - The command astro add vercel now updates the configuration file differently, and adds @astrojs/vercel as module to import.
This is a breaking change because it requires the version 8.* of @astrojs/vercel.
#11741 6617491 Thanks @bluwy! - Removes internal JSX handling and moves the responsibility to the @astrojs/mdx package directly. The following exports are also now removed:
astro/jsx/babel.jsastro/jsx/component.jsastro/jsx/index.jsastro/jsx/renderer.jsastro/jsx/server.jsastro/jsx/transform-options.jsIf your project includes .mdx files, you must upgrade @astrojs/mdx to the latest version so that it doesnโt rely on these entrypoints to handle your JSX.
#11782 9a2aaa0 Thanks @Princesseuh! - Makes the compiledContent property of Markdown content an async function, this change should fix underlying issues where sometimes when using a custom image service and images inside Markdown, Node would exit suddenly without any error message.
---import * as myPost from "../post.md";
const content = myPost.compiledContent(); const content = await myPost.compiledContent();---
<Fragment set:html={content} />#11819 2bdde80 Thanks @bluwy! - Updates the Astro config loading flow to ignore processing locally-linked dependencies with Vite (e.g. npm link, in a monorepo, etc). Instead, they will be normally imported by the Node.js runtime the same way as other dependencies from node_modules.
Previously, Astro would process locally-linked dependencies which were able to use Vite features like TypeScript when imported by the Astro config file.
However, this caused confusion as integration authors may test against a package that worked locally, but not when published. This method also restricts using CJS-only dependencies because Vite requires the code to be ESM. Therefore, Astroโs behaviour is now changed to ignore processing any type of dependencies by Vite.
In most cases, make sure your locally-linked dependencies are built to JS before running the Astro project, and the config loading should work as before.
#11827 a83e362 Thanks @matthewp! - Prevent usage of astro:content in the client
Usage of astro:content in the client has always been discouraged because it leads to all of your content winding up in your client bundle, and can possibly leaks secrets.
This formally makes doing so impossible, adding to the previous warning with errors.
In the future Astro might add APIs for client-usage based on needs.
#11979 423dfc1 Thanks @bluwy! - Bumps vite dependency to v6.0.0-beta.2. The version is pinned and will be updated as new Vite versions publish to prevent unhandled breaking changes. For the full list of Vite-specific changes, see its changelog.
#11859 3804711 Thanks @florian-lefebvre! - Changes the default tsconfig.json with better defaults, and makes src/env.d.ts optional
Astroโs default tsconfig.json in starter examples has been updated to include generated types and exclude your build output. This means that src/env.d.ts is only necessary if you have added custom type declarations or if youโre not using a tsconfig.json file.
Additionally, running astro sync no longer creates, nor updates, src/env.d.ts as it is not required for type-checking standard Astro projects.
To update your project to Astroโs recommended TypeScript settings, please add the following include and exclude properties to tsconfig.json:
{ "extends": "astro/tsconfigs/base", "include": [".astro/types.d.ts", "**/*"], "exclude": ["dist"]}#11715 d74617c Thanks @Princesseuh! - Refactor the exported types from the astro module. There should normally be no breaking changes, but if you relied on some previously deprecated types, these might now have been fully removed.
In most cases, updating your code to move away from previously deprecated APIs in previous versions of Astro should be enough to fix any issues.
#12551 abf9a89 Thanks @ematipico! - Refactors legacy content and data collections to use the Content Layer API glob() loader for better performance and to support backwards compatibility. Also introduces the legacy.collections flag for projects that are unable to update to the new behavior immediately.
:warning: BREAKING CHANGE FOR LEGACY CONTENT COLLECTIONS :warning:
By default, collections that use the old types (content or data) and do not define a loader are now implemented under the hood using the Content Layer APIโs built-in glob() loader, with extra backward-compatibility handling.
In order to achieve backwards compatibility with existing content collections, the following have been implemented:
glob loader collection is defined, with patterns that match the previous handling (matches src/content/<collection name>/**/*.md and other content extensions depending on installed integrations, with underscore-prefixed files and folders ignored)slug field is added with the same format as beforerender() method is added to the entry, so they can be called using entry.render()getEntryBySlug is supportedIn order to achieve backwards compatibility with existing data collections, the following have been implemented:
glob loader collection is defined, with patterns that match the previous handling (matches src/content/<collection name>/**/*{.json,.yaml} and other data extensions, with underscore-prefixed files and folders ignored)getDataEntryById is supportedWhile this backwards compatibility implementation is able to emulate most of the features of legacy collections, there are some differences and limitations that may cause breaking changes to existing collections:
src/content/, even if they were not defined in src/content/config.ts. This behavior is now deprecated, and collections should always be defined in src/content/config.ts. For existing collections, these can just be empty declarations (e.g. const blog = defineCollection({})) and Astro will implicitly define your legacy collection for you in a way that is compatible with the new loading behavior.layout field is not supported in Markdown collection entries. This property is intended only for standalone page files located in src/pages/ and not likely to be in your collection entries. However, if you were using this property, you must now create dynamic routes that include your page styling.getCollection(), the order in which entries are returned may be different than before. If you need a specific order, you should sort the collection entries yourself.image().refine() is not supported. If you need to validate the properties of an image you will need to do this at runtime in your page or component.key argument of getEntry(collection, key) is typed as string, rather than having types for every entry.A new legacy configuration flag legacy.collections is added for users that want to keep their current legacy (content and data) collections behavior (available in Astro v2 - v4), or who are not yet ready to update their projects:
import { defineConfig } from 'astro/config';
export default defineConfig({ legacy: { collections: true, },});When set, no changes to your existing collections are necessary, and the restrictions on storing both new and old collections continue to exist: legacy collections (only) must continue to remain in src/content/, while new collections using a loader from the Content Layer API are forbidden in that folder.
#11660 e90f559 Thanks @bluwy! - Fixes attribute rendering for non-boolean HTML attributes with boolean values to match proper attribute handling in browsers.
Previously, non-boolean attributes may not have included their values when rendered to HTML. In Astro v5.0, the values are now explicitly rendered as ="true" or ="false"
In the following .astro examples, only allowfullscreen is a boolean attribute:
<!-- src/pages/index.astro --><!-- `allowfullscreen` is a boolean attribute --><p allowfullscreen={true}></p><p allowfullscreen={false}></p>
<!-- `inherit` is *not* a boolean attribute --><p inherit={true}></p><p inherit={false}></p>
<!-- `data-*` attributes are not boolean attributes --><p data-light={true}></p><p data-light={false}></p>Astro v5.0 now preserves the full data attribute with its value when rendering the HTML of non-boolean attributes:
<p allowfullscreen></p><p></p>
<p inherit="true"></p><p inherit></p><p inherit="false"></p>
<p data-light></p><p data-light="true"></p><p></p><p data-light="false"></p>If you rely on attribute values, for example to locate elements or to conditionally render, update your code to match the new non-boolean attribute values:
el.getAttribute('inherit') === ''el.getAttribute('inherit') === 'false'
el.hasAttribute('data-light')el.dataset.light === 'true'#11770 cfa6a47 Thanks @Princesseuh! - Removed support for the Squoosh image service. As the underlying library libsquoosh is no longer maintained, and the image service sees very little usage we have decided to remove it from Astro.
Our recommendation is to use the base Sharp image service, which is more powerful, faster, and more actively maintained.
import { squooshImageService } from "astro/config";import { defineConfig } from "astro/config";
export default defineConfig({ image: { service: squooshImageService() }});If you are using this service, and cannot migrate to the base Sharp image service, a third-party extraction of the previous service is available here: https://github.com/Princesseuh/astro-image-service-squoosh
#12231 90ae100 Thanks @bluwy! - Updates the automatic charset=utf-8 behavior for Markdown pages, where instead of responding with charset=utf-8 in the Content-Type header, Astro will now automatically add the <meta charset="utf-8"> tag instead.
This behaviour only applies to Markdown pages (.md or similar Markdown files located within src/pages/) that do not use Astroโs special layout frontmatter property. It matches the rendering behaviour of other non-content pages, and retains the minimal boilerplate needed to write with non-ASCII characters when adding individual Markdown pages to your site.
If your Markdown pages use the layout frontmatter property, then HTML encoding will be handled by the designated layout component instead, and the <meta charset="utf-8"> tag will not be added to your page by default.
If you require charset=utf-8 to render your page correctly, make sure that your layout components contain the <meta charset="utf-8"> tag. You may need to add this if you have not already done so.
#11714 8a53517 Thanks @matthewp! - Remove support for functionPerRoute
This change removes support for the functionPerRoute option both in Astro and @astrojs/vercel.
This option made it so that each route got built as separate entrypoints so that they could be loaded as separate functions. The hope was that by doing this it would decrease the size of each function. However in practice routes use most of the same code, and increases in function size limitations made the potential upsides less important.
Additionally there are downsides to functionPerRoute, such as hitting limits on the number of functions per project. The feature also never worked with some Astro features like i18n domains and request rewriting.
Given this, the feature has been removed from Astro.
#11864 ee38b3a Thanks @ematipico! - ### [changed]: RouteData.distURL is now an array
In Astro v4.x, RouteData.distURL was undefined or a URL
Astro v5.0, RouteData.distURL is undefined or an array of URL. This was a bug, because a route can generate multiple files on disk, especially when using dynamic routes such as [slug] or [...slug].
Update your code to handle RouteData.distURL as an array.
if (route.distURL) { if (route.distURL.endsWith('index.html')) { // do something } for (const url of route.distURL) { if (url.endsWith('index.html')) { // do something } }}#11253 4e5cc5a Thanks @kevinzunigacuellar! - Changes the data returned for page.url.current, page.url.next, page.url.prev, page.url.first and page.url.last to include the value set for base in your Astro config.
Previously, you had to manually prepend your configured value for base to the URL path. Now, Astro automatically includes your base value in next and prev URLs.
If you are using the paginate() function for โpreviousโ and โnextโ URLs, remove any existing base value as it is now added for you:
---export async function getStaticPaths({ paginate }) { const astronautPages = [{ astronaut: 'Neil Armstrong', }, { astronaut: 'Buzz Aldrin', }, { astronaut: 'Sally Ride', }, { astronaut: 'John Glenn', }]; return paginate(astronautPages, { pageSize: 1 });}const { page } = Astro.props;// `base: /'docs'` configured in `astro.config.mjs` const prev = "/docs" + page.url.prev; const prev = page.url.prev;---<a id="prev" href={prev}>Back</a>#12079 7febf1f Thanks @ematipico! - params passed in getStaticPaths are no longer automatically decoded.
params arenโt decoded anymore.In Astro v4.x, params in were automatically decoded using decodeURIComponent.
Astro v5.0 doesnโt automatically decode params in getStaticPaths anymore, so youโll need to manually decode them yourself if needed
If you were relying on the automatic decode, youโll need to manually decode it using decodeURI.
Note that the use of decodeURIComponent) is discouraged for getStaticPaths because it decodes more characters than it should, for example /, ?, # and more.
---export function getStaticPaths() { return [ { params: { id: decodeURI("%5Bpage%5D") } }, { params: { id: "%5Bpage%5D" } }, ]}
const { id } = Astro.params;---#11941 b6a5f39 Thanks @Princesseuh! - Adapters can now specify the build output type theyโre intended for using the adapterFeatures.buildOutput property. This property can be used to always generate a server output, even if the project doesnโt have any server-rendered pages.
{ 'astro:config:done': ({ setAdapter, config }) => { setAdapter({ name: 'my-adapter', adapterFeatures: { buildOutput: 'server', }, }); },}If your adapter specifies buildOutput: 'static', and the userโs project contains server-rendered pages, Astro will warn in development and error at build time. Note that a hybrid output, containing both static and server-rendered pages, is considered to be a server output, as a server is required to serve the server-rendered pages.
#12067 c48916c Thanks @stramel! - Adds experimental support for built-in SVG components.
This feature allows you to import SVG files directly into your Astro project as components. By default, Astro will inline the SVG content into your HTML output.
To enable this feature, set experimental.svg to true in your Astro config:
{ experimental: { svg: true, },}To use this feature, import an SVG file in your Astro project, passing any common SVG attributes to the imported component. Astro also provides a size attribute to set equal height and width properties:
---import Logo from './path/to/svg/file.svg';---
<Logo size={24} />For a complete overview, and to give feedback on this experimental API, see the Feature RFC.
#12226 51d13e2 Thanks @ematipico! - The following renderer fields and integration fields now accept URL as a type:
Renderers:
AstroRenderer.clientEntrpointAstroRenderer.serverEntrypointIntegrations:
InjectedRoute.entrypointAstroIntegrationMiddleware.entrypointDevToolbarAppEntry.entrypoint#12323 c280655 Thanks @bluwy! - Updates to Vite 6.0.0-beta.6
#12243 eb41d13 Thanks @florian-lefebvre! - Improves defineConfig type safety. TypeScript will now error if a group of related configuration options do not have consistent types. For example, you will now see an error if your language set for i18n.defaultLocale is not one of the supported locales specified in i18n.locales.
#12329 8309c61 Thanks @florian-lefebvre! - Adds a new astro:routes:resolved hook to the Integration API. Also update the astro:build:done hook by deprecating routes and adding a new assets map.
When building an integration, you can now get access to routes inside the astro:routes:resolved hook:
const integration = () => { return { name: 'my-integration', hooks: { 'astro:routes:resolved': ({ routes }) => { console.log(routes); }, }, };};This hook runs before astro:config:done, and whenever a route changes in development.
The routes array from astro:build:done is now deprecated, and exposed properties are now available on astro:routes:resolved, except for distURL. For this, you can use the newly exposed assets map:
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) } } }}#11911 c3dce83 Thanks @ascorbic! - The Content Layer API introduced behind a flag in 4.14.0 is now stable and ready for use in Astro v5.0.
The new Content Layer API builds upon content collections, taking them beyond local files in src/content/ and allowing you to fetch content from anywhere, including remote APIs. These new collections work alongside your existing content collections, and you can migrate them to the new API at your own pace. There are significant improvements to performance with large collections of local files. For more details, see the Content Layer RFC.
If you previously used this feature, you can now remove the experimental.contentLayer flag from your Astro config:
import { defineConfig } from 'astro'
export default defineConfig({ experimental: { contentLayer: true }})The core of the new Content Layer API is the loader, a function that fetches content from a source and caches it in a local data store. Astro 4.14 ships with built-in glob() and file() loaders to handle your local Markdown, MDX, Markdoc, and JSON files:
import { defineCollection, z } from 'astro:content';import { glob } from 'astro/loaders';
const blog = defineCollection({ // The ID is a slug generated from the path of the file relative to `base` loader: glob({ pattern: '**/*.md', base: './src/data/blog' }), schema: z.object({ title: z.string(), description: z.string(), publishDate: z.coerce.date(), }),});
export const collections = { blog };You can then query using the existing content collections functions, and use a simplified render() function to display your content:
---import { getEntry, render } from 'astro:content';
const post = await getEntry('blog', Astro.params.slug);
const { Content } = await render(entry);---
<Content />Youโre not restricted to the built-in loaders โ we hope youโll try building your own. You can fetch content from anywhere and return an array of entries:
const countries = defineCollection({ loader: async () => { const response = await fetch('https://restcountries.com/v3.1/all'); const data = await response.json(); // Must return an array of entries with an id property, // or an object with IDs as keys and entries as values return data.map((country) => ({ id: country.cca3, ...country, })); }, // optionally add a schema to validate the data and make it type-safe for users // schema: z.object...});
export const collections = { countries };For more advanced loading logic, you can define an object loader. This allows incremental updates and conditional loading, and gives full access to the data store. It also allows a loader to define its own schema, including generating it dynamically based on the source API. See the the Content Layer API RFC for more details.
Loaders are better when theyโre shared. You can create a package that exports a loader and publish it to npm, and then anyone can use it on their site. Weโre excited to see what the community comes up with! To get started, take a look at some examples. Hereโs how to load content using an RSS/Atom feed loader:
import { defineCollection } from 'astro:content';import { feedLoader } from '@ascorbic/feed-loader';
const podcasts = defineCollection({ loader: feedLoader({ url: 'https://feeds.99percentinvisible.org/99percentinvisible', }),});
export const collections = { podcasts };To learn more, see the Content Layer RFC.
#11980 a604a0c Thanks @matthewp! - ViewTransitions component renamed to ClientRouter
The <ViewTransitions /> component has been renamed to <ClientRouter />. There are no other changes than the name. The old name will continue to work in Astro 5.x, but will be removed in 6.0.
This change was done to clarify the role of the component within Astroโs View Transitions support. Astro supports View Transitions APIs in a few different ways, and renaming the component makes it more clear that the features you get from the ClientRouter component are slightly different from what you get using the native CSS-based MPA router.
We still intend to maintain the ClientRouter as before, and itโs still important for use-cases that the native support doesnโt cover, such as persisting state between pages.
#11875 a8a3d2c Thanks @florian-lefebvre! - Adds a new property isPrerendered to the globals Astro and APIContext . This boolean value represents whether or not the current page is prerendered:
---export const prerender = true;---export const onRequest = (ctx, next) => { console.log(ctx.isPrerendered); // it will log true return next();};#12047 21b5e80 Thanks @rgodha24! - Adds a new optional parser property to the built-in file() loader for content collections to support additional file types such as toml and csv.
The file() loader now accepts a second argument that defines a parser function. This allows you to specify a custom parser (e.g. toml.parse or csv-parse) to create a collection from a fileโs contents. The file() loader will automatically detect and parse JSON and YAML files (based on their file extension) with no need for a parser.
This works with any type of custom file formats including csv and toml. The following example defines a content collection dogs using a .toml file.
[[dogs]]id = "..."age = "..."
[[dogs]]id = "..."age = "..."After importing TOMLโs parser, you can load the dogs collection into your project by passing both a file path and parser to the file() loader.
import { defineCollection } from "astro:content"import { file } from "astro/loaders"import { parse as parseToml } from "toml"
const dogs = defineCollection({ loader: file("src/data/dogs.toml", { parser: (text) => parseToml(text).dogs }), schema: /* ... */})
// it also works with CSVs!import { parse as parseCsv } from "csv-parse/sync";
const cats = defineCollection({ loader: file("src/data/cats.csv", { parser: (text) => parseCsv(text, { columns: true, skipEmptyLines: true })})});The parser argument also allows you to load a single collection from a nested JSON document. For example, this JSON file contains multiple collections:
{ "dogs": [{}], "cats": [{}] }You can seperate these collections by passing a custom parser to the file() loader like so:
const dogs = defineCollection({ loader: file('src/data/pets.json', { parser: (text) => JSON.parse(text).dogs }),});const cats = defineCollection({ loader: file('src/data/pets.json', { parser: (text) => JSON.parse(text).cats }),});And it continues to work with maps of id to data
bubbles: breed: 'Goldfish' age: 2finn: breed: 'Betta' age: 1const fish = defineCollection({ loader: file('src/data/fish.yaml'), schema: z.object({ breed: z.string(), age: z.number() }),});#11698 05139ef Thanks @ematipico! - Adds a new property to the globals Astro and APIContext called routePattern. The routePattern represents the current route (component)
that is being rendered by Astro. Itโs usually a path pattern will look like this: blog/[slug]:
---const route = Astro.routePattern;console.log(route); // it will log "blog/[slug]"---export const GET = (ctx) => { console.log(ctx.routePattern); // it will log src/pages/index.js return new Response.json({ loreum: 'ipsum' });};#11941 b6a5f39 Thanks @Princesseuh! - Adds a new buildOutput property to the astro:config:done hook returning the build output type.
This can be used to know if the userโs project will be built as a static site (HTML files), or a server-rendered site (whose exact output depends on the adapter).
#12377 af867f3 Thanks @ascorbic! - Adds experimental support for automatic responsive images
This feature is experimental and may change in future versions. To enable it, set experimental.responsiveImages to true in your astro.config.mjs file.
{ experimental: { responsiveImages: true, },}When this flag is enabled, you can pass a layout prop to any <Image /> or <Picture /> component to create a responsive image. When a layout is set, images have automatically generated srcset and sizes attributes based on the imageโs dimensions and the layout type. Images with responsive and full-width layouts will have styles applied to ensure they resize according to their container.
---import { Image, Picture } from 'astro:assets';import myImage from '../assets/my_image.png';---
<Image src={myImage} alt="A description of my image." layout="responsive" width={800} height={600}/><Picture src={myImage} alt="A description of my image." layout="full-width" formats={['avif', 'webp', 'jpeg']}/>This <Image /> component will generate the following HTML output:
<img src="/_astro/my_image.hash3.webp" srcset=" /_astro/my_image.hash1.webp 640w, /_astro/my_image.hash2.webp 750w, /_astro/my_image.hash3.webp 800w, /_astro/my_image.hash4.webp 828w, /_astro/my_image.hash5.webp 1080w, /_astro/my_image.hash6.webp 1280w, /_astro/my_image.hash7.webp 1600w " alt="A description of my image" sizes="(min-width: 800px) 800px, 100vw" loading="lazy" decoding="async" fetchpriority="auto" width="800" height="600" style="--w: 800; --h: 600; --fit: cover; --pos: center;" data-astro-image="responsive"/>These are additional properties available to the <Image /> and <Picture /> components when responsive images are enabled:
layout: The layout type for the image. Can be responsive, fixed, full-width or none. Defaults to value of image.experimentalLayout.fit: Defines how the image should be cropped if the aspect ratio is changed. Values match those of CSS object-fit. Defaults to cover, or the value of image.experimentalObjectFit if set.position: Defines the position of the image crop if the aspect ratio is changed. Values match those of CSS object-position. Defaults to center, or the value of image.experimentalObjectPosition if set.priority: If set, eagerly loads the image. Otherwise images will be lazy-loaded. Use this for your largest above-the-fold image. Defaults to false.You can enable responsive images for all <Image /> and <Picture /> components by setting image.experimentalLayout with a default value. This can be overridden by the layout prop on each component.
Example:
{ image: { // Used for all `<Image />` and `<Picture />` components unless overridden experimentalLayout: 'responsive', }, experimental: { responsiveImages: true, },}---import { Image } from 'astro:assets';import myImage from '../assets/my_image.png';---
<Image src={myImage} alt="This will use responsive layout" width={800} height={600} />
<Image src={myImage} alt="This will use full-width layout" layout="full-width" />
<Image src={myImage} alt="This will disable responsive images" layout="none" />For a complete overview, and to give feedback on this experimental API, see the Responsive Images RFC.
#12150 93351bc Thanks @bluwy! - Adds support for passing values other than "production" or "development" to the --mode flag (e.g. "staging", "testing", or any custom value) to change the value of import.meta.env.MODE or the loaded .env file. This allows you take advantage of Viteโs mode feature.
Also adds a new --devOutput flag for astro build that will output a development-based build.
Note that changing the mode does not change the kind of code transform handled by Vite and Astro:
astro dev, Astro will transform code with debug information.astro build, Astro will transform code with the most optimized output and removes debug information.astro build --devOutput (new flag), Astro will transform code with debug information like in astro dev.This enables various usecases like:
# Run the dev server connected to a "staging" APIastro dev --mode staging
# Build a site that connects to a "staging" APIastro build --mode staging
# Build a site that connects to a "production" API with additional debug informationastro build --devOutput
# Build a site that connects to a "testing" APIastro build --mode testingThe different modes can be used to load different .env files, e.g. .env.staging or .env.production, which can be customized for each environment, for example with different API_URL environment variable values.
#12510 14feaf3 Thanks @bholmesdev! - Changes the generated URL query param from _astroAction to _action when submitting a form using Actions. This avoids leaking the framework name into the URL bar, which may be considered a security issue.
#11806 f7f2338 Thanks @Princesseuh! - The value of the different properties on supportedAstroFeatures for adapters can now be objects, with a support and message properties. The content of the message property will be shown in the Astro CLI when the adapter is not compatible with the feature, allowing one to give a better informational message to the user.
This is notably useful with the new limited value, to explain to the user why support is limited.
#12071 61d248e Thanks @Princesseuh! - astro add no longer automatically sets output: 'server'. Since the default value of output now allows for server-rendered pages, it no longer makes sense to default to full server builds when you add an adapter
#11955 d813262 Thanks @matthewp! - Server Islands introduced behind an experimental flag in v4.12.0 is no longer experimental and is available for general use.
Server islands are Astroโs solution for highly cacheable pages of mixed static and dynamic content. They allow you to specify components that should run on the server, allowing the rest of the page to be more aggressively cached, or even generated statically.
Turn any .astro component into a server island by adding the server:defer directive and optionally, fallback placeholder content. It will be rendered dynamically at runtime outside the context of the rest of the page, allowing you to add longer cache headers for the pages, or even prerender them.
---import Avatar from '../components/Avatar.astro';import GenericUser from '../components/GenericUser.astro';---
<header> <h1>Page Title</h1> <div class="header-right"> <Avatar server:defer> <GenericUser slot="fallback" /> </Avatar> </div></header>If you were previously using this feature, please remove the experimental flag from your Astro config:
import { defineConfig } from 'astro/config';
export default defineConfig({ experimental { serverIslands: true, },});If you have been waiting for stabilization before using server islands, you can now do so.
Please see the server island documentation for more about this feature.
#12373 d10f918 Thanks @bholmesdev! - Changes the default behavior for Astro Action form requests to a standard POST submission.
In Astro 4.x, actions called from an HTML form would trigger a redirect with the result forwarded using cookies. This caused issues for large form errors and return values that exceeded the 4 KB limit of cookie-based storage.
Astro 5.0 now renders the result of an action as a POST result without any forwarding. This will introduce a โconfirm form resubmission?โ dialog when a user attempts to refresh the page, though it no longer imposes a 4 KB limit on action return value.
If you prefer to address the โconfirm form resubmission?โ dialog on refresh, or to preserve action results across sessions, you can now customize action result handling from middleware.
We recommend using a session storage provider as described in our Netlify Blob example. However, if you prefer the cookie forwarding behavior from 4.X and accept the 4 KB size limit, you can implement the pattern as shown in this sample snippet:
import { defineMiddleware } from 'astro:middleware';import { getActionContext } from 'astro:actions';
export const onRequest = defineMiddleware(async (context, next) => { // Skip requests for prerendered pages if (context.isPrerendered) return next();
const { action, setActionResult, serializeActionResult } = getActionContext(context);
// If an action result was forwarded as a cookie, set the result // to be accessible from `Astro.getActionResult()` const payload = context.cookies.get('ACTION_PAYLOAD'); if (payload) { const { actionName, actionResult } = payload.json(); setActionResult(actionName, actionResult); context.cookies.delete('ACTION_PAYLOAD'); return next(); }
// If an action was called from an HTML form action, // call the action handler and redirect with the result as a cookie. if (action?.calledFrom === 'form') { const actionResult = await action.handler();
context.cookies.set('ACTION_PAYLOAD', { actionName: action.name, actionResult: serializeActionResult(actionResult), });
if (actionResult.error) { // Redirect back to the previous page on error const referer = context.request.headers.get('Referer'); if (!referer) { throw new Error('Internal: Referer unexpectedly missing from Action POST request.'); } return context.redirect(referer); } // Redirect to the destination page on success return context.redirect(context.originPathname); }
return next();});#12475 3f02d5f Thanks @ascorbic! - Changes the default content config location from src/content/config.* to src/content.config.*.
The previous location is still supported, and is required if the legacy.collections flag is enabled.
#11963 0a1036e Thanks @florian-lefebvre! - Adds a new createCodegenDir() function to the astro:config:setup hook in the Integrations API
In 4.14, we introduced the injectTypes utility on the astro:config:done hook. It can create .d.ts files and make their types available to userโs projects automatically. Under the hood, it creates a file in <root>/.astro/integrations/<normalized_integration_name>.
While the .astro directory has always been the preferred place to write code generated files, it has also been prone to mistakes. For example, you can write a .astro/types.d.ts file, breaking Astro types. Or you can create a file that overrides a file created by another integration.
In this release, <root>/.astro/integrations/<normalized_integration_name> can now be retrieved in the astro:config:setup hook by calling createCodegenDir(). It allows you to have a dedicated folder, avoiding conflicts with another integration or Astro itself. This directory is created by calling this function so itโs safe to write files to it directly:
import { writeFileSync } from 'node:fs';
const integration = { name: 'my-integration', hooks: { 'astro:config:setup': ({ createCodegenDir }) => { const codegenDir = createCodegenDir(); writeFileSync(new URL('cache.json', codegenDir), '{}', 'utf-8'); }, },};#12379 94f4fe8 Thanks @Princesseuh! - Adds a new components exported from astro/components: Welcome, to be used by the new Basics template
#11806 f7f2338 Thanks @Princesseuh! - Adds a new limited value for the different properties of supportedAstroFeatures for adapters, which indicates that the adapter is compatible with the feature, but with some limitations. This is useful for adapters that support a feature, but not in all cases or with all options.
#11925 74722cb Thanks @florian-lefebvre! - Updates astro/config import to reference astro/client types
When importing astro/config, types from astro/client will be made automatically available to your project. If your project tsconfig.json changes how references behave, youโll still have access to these types after running astro sync.
#12081 8679954 Thanks @florian-lefebvre! - Removes the experimental contentCollectionsCache introduced in 3.5.0.
Astro Content Layer API independently solves some of the caching and performance issues with legacy content collections that this strategy attempted to address. This feature has been replaced with continued work on improvements to the content layer. If you were using this experimental feature, you must now remove the flag from your Astro config as it no longer exists:
export default defineConfig({ experimental: { contentCollectionsCache: true }})The cacheManifest boolean argument is no longer passed to the astro:build:done integration hook:
const integration = { name: "my-integration", hooks: { "astro:build:done": ({ cacheManifest, logger }) => {} }}#12565 97f413f Thanks @ascorbic! - Fixes a bug where content types were not generated when first running astro dev unless src/content exists
#11987 bf90a53 Thanks @florian-lefebvre! - render() signature now takes renderOptions as 2nd argument
The signature for app.render() has changed, and the second argument is now an options object called renderOptions with more options for customizing rendering.
The renderOptions are:
addCookieHeader: Determines whether Astro will set the Set-Cookie header, otherwise the adapter is expected to do so itself.clientAddress: The client IP address used to set Astro.clientAddress.locals: An object of locals thatโs set to Astro.locals.routeData: An object specifying the route to use.#12522 33b0e30 Thanks @ascorbic! - Fixes a bug where content config was ignored if it was outside of content dir and has a parent dir with an underscore
#12424 4364bff Thanks @ematipico! - Fixes an issue where an incorrect usage of Astro actions was lost when porting the fix from v4 to v5
#12438 c8f877c Thanks @ascorbic! - Fixes a bug where legacy content types were generated for content layer collections if they were in the content directory
#12035 325a57c Thanks @ascorbic! - Correctly parse values returned from inline loader
#11960 4410130 Thanks @ascorbic! - Fixes an issue where the refresh context data was not passed correctly to content layer loaders
#11878 334948c Thanks @ascorbic! - Adds a new function refreshContent to the astro:server:setup hook that allows integrations to refresh the content layer. This can be used, for example, to register a webhook endpoint during dev, or to open a socket to a CMS to listen for changes.
By default, refreshContent will refresh all collections. You can optionally pass a loaders property, which is an array of loader names. If provided, only collections that use those loaders will be refreshed. For example, A CMS integration could use this property to only refresh its own collections.
You can also pass a context object to the loaders. This can be used to pass arbitrary data, such as the webhook body, or an event from the websocket.
{ name: 'my-integration', hooks: { 'astro:server:setup': async ({ server, refreshContent }) => { server.middlewares.use('/_refresh', async (req, res) => { if(req.method !== 'POST') { res.statusCode = 405 res.end('Method Not Allowed'); return } let body = ''; req.on('data', chunk => { body += chunk.toString(); }); req.on('end', async () => { try { const webhookBody = JSON.parse(body); await refreshContent({ context: { webhookBody }, loaders: ['my-loader'] }); res.writeHead(200, { 'Content-Type': 'application/json' }); res.end(JSON.stringify({ message: 'Content refreshed successfully' })); } catch (error) { res.writeHead(500, { 'Content-Type': 'application/json' }); res.end(JSON.stringify({ error: 'Failed to refresh content: ' + error.message })); } }); }); } }}#11991 d7a396c Thanks @matthewp! - Update error link to on-demand rendering guide
#12127 55e9cd8 Thanks @ascorbic! - Prevents Vite emitting an error when restarting itself
#12516 cb9322c Thanks @stramel! - Handle multiple root nodes on SVG files
#11974 60211de Thanks @ascorbic! - Exports the RenderResult type
#12578 07b9ca8 Thanks @WesSouza! - Explicitly import index.ts to fix types when moduleResolution is NodeNext
#11791 9393243 Thanks @bluwy! - Updates Astroโs default <script> rendering strategy and removes the experimental.directRenderScript option as this is now the default behavior: scripts are always rendered directly. This new strategy prevents scripts from being executed in pages where they are not used.
Scripts will directly render as declared in Astro files (including existing features like TypeScript, importing node_modules, and deduplicating scripts). You can also now conditionally render scripts in your Astro file.
However, this means scripts are no longer hoisted to the <head>, multiple scripts on a page are no longer bundled together, and the <script> tag may interfere with the CSS styling.
As this is a potentially breaking change to your script behavior, please review your <script> tags and ensure that they behave as expected.
#12011 cfdaab2 Thanks @ArmandPhilippot! - Fixes a type and an example in documenting the security.checkOrigin property of Astro config.
#12168 1cd3085 Thanks @ascorbic! - Allows โslugโ as a field in content layer data
#12302 7196c24 Thanks @ematipico! - Fixes an issue where the origin check middleware run for prendered pages
#12341 c1786d6 Thanks @ematipico! - Fixes and issue where Astro.currentLocale always returned the default locale when consumed inside a server island.
#11732 4cd6c43 Thanks @matthewp! - Use GET requests with preloading for Server Islands
Server Island requests include the props used to render the island as well as any slots passed in (excluding the fallback slot). Since browsers have a max 4mb URL length we default to using a POST request to avoid overflowing this length.
However in reality most usage of Server Islands are fairly isolated and wonโt exceed this limit, so a GET request is possible by passing this same information via search parameters.
Using GET means we can also include a <link rel="preload"> tag to speed up the request.
This change implements this, with safe fallback to POST.
#11952 50a0146 Thanks @ascorbic! - Adds support for array patterns in the built-in glob() content collections loader
The glob loader can now accept an array of multiple patterns as well as string patterns. This allows you to more easily combine multiple patterns into a single collection, and also means you can use negative matches to exclude files from the collection.
const probes = defineCollection({ // Load all markdown files in the space-probes directory, except for those that start with "voyager-" loader: glob({ pattern: ['*.md', '!voyager-*'], base: 'src/data/space-probes' }), schema: z.object({ name: z.string(), type: z.enum(['Space Probe', 'Mars Rover', 'Comet Lander']), launch_date: z.date(), status: z.enum(['Active', 'Inactive', 'Decommissioned']), destination: z.string(), operator: z.string(), notable_discoveries: z.array(z.string()), }),});#12022 ddc3a08 Thanks @Princesseuh! - Properly handle including trailing slash on the image endpoint route based on the trailingSlash config
#12169 15fa9ba Thanks @ematipico! - Fixes a bug where configured redirects were incorrectly constructed when reading the file system.
This caused an issue where configuring a redirect in astro.config.mjs like { /old: /new }, failed to trigger the correct redirect in the dev server.
#11914 b5d827b Thanks @ascorbic! - Exports types for all LoaderContext properties from astro/loaders to make it easier to use them in custom loaders.
The ScopedDataStore interface (which was previously internal) is renamed to DataStore, to reflect the fact that itโs the only public API for the data store.
#12270 25192a0 Thanks @ematipico! - Fixes a bug where the params werenโt correctly computed when rendering URLs with non-English characters
#11927 5b4e3ab Thanks @florian-lefebvre! - Updates the env configuration reference docs to include a full API reference for envField.
#12591 b731b3d Thanks @ascorbic! - Fixes a bug where a catchall route would match an image endpoint request
#12073 acf264d Thanks @bluwy! - Replaces ora with yocto-spinner
#12339 bdb75a8 Thanks @ematipico! - Adds an error when Astro.rewrite() is used to rewrite an on-demand route with a static route when using the "server" output.
This is a forbidden rewrite because Astro canโt retrieve the emitted static route at runtime. This route is served by the hosting platform, and not Astro itself.
#12511 d023682 Thanks @stramel! - Fix SVG Component sprite references
#12486 dc3d842 Thanks @matthewp! - Call server island early so it can set headers
#12016 837ee3a Thanks @matthewp! - Fixes actions with large amount of validation errors
#11943 fa4671c Thanks @sarah11918! - Updates error messages that assume content collections are located in src/content/ with more generic language
#12030 10a756a Thanks @ascorbic! - Resolves image paths in content layer with initial slash as project-relative
When using the image() schema helper, previously paths with an initial slash were treated as public URLs. This was to match the behavior of markdown images. However this is a change from before, where paths with an initial slash were treated as project-relative. This change restores the previous behavior, so that paths with an initial slash are treated as project-relative.
#12009 f10a3b7 Thanks @matthewp! - Fixes use of Vitest with Astro 5
#12075 a19530e Thanks @bluwy! - Parses frontmatter ourselves
#12552 15f000c Thanks @avanderbergh! - Fixed an issue where modifying the Request.headers prototype during prerendering caused a build error. Removed conflicting value and writable properties from the headers descriptor to prevent Invalid property descriptor errors.
#12070 9693ad4 Thanks @ematipico! - Fixes an issue where the check origin middleware was incorrectly injected when the build output was "static"
#12169 15fa9ba Thanks @ematipico! - Fixes a bug where the dev server was not providing a consistent user experience for configured redirects.
With the fix, when you configure a redirect in astro.config.mjs like this { /old: "/new" }, the dev server return an HTML response that matches the one emitted by a static build.
Updated dependencies [3ab3b4e, 5608338, 827093e, 560ef15, 83a2a64, 3ab3b4e, a19530e, 1dc8f5e]:
14feaf3 Thanks @bholmesdev! - Changes the generated URL query param from _astroAction to _action when submitting a form using Actions. This avoids leaking the framework name into the URL bar, which may be considered a security issue.#12522 33b0e30 Thanks @ascorbic! - Fixes a bug where content config was ignored if it was outside of content dir and has a parent dir with an underscore
#12516 cb9322c Thanks @stramel! - Handle multiple root nodes on SVG files
#12511 d023682 Thanks @stramel! - Fix SVG Component sprite references
#12498 b140a3f Thanks @ematipico! - Fixes a regression where Astro was trying to access Request.headers
b140a3f Thanks @ematipico! - Fixes a regression where Astro was trying to access Request.headers#12480 c3b7e7c Thanks @matthewp! - Removes the default throw behavior in astro:env
#12444 28dd3ce Thanks @ematipico! - Fixes an issue where a server island hydration script might fail case the island ID misses from the DOM.
#12476 80a9a52 Thanks @florian-lefebvre! - Fixes a case where the Content Layer glob() loader would not update when renaming or deleting an entry
#12418 25baa4e Thanks @oliverlynch! - Fix cached image redownloading if it is the first asset
#12477 46f6b38 Thanks @ematipico! - Fixes an issue where the SSR build was emitting the dist/server/entry.mjs file with an incorrect import at the top of the file/
#12365 a23985b Thanks @apatel369! - Fixes an issue where Astro.currentLocale was not correctly returning the locale for 404 and 500 pages.
#12067 c48916c Thanks @stramel! - Adds experimental support for built-in SVG components.
This feature allows you to import SVG files directly into your Astro project as components. By default, Astro will inline the SVG content into your HTML output.
To enable this feature, set experimental.svg to true in your Astro config:
{ experimental: { svg: true, },}To use this feature, import an SVG file in your Astro project, passing any common SVG attributes to the imported component. Astro also provides a size attribute to set equal height and width properties:
---import Logo from './path/to/svg/file.svg';---
<Logo size={24} />For a complete overview, and to give feedback on this experimental API, see the Feature RFC.
#12329 8309c61 Thanks @florian-lefebvre! - Adds a new astro:routes:resolved hook to the Integration API. Also update the astro:build:done hook by deprecating routes and adding a new assets map.
When building an integration, you can now get access to routes inside the astro:routes:resolved hook:
const integration = () => { return { name: 'my-integration', hooks: { 'astro:routes:resolved': ({ routes }) => { console.log(routes); }, }, };};This hook runs before astro:config:done, and whenever a route changes in development.
The routes array from astro:build:done is now deprecated, and exposed properties are now available on astro:routes:resolved, except for distURL. For this, you can use the newly exposed assets map:
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) } } }}#12377 af867f3 Thanks @ascorbic! - Adds experimental support for automatic responsive images
This feature is experimental and may change in future versions. To enable it, set experimental.responsiveImages to true in your astro.config.mjs file.
{ experimental: { responsiveImages: true, },}When this flag is enabled, you can pass a layout prop to any <Image /> or <Picture /> component to create a responsive image. When a layout is set, images have automatically generated srcset and sizes attributes based on the imageโs dimensions and the layout type. Images with responsive and full-width layouts will have styles applied to ensure they resize according to their container.
---import { Image, Picture } from 'astro:assets';import myImage from '../assets/my_image.png';---
<Image src={myImage} alt="A description of my image." layout="responsive" width={800} height={600}/><Picture src={myImage} alt="A description of my image." layout="full-width" formats={['avif', 'webp', 'jpeg']}/>This <Image /> component will generate the following HTML output:
<img src="/_astro/my_image.hash3.webp" srcset=" /_astro/my_image.hash1.webp 640w, /_astro/my_image.hash2.webp 750w, /_astro/my_image.hash3.webp 800w, /_astro/my_image.hash4.webp 828w, /_astro/my_image.hash5.webp 1080w, /_astro/my_image.hash6.webp 1280w, /_astro/my_image.hash7.webp 1600w " alt="A description of my image" sizes="(min-width: 800px) 800px, 100vw" loading="lazy" decoding="async" fetchpriority="auto" width="800" height="600" style="--w: 800; --h: 600; --fit: cover; --pos: center;" data-astro-image="responsive"/>These are additional properties available to the <Image /> and <Picture /> components when responsive images are enabled:
layout: The layout type for the image. Can be responsive, fixed, full-width or none. Defaults to value of image.experimentalLayout.fit: Defines how the image should be cropped if the aspect ratio is changed. Values match those of CSS object-fit. Defaults to cover, or the value of image.experimentalObjectFit if set.position: Defines the position of the image crop if the aspect ratio is changed. Values match those of CSS object-position. Defaults to center, or the value of image.experimentalObjectPosition if set.priority: If set, eagerly loads the image. Otherwise images will be lazy-loaded. Use this for your largest above-the-fold image. Defaults to false.You can enable responsive images for all <Image /> and <Picture /> components by setting image.experimentalLayout with a default value. This can be overridden by the layout prop on each component.
Example:
{ image: { // Used for all `<Image />` and `<Picture />` components unless overridden experimentalLayout: 'responsive', }, experimental: { responsiveImages: true, },}---import { Image } from 'astro:assets';import myImage from '../assets/my_image.png';---
<Image src={myImage} alt="This will use responsive layout" width={800} height={600} />
<Image src={myImage} alt="This will use full-width layout" layout="full-width" />
<Image src={myImage} alt="This will disable responsive images" layout="none" />For a complete overview, and to give feedback on this experimental API, see the Responsive Images RFC.
#12475 3f02d5f Thanks @ascorbic! - Changes the default content config location from src/content/config.* to src/content.config.*.
The previous location is still supported, and is required if the legacy.collections flag is enabled.
#12436 453ec6b Thanks @martrapp! - Fixes a potential null access in the clientside router
#12392 0462219 Thanks @apatel369! - Fixes an issue where scripts were not correctly injected during the build. The issue was triggered when there were injected routes with the same entrypoint and different pattern
#12373 d10f918 Thanks @bholmesdev! - Changes the default behavior for Astro Action form requests to a standard POST submission.
In Astro 4.x, actions called from an HTML form would trigger a redirect with the result forwarded using cookies. This caused issues for large form errors and return values that exceeded the 4 KB limit of cookie-based storage.
Astro 5.0 now renders the result of an action as a POST result without any forwarding. This will introduce a โconfirm form resubmission?โ dialog when a user attempts to refresh the page, though it no longer imposes a 4 KB limit on action return value.
If you prefer to address the โconfirm form resubmission?โ dialog on refresh, or to preserve action results across sessions, you can now customize action result handling from middleware.
We recommend using a session storage provider as described in our Netlify Blob example. However, if you prefer the cookie forwarding behavior from 4.X and accept the 4 KB size limit, you can implement the pattern as shown in this sample snippet:
import { defineMiddleware } from 'astro:middleware';import { getActionContext } from 'astro:actions';
export const onRequest = defineMiddleware(async (context, next) => { // Skip requests for prerendered pages if (context.isPrerendered) return next();
const { action, setActionResult, serializeActionResult } = getActionContext(context);
// If an action result was forwarded as a cookie, set the result // to be accessible from `Astro.getActionResult()` const payload = context.cookies.get('ACTION_PAYLOAD'); if (payload) { const { actionName, actionResult } = payload.json(); setActionResult(actionName, actionResult); context.cookies.delete('ACTION_PAYLOAD'); return next(); }
// If an action was called from an HTML form action, // call the action handler and redirect with the result as a cookie. if (action?.calledFrom === 'form') { const actionResult = await action.handler();
context.cookies.set('ACTION_PAYLOAD', { actionName: action.name, actionResult: serializeActionResult(actionResult), });
if (actionResult.error) { // Redirect back to the previous page on error const referer = context.request.headers.get('Referer'); if (!referer) { throw new Error('Internal: Referer unexpectedly missing from Action POST request.'); } return context.redirect(referer); } // Redirect to the destination page on success return context.redirect(context.originPathname); }
return next();});#12339 bdb75a8 Thanks @ematipico! - Adds an error when Astro.rewrite() is used to rewrite an on-demand route with a static route when using the "server" output.
This is a forbidden rewrite because Astro canโt retrieve the emitted static route at runtime. This route is served by the hosting platform, and not Astro itself.
acac0af Thanks @ematipico! - Fixes an issue where the dev server returns a 404 status code when a user middleware returns a valid Response.#12305 f5f7109 Thanks @florian-lefebvre! - Fixes a case where the error overlay would not escape the message
#12402 823e73b Thanks @ematipico! - Fixes a case where Astro allowed to call an action without using Astro.callAction. This is now invalid, and Astro will show a proper error.
---import { actions } from "astro:actions";
const result = actions.getUser({ userId: 123 });const result = Astro.callAction(actions.getUser, { userId: 123 });---#12401 9cca108 Thanks @bholmesdev! - Fixes unexpected 200 status in dev server logs for action errors and redirects.
#12311 bf2723e Thanks @dinesh-58! - Adds checked to the list of boolean attributes.
#12363 222f718 Thanks @Fryuni! - Fixes code generated by astro add command when adding a version of an integration other than the default latest.
#12368 493fe43 Thanks @bluwy! - Improves error logs when executing commands
#12355 c4726d7 Thanks @apatel369! - Improves error reporting for invalid frontmatter in MDX files during the astro build command. The error message now includes the file path where the frontmatter parsing failed.
#12333 836cd91 Thanks @imattacus! - Destroy the server response stream if async error is thrown
#12358 7680349 Thanks @spacedawwwg! - Honors inlineAstroConfig parameter in getViteConfig when creating a logger
#12353 35795a1 Thanks @hippotastic! - Fixes an issue in dev server watch file handling that could cause multiple restarts for a single file change.
#12351 5751488 Thanks @florian-lefebvre! - Reverts a change made in 4.16.6 that prevented usage of astro:env secrets inside middleware in SSR
#12346 20e5a84 Thanks @bluwy! - Fixes sourcemap generation when prefetch is enabled
#12349 1fc83d3 Thanks @norskeld! - Fixes the getImage options type so it properly extends ImageTransform
#12268 4e9a3ac Thanks @ematipico! - The command astro add vercel now updates the configuration file differently, and adds @astrojs/vercel as module to import.
This is a breaking change because it requires the version 8.* of @astrojs/vercel.
#12231 90ae100 Thanks @bluwy! - Updates the automatic charset=utf-8 behavior for Markdown pages, where instead of responding with charset=utf-8 in the Content-Type header, Astro will now automatically add the <meta charset="utf-8"> tag instead.
This behaviour only applies to Markdown pages (.md or similar Markdown files located within src/pages/) that do not use Astroโs special layout frontmatter property. It matches the rendering behaviour of other non-content pages, and retains the minimal boilerplate needed to write with non-ASCII characters when adding individual Markdown pages to your site.
If your Markdown pages use the layout frontmatter property, then HTML encoding will be handled by the designated layout component instead, and the <meta charset="utf-8"> tag will not be added to your page by default.
If you require charset=utf-8 to render your page correctly, make sure that your layout components contain the <meta charset="utf-8"> tag. You may need to add this if you have not already done so.
#12243 eb41d13 Thanks @florian-lefebvre! - Improves defineConfig type safety. TypeScript will now error if a group of related configuration options do not have consistent types. For example, you will now see an error if your language set for i18n.defaultLocale is not one of the supported locales specified in i18n.locales.
#12150 93351bc Thanks @bluwy! - Adds support for passing values other than "production" or "development" to the --mode flag (e.g. "staging", "testing", or any custom value) to change the value of import.meta.env.MODE or the loaded .env file. This allows you take advantage of Viteโs mode feature.
Also adds a new --devOutput flag for astro build that will output a development-based build.
Note that changing the mode does not change the kind of code transform handled by Vite and Astro:
astro dev, Astro will transform code with debug information.astro build, Astro will transform code with the most optimized output and removes debug information.astro build --devOutput (new flag), Astro will transform code with debug information like in astro dev.This enables various usecases like:
# Run the dev server connected to a "staging" APIastro dev --mode staging
# Build a site that connects to a "staging" APIastro build --mode staging
# Build a site that connects to a "production" API with additional debug informationastro build --devOutput
# Build a site that connects to a "testing" APIastro build --mode testingThe different modes can be used to load different .env files, e.g. .env.staging or .env.production, which can be customized for each environment, for example with different API_URL environment variable values.
#12302 7196c24 Thanks @ematipico! - Fixes an issue where the origin check middleware run for prendered pages
#12341 c1786d6 Thanks @ematipico! - Fixes and issue where Astro.currentLocale always returned the default locale when consumed inside a server island.
#12270 25192a0 Thanks @ematipico! - Fixes a bug where the params werenโt correctly computed when rendering URLs with non-English characters
#12338 9ca89b3 Thanks @situ2001! - Resets NODE_ENV to ensure install command run in dev mode
#12286 9d6bcdb Thanks @florian-lefebvre! - Fixes a case where a warning for experimental astro:env support would be shown when using an adapter but not actually using astro:env
#12342 ffc836b Thanks @liruifengv! - Fixes a typo in the command name of the CLI
#12301 0cfc69d Thanks @apatel369! - Fixes an issue with action handler context by passing the correct context (ActionAPIContext).
#12312 5642ef9 Thanks @koyopro! - Fixes an issue where using getViteConfig() returns incorrect and duplicate configuration
#12245 1d4f6a4 Thanks @bmenant! - Add components property to MDXInstance type definition (RenderResult and module import)
#12340 94eaeea Thanks @ematipico! - Fixes an issue where Astro actions didnโt work when base was different from /
#12263 e9e8080 Thanks @Fryuni! - Fixes conflict between server islands and on-demand dynamic routes in the form of /[...rest] or /[paramA]/[paramB].
#12279 b781f88 Thanks @jsparkdev! - Update wrong error message
#12273 c2ee963 Thanks @ascorbic! - Fixes an issue with some package managers where sites would not build if TypeScript was not installed.
#12235 a75bc5e Thanks @ematipico! - Fixes a bug where Astro Actions couldnโt redirect to the correct pathname when there was a rewrite involved.
#11839 ff522b9 Thanks @icaliman! - Fixes error when returning a top-level null from an Astro file frontmatter
#12272 388d237 Thanks @ascorbic! - Correctly handles local images when using a base path in SSR
#11823 a3d30a6 Thanks @DerTimonius! - fix: improve error message when inferSize is used in local images with the Image component
#12227 8b1a641 Thanks @florian-lefebvre! - Fixes a case where environment variables would not be refreshed when using astro:env
#12239 2b6daa5 Thanks @ematipico! - BREAKING CHANGE to the experimental Container API only
Changes the default page rendering behavior of Astro components in containers, and adds a new option partial: false to render full Astro pages as before.
Previously, the Container API was rendering all Astro components as if they were full Astro pages containing <!DOCTYPE html> by default. This was not intended, and now by default, all components will render as page partials: only the contents of the components without a page shell.
To render the component as a full-fledged Astro page, pass a new option called partial: false to renderToString() and renderToResponse():
import { experimental_AstroContainer as AstroContainer } from 'astro/container';import Card from '../src/components/Card.astro';
const container = AstroContainer.create();
await container.renderToString(Card); // the string will not contain `<!DOCTYPE html>`await container.renderToString(Card, { partial: false }); // the string will contain `<!DOCTYPE html>`#12226 51d13e2 Thanks @ematipico! - The following renderer fields and integration fields now accept URL as a type:
Renderers:
AstroRenderer.clientEntrpointAstroRenderer.serverEntrypointIntegrations:
InjectedRoute.entrypointAstroIntegrationMiddleware.entrypointDevToolbarAppEntry.entrypoint#12168 1cd3085 Thanks @ascorbic! - Allows โslugโ as a field in content layer data
#12169 15fa9ba Thanks @ematipico! - Fixes a bug where configured redirects were incorrectly constructed when reading the file system.
This caused an issue where configuring a redirect in astro.config.mjs like { /old: /new }, failed to trigger the correct redirect in the dev server.
#12169 15fa9ba Thanks @ematipico! - Fixes a bug where the dev server was not providing a consistent user experience for configured redirects.
With the fix, when you configure a redirect in astro.config.mjs like this { /old: "/new" }, the dev server return an HTML response that matches the one emitted by a static build.
#12223 79ffa5d Thanks @ArmandPhilippot! - Fixes a false positive reported by the dev toolbar Audit app where a label was considered missing when associated with a button
The button element can be used with a label (e.g. to create a switch) and should not be reported as an accessibility issue when used as a child of a label.
#12199 c351352 Thanks @ematipico! - Fixes a regression in the computation of Astro.currentLocale
#12222 fb55695 Thanks @ematipico! - Fixes an issue where the edge middleware couldnโt correctly compute the client IP address when calling ctx.clientAddress()
12b0022 Thanks @bluwy! - Reverts https://github.com/withastro/astro/pull/12173 which caused Can't modify immutable headers warnings and 500 errors on Cloudflare Pages#12177 a4ffbfa Thanks @matthewp! - Ensure we target scripts for execution in the router
Using document.scripts is unsafe because if the application has a name="scripts" this will shadow the built-in document.scripts. Fix is to use getElementsByTagName to ensure weโre only grabbing real scripts.
#12173 2d10de5 Thanks @ematipico! - Fixes a bug where Astro Actions couldnโt redirect to the correct pathname when there was a rewrite involved.
#12039 710a1a1 Thanks @ematipico! - Adds a markdown.shikiConfig.langAlias option that allows aliasing a non-supported code language to a known language. This is useful when the language of your code samples is not a built-in Shiki language, but you want your Markdown source to contain an accurate language while also displaying syntax highlighting.
The following example configures Shiki to highlight cjs code blocks using the javascript syntax highlighter:
import { defineConfig } from 'astro/config';
export default defineConfig({ markdown: { shikiConfig: { langAlias: { cjs: 'javascript', }, }, },});Then in your Markdown, you can use the alias as the language for a code block for syntax highlighting:
```cjs'use strict';
function commonJs() { return 'I am a commonjs file';}```#11984 3ac2263 Thanks @chaegumi! - Adds a new build.concurreny configuration option to specify the number of pages to build in parallel
In most cases, you should not change the default value of 1.
Use this option only when other attempts to reduce the overall rendering time (e.g. batch or cache long running tasks like fetch calls or data access) are not possible or are insufficient.
Use this option only if the refactors are not possible. If the number is set too high, the page rendering may slow down due to insufficient memory resources and because JS is single-threaded.
[!WARNING] This feature is stable and is not considered experimental. However, this feature is only intended to address difficult performance issues, and breaking changes may occur in a minor release to keep this option as performant as possible.
import { defineConfig } from 'astro';
export default defineConfig({ build: { concurrency: 2, },});#12160 c6fd1df Thanks @louisescher! - Fixes a bug where astro.config.mts and astro.config.cts werenโt reloading the dev server upon modifications.
#12130 e96bcae Thanks @thehansys! - Fixes a bug in the parsing of x-forwarded-\* Request headers, where multiple values assigned to those headers were not correctly parsed.
Now, headers like x-forwarded-proto: https,http are correctly parsed.
#12147 9db755a Thanks @ascorbic! - Skips setting statusMessage header for HTTP/2 response
HTTP/2 doesnโt support status message, so setting this was logging a warning.
#12151 bb6d37f Thanks @ematipico! - Fixes an issue where Astro.currentLocale wasnโt incorrectly computed when the defaultLocale belonged to a custom locale path.
Updated dependencies [710a1a1]:
#11979 423dfc1 Thanks @bluwy! - Bumps vite dependency to v6.0.0-beta.2. The version is pinned and will be updated as new Vite versions publish to prevent unhandled breaking changes. For the full list of Vite-specific changes, see its changelog.
#12100 abf9a89 Thanks @astrobot-houston! - Refactors legacy content and data collections to use the Content Layer API glob() loader for better performance and to support backwards compatibility. Also introduces the legacy.collections flag for projects that are unable to update to the new behavior immediately.
:warning: BREAKING CHANGE FOR LEGACY CONTENT COLLECTIONS :warning:
By default, collections that use the old types (content or data) and do not define a loader are now implemented under the hood using the Content Layer APIโs built-in glob() loader, with extra backward-compatibility handling.
In order to achieve backwards compatibility with existing content collections, the following have been implemented:
glob loader collection is defined, with patterns that match the previous handling (matches src/content/<collection name>/**/*.md and other content extensions depending on installed integrations, with underscore-prefixed files and folders ignored)slug field is added with the same format as beforerender() method is added to the entry, so they can be called using entry.render()getEntryBySlug is supportedIn order to achieve backwards compatibility with existing data collections, the following have been implemented:
glob loader collection is defined, with patterns that match the previous handling (matches src/content/<collection name>/**/*{.json,.yaml} and other data extensions, with underscore-prefixed files and folders ignored)getDataEntryById is supportedWhile this backwards compatibility implementation is able to emulate most of the features of legacy collections, there are some differences and limitations that may cause breaking changes to existing collections:
src/content/, even if they were not defined in src/content/config.ts. This behavior is now deprecated, and collections should always be defined in src/content/config.ts. For existing collections, these can just be empty declarations (e.g. const blog = defineCollection({})) and Astro will implicitly define your legacy collection for you in a way that is compatible with the new loading behavior.layout field is not supported in Markdown collection entries. This property is intended only for standalone page files located in src/pages/ and not likely to be in your collection entries. However, if you were using this property, you must now create dynamic routes that include your page styling.getCollection(), the order in which entries are returned may be different than before. If you need a specific order, you should sort the collection entries yourself.image().refine() is not supported. If you need to validate the properties of an image you will need to do this at runtime in your page or component.key argument of getEntry(collection, key) is typed as string, rather than having types for every entry.A new legacy configuration flag legacy.collections is added for users that want to keep their current legacy (content and data) collections behavior (available in Astro v2 - v4), or who are not yet ready to update their projects:
import { defineConfig } from 'astro/config';
export default defineConfig({ legacy: { collections: true, },});When set, no changes to your existing collections are necessary, and the restrictions on storing both new and old collections continue to exist: legacy collections (only) must continue to remain in src/content/, while new collections using a loader from the Content Layer API are forbidden in that folder.
#12079 7febf1f Thanks @ematipico! - params passed in getStaticPaths are no longer automatically decoded.
params arenโt decoded anymore.In Astro v4.x, params in were automatically decoded using decodeURIComponent.
Astro v5.0 doesnโt automatically decode params in getStaticPaths anymore, so youโll need to manually decode them yourself if needed
If you were relying on the automatic decode, youโll need to manually decode it using decodeURI.
Note that the use of decodeURIComponent) is discouraged for getStaticPaths because it decodes more characters than it should, for example /, ?, # and more.
---export function getStaticPaths() { return [ { params: { id: decodeURI("%5Bpage%5D") } }, { params: { id: "%5Bpage%5D" } }, ]}
const { id } = Astro.params;---#12121 2490ceb Thanks @ascorbic! - Support passing the values Infinity and -Infinity as island props.
#12118 f47b347 Thanks @Namchee! - Removes the strip-ansi dependency in favor of the native Node API
#12126 6e1dfeb Thanks @ascorbic! - Clear content layer cache when astro version changes
#12117 a46839a Thanks @ArmandPhilippot! - Updates Vite links to use their new domain
#12124 499fbc9 Thanks @ascorbic! - Allows special characters in Action names
#12123 b8673df Thanks @Princesseuh! - Fixes missing body property on CollectionEntry types for content layer entries
#12132 de35daa Thanks @jcayzac! - Updates the cookie dependency to avoid the CVE 2024-47764 vulnerability.
#12113 a54e520 Thanks @ascorbic! - Adds a helpful error when attempting to render an undefined collection entry
#12097 11d447f Thanks @ascorbic! - Fixes error where references in content layer schemas sometimes incorrectly report as missing
#12108 918953b Thanks @lameuler! - Fixes a bug where data URL images were not correctly handled. The bug resulted in an ENAMETOOLONG error.
#12105 42037f3 Thanks @ascorbic! - Returns custom statusText that has been set in a Response
#12109 ea22558 Thanks @ematipico! - Fixes a regression that was introduced by an internal refactor of how the middleware is loaded by the Astro application. The regression was introduced by #11550.
When the edge middleware feature is opted in, Astro removes the middleware function from the SSR manifest, and this wasnโt taken into account during the refactor.
#12106 d3a74da Thanks @ascorbic! - Handles case where an immutable Response object is returned from an endpoint
#12090 d49a537 Thanks @markjaquith! - Server islands: changes the server island HTML placeholder comment so that it is much less likely to get removed by HTML minifiers.
#12047 21b5e80 Thanks @rgodha24! - Adds a new optional parser property to the built-in file() loader for content collections to support additional file types such as toml and csv.
The file() loader now accepts a second argument that defines a parser function. This allows you to specify a custom parser (e.g. toml.parse or csv-parse) to create a collection from a fileโs contents. The file() loader will automatically detect and parse JSON and YAML files (based on their file extension) with no need for a parser.
This works with any type of custom file formats including csv and toml. The following example defines a content collection dogs using a .toml file.
[[dogs]]id = "..."age = "..."
[[dogs]]id = "..."age = "..."After importing TOMLโs parser, you can load the dogs collection into your project by passing both a file path and parser to the file() loader.
import { defineCollection } from "astro:content"import { file } from "astro/loaders"import { parse as parseToml } from "toml"
const dogs = defineCollection({ loader: file("src/data/dogs.toml", { parser: (text) => parseToml(text).dogs }), schema: /* ... */})
// it also works with CSVs!import { parse as parseCsv } from "csv-parse/sync";
const cats = defineCollection({ loader: file("src/data/cats.csv", { parser: (text) => parseCsv(text, { columns: true, skipEmptyLines: true })})});The parser argument also allows you to load a single collection from a nested JSON document. For example, this JSON file contains multiple collections:
{ "dogs": [{}], "cats": [{}] }You can seperate these collections by passing a custom parser to the file() loader like so:
const dogs = defineCollection({ loader: file('src/data/pets.json', { parser: (text) => JSON.parse(text).dogs }),});const cats = defineCollection({ loader: file('src/data/pets.json', { parser: (text) => JSON.parse(text).cats }),});And it continues to work with maps of id to data
bubbles: breed: 'Goldfish' age: 2finn: breed: 'Betta' age: 1const fish = defineCollection({ loader: file('src/data/fish.yaml'), schema: z.object({ breed: z.string(), age: z.number() }),});#12071 61d248e Thanks @Princesseuh! - astro add no longer automatically sets output: 'server'. Since the default value of output now allows for server-rendered pages, it no longer makes sense to default to full server builds when you add an adapter
#11963 0a1036e Thanks @florian-lefebvre! - Adds a new createCodegenDir() function to the astro:config:setup hook in the Integrations API
In 4.14, we introduced the injectTypes utility on the astro:config:done hook. It can create .d.ts files and make their types available to userโs projects automatically. Under the hood, it creates a file in <root>/.astro/integrations/<normalized_integration_name>.
While the .astro directory has always been the preferred place to write code generated files, it has also been prone to mistakes. For example, you can write a .astro/types.d.ts file, breaking Astro types. Or you can create a file that overrides a file created by another integration.
In this release, <root>/.astro/integrations/<normalized_integration_name> can now be retrieved in the astro:config:setup hook by calling createCodegenDir(). It allows you to have a dedicated folder, avoiding conflicts with another integration or Astro itself. This directory is created by calling this function so itโs safe to write files to it directly:
import { writeFileSync } from 'node:fs';
const integration = { name: 'my-integration', hooks: { 'astro:config:setup': ({ createCodegenDir }) => { const codegenDir = createCodegenDir(); writeFileSync(new URL('cache.json', codegenDir), '{}', 'utf-8'); }, },};#12081 8679954 Thanks @florian-lefebvre! - Removes the experimental contentCollectionsCache introduced in 3.5.0.
Astro Content Layer API independently solves some of the caching and performance issues with legacy content collections that this strategy attempted to address. This feature has been replaced with continued work on improvements to the content layer. If you were using this experimental feature, you must now remove the flag from your Astro config as it no longer exists:
export default defineConfig({ experimental: { contentCollectionsCache: true }})The cacheManifest boolean argument is no longer passed to the astro:build:done integration hook:
const integration = { name: "my-integration", hooks: { "astro:build:done": ({ cacheManifest, logger }) => {} }}#12073 acf264d Thanks @bluwy! - Replaces ora with yocto-spinner
#12075 a19530e Thanks @bluwy! - Parses frontmatter ourselves
#12070 9693ad4 Thanks @ematipico! - Fixes an issue where the check origin middleware was incorrectly injected when the build output was "static"
Updated dependencies [a19530e]:
#12084 12dae50 Thanks @Princesseuh! - Adds missing filePath property on content layer entries
#12046 d7779df Thanks @martrapp! - View transitions: Fixes Astroโs fade animation to prevent flashing during morph transitions.
#12043 1720c5b Thanks @bluwy! - Fixes injected endpoint prerender option detection
#12095 76c5fbd Thanks @TheOtterlord! - Fix installing non-stable versions of integrations with astro add
#12035 325a57c Thanks @ascorbic! - Correctly parse values returned from inline loader
#12022 ddc3a08 Thanks @Princesseuh! - Properly handle including trailing slash on the image endpoint route based on the trailingSlash config
#12016 837ee3a Thanks @matthewp! - Fixes actions with large amount of validation errors
#12030 10a756a Thanks @ascorbic! - Resolves image paths in content layer with initial slash as project-relative
When using the image() schema helper, previously paths with an initial slash were treated as public URLs. This was to match the behavior of markdown images. However this is a change from before, where paths with an initial slash were treated as project-relative. This change restores the previous behavior, so that paths with an initial slash are treated as project-relative.
#12034 5b3ddfa Thanks @ematipico! - Fixes an issue where the middleware wasnโt called when a project uses 404.astro.
#12042 243ecb6 Thanks @ematipico! - Fixes a problem in the Container API, where a polyfill wasnโt correctly applied. This caused an issue in some environments where crypto isnโt supported.
#12038 26ea5e8 Thanks @ascorbic! - Resolves image paths in content layer with initial slash as project-relative
When using the image() schema helper, previously paths with an initial slash were treated as public URLs. This was to match the behavior of markdown images. However this is a change from before, where paths with an initial slash were treated as project-relative. This change restores the previous behavior, so that paths with an initial slash are treated as project-relative.
#12014 53cb41e Thanks @ascorbic! - Fixes an issue where component styles were not correctly included in rendered MDX
#12031 8c0cae6 Thanks @ematipico! - Fixes a bug where the rewrite via next(/*..*/) inside a middleware didnโt compute the new APIContext.params
#12026 40e7a1b Thanks @bluwy! - Initializes the Markdown processor only when thereโs .md files
#12028 d3bd673 Thanks @bluwy! - Handles route collision detection only if it matches getStaticPaths
#12027 dd3b753 Thanks @fviolette! - Add selected to the list of boolean attributes
#12001 9be3e1b Thanks @uwej711! - Remove dependency on path-to-regexp
#12008 5608338 Thanks @Princesseuh! - Welcome to the Astro 5 beta! This release has no changes from the latest alpha of this package, but it does bring us one step closer to the final, stable release.
Starting from this release, no breaking changes will be introduced unless absolutely necessary.
To learn how to upgrade, check out the Astro v5.0 upgrade guide in our beta docs site.
5608338]:
#11982 d84e444 Thanks @Princesseuh! - Adds a default exclude and include value to the tsconfig presets. {projectDir}/dist is now excluded by default, and {projectDir}/.astro/types.d.ts and {projectDir}/**/* are included by default.
Both of these options can be overridden by setting your own values to the corresponding settings in your tsconfig.json file.
#11987 bf90a53 Thanks @florian-lefebvre! - The locals object can no longer be overridden
Middleware, API endpoints, and pages can no longer override the locals object in its entirety. You can still append values onto the object, but you can not replace the entire object and delete its existing values.
If you were previously overwriting like so:
ctx.locals = { one: 1, two: 2,};This can be changed to an assignment on the existing object instead:
Object.assign(ctx.locals, { one: 1, two: 2,});#11980 a604a0c Thanks @matthewp! - ViewTransitions component renamed to ClientRouter
The <ViewTransitions /> component has been renamed to <ClientRouter />. There are no other changes than the name. The old name will continue to work in Astro 5.x, but will be removed in 6.0.
This change was done to clarify the role of the component within Astroโs View Transitions support. Astro supports View Transitions APIs in a few different ways, and renaming the component makes it more clear that the features you get from the ClientRouter component are slightly different from what you get using the native CSS-based MPA router.
We still intend to maintain the ClientRouter as before, and itโs still important for use-cases that the native support doesnโt cover, such as persisting state between pages.
#11987 bf90a53 Thanks @florian-lefebvre! - render() signature now takes renderOptions as 2nd argument
The signature for app.render() has changed, and the second argument is now an options object called renderOptions with more options for customizing rendering.
The renderOptions are:
addCookieHeader: Determines whether Astro will set the Set-Cookie header, otherwise the adapter is expected to do so itself.clientAddress: The client IP address used to set Astro.clientAddress.locals: An object of locals thatโs set to Astro.locals.routeData: An object specifying the route to use.#11991 d7a396c Thanks @matthewp! - Update error link to on-demand rendering guide
#11864 ee38b3a Thanks @ematipico! - ### [changed]: entryPoint type inside the hook astro:build:ssr
In Astro v4.x, the entryPoint type was RouteData.
Astro v5.0 the entryPoint type is IntegrationRouteData, which contains a subset of the RouteData type. The fields isIndex and fallbackRoutes were removed.
Update your adapter to change the type of entryPoint from RouteData to IntegrationRouteData.
import type {RouteData} from 'astro';import type {IntegrationRouteData} from "astro"
function useRoute(route: RouteData) {function useRoute(route: IntegrationRouteData) {
}#11908 518433e Thanks @Princesseuh! - The image.endpoint config now allow customizing the route of the image endpoint in addition to the entrypoint. This can be useful in niche situations where the default route /_image conflicts with an existing route or your local server setup.
import { defineConfig } from 'astro/config';
defineConfig({ image: { endpoint: { route: '/image', entrypoint: './src/image_endpoint.ts', }, },});#11806 f7f2338 Thanks @Princesseuh! - Removes the assets property on supportedAstroFeatures for adapters, as it did not reflect reality properly in many cases.
Now, relating to assets, only a single sharpImageService property is available, determining if the adapter is compatible with the built-in sharp image service.
#11864 ee38b3a Thanks @ematipico! - ### [changed]: routes type inside the hook astro:build:done
In Astro v4.x, the routes type was RouteData.
Astro v5.0 the routes type is IntegrationRouteData, which contains a subset of the RouteData type. The fields isIndex and fallbackRoutes were removed.
Update your adapter to change the type of routes from RouteData to IntegrationRouteData.
import type {RouteData} from 'astro';import type {IntegrationRouteData} from "astro"
function useRoute(route: RouteData) {function useRoute(route: IntegrationRouteData) {
}#11864 ee38b3a Thanks @ematipico! - ### [changed]: RouteData.distURL is now an array
In Astro v4.x, RouteData.distURL was undefined or a URL
Astro v5.0, RouteData.distURL is undefined or an array of URL. This was a bug, because a route can generate multiple files on disk, especially when using dynamic routes such as [slug] or [...slug].
Update your code to handle RouteData.distURL as an array.
if (route.distURL) { if (route.distURL.endsWith('index.html')) { // do something } for (const url of route.distURL) { if (url.endsWith('index.html')) { // do something } }}#11806 f7f2338 Thanks @Princesseuh! - The value of the different properties on supportedAstroFeatures for adapters can now be objects, with a support and message properties. The content of the message property will be shown in the Astro CLI when the adapter is not compatible with the feature, allowing one to give a better informational message to the user.
This is notably useful with the new limited value, to explain to the user why support is limited.
#11955 d813262 Thanks @matthewp! - Server Islands introduced behind an experimental flag in v4.12.0 is no longer experimental and is available for general use.
Server islands are Astroโs solution for highly cacheable pages of mixed static and dynamic content. They allow you to specify components that should run on the server, allowing the rest of the page to be more aggressively cached, or even generated statically.
Turn any .astro component into a server island by adding the server:defer directive and optionally, fallback placeholder content. It will be rendered dynamically at runtime outside the context of the rest of the page, allowing you to add longer cache headers for the pages, or even prerender them.
---import Avatar from '../components/Avatar.astro';import GenericUser from '../components/GenericUser.astro';---
<header> <h1>Page Title</h1> <div class="header-right"> <Avatar server:defer> <GenericUser slot="fallback" /> </Avatar> </div></header>If you were previously using this feature, please remove the experimental flag from your Astro config:
import { defineConfig } from 'astro/config';
export default defineConfig({ experimental { serverIslands: true, },});If you have been waiting for stabilization before using server islands, you can now do so.
Please see the server island documentation for more about this feature.
#11806 f7f2338 Thanks @Princesseuh! - Adds a new limited value for the different properties of supportedAstroFeatures for adapters, which indicates that the adapter is compatible with the feature, but with some limitations. This is useful for adapters that support a feature, but not in all cases or with all options.
#11925 74722cb Thanks @florian-lefebvre! - Updates astro/config import to reference astro/client types
When importing astro/config, types from astro/client will be made automatically available to your project. If your project tsconfig.json changes how references behave, youโll still have access to these types after running astro sync.
#11974 60211de Thanks @ascorbic! - Exports the RenderResult type
#11939 7b09c62 Thanks @bholmesdev! - Adds support for Zod discriminated unions on Action form inputs. This allows forms with different inputs to be submitted to the same action, using a given input to decide which object should be used for validation.
This example accepts either a create or update form submission, and uses the type field to determine which object to validate against.
import { defineAction } from 'astro:actions';import { z } from 'astro:schema';
export const server = { changeUser: defineAction({ accept: 'form', input: z.discriminatedUnion('type', [ z.object({ type: z.literal('create'), name: z.string(), email: z.string().email(), }), z.object({ type: z.literal('update'), id: z.number(), name: z.string(), email: z.string().email(), }), ]), async handler(input) { if (input.type === 'create') { // input is { type: 'create', name: string, email: string } } else { // input is { type: 'update', id: number, name: string, email: string } } }, }),};The corresponding create and update forms may look like this:
---import { actions } from 'astro:actions';---
<!--Create--><form action={actions.changeUser} method="POST"> <input type="hidden" name="type" value="create" /> <input type="text" name="name" required /> <input type="email" name="email" required /> <button type="submit">Create User</button></form>
<!--Update--><form action={actions.changeUser} method="POST"> <input type="hidden" name="type" value="update" /> <input type="hidden" name="id" value="user-123" /> <input type="text" name="name" required /> <input type="email" name="email" required /> <button type="submit">Update User</button></form>#11939 7b09c62 Thanks @bholmesdev! - Adds support for Zod discriminated unions on Action form inputs. This allows forms with different inputs to be submitted to the same action, using a given input to decide which object should be used for validation.
This example accepts either a create or update form submission, and uses the type field to determine which object to validate against.
import { defineAction } from 'astro:actions';import { z } from 'astro:schema';
export const server = { changeUser: defineAction({ accept: 'form', input: z.discriminatedUnion('type', [ z.object({ type: z.literal('create'), name: z.string(), email: z.string().email(), }), z.object({ type: z.literal('update'), id: z.number(), name: z.string(), email: z.string().email(), }), ]), async handler(input) { if (input.type === 'create') { // input is { type: 'create', name: string, email: string } } else { // input is { type: 'update', id: number, name: string, email: string } } }, }),};The corresponding create and update forms may look like this:
---import { actions } from 'astro:actions';---
<!--Create--><form action={actions.changeUser} method="POST"> <input type="hidden" name="type" value="create" /> <input type="text" name="name" required /> <input type="email" name="email" required /> <button type="submit">Create User</button></form>
<!--Update--><form action={actions.changeUser} method="POST"> <input type="hidden" name="type" value="update" /> <input type="hidden" name="id" value="user-123" /> <input type="text" name="name" required /> <input type="email" name="email" required /> <button type="submit">Update User</button></form>#11968 86ad1fd Thanks @NikolaRHristov! - Fixes a typo in the server island JSDoc
#11983 633eeaa Thanks @uwej711! - Remove dependency on path-to-regexp
#11941 b6a5f39 Thanks @Princesseuh! - Merges the output: 'hybrid' and output: 'static' configurations into one single configuration (now called 'static') that works the same way as the previous hybrid option.
It is no longer necessary to specify output: 'hybrid' in your Astro config to use server-rendered pages. The new output: 'static' has this capability included. Astro will now automatically provide the ability to opt out of prerendering in your static site with no change to your output configuration required. Any page route or endpoint can include export const prerender = false to be server-rendered, while the rest of your site is statically-generated.
If your project used hybrid rendering, you must now remove the output: 'hybrid' option from your Astro config as it no longer exists. However, no other changes to your project are required, and you should have no breaking changes. The previous 'hybrid' behavior is now the default, under a new name 'static'.
If you were using the output: 'static' (default) option, you can continue to use it as before. By default, all of your pages will continue to be prerendered and you will have a completely static site. You should have no breaking changes to your project.
import { defineConfig } from "astro/config";
export default defineConfig({ output: 'hybrid',});An adapter is still required to deploy an Astro project with any server-rendered pages. Failure to include an adapter will result in a warning in development and an error at build time.
#11941 b6a5f39 Thanks @Princesseuh! - Adapters can now specify the build output type theyโre intended for using the adapterFeatures.buildOutput property. This property can be used to always generate a server output, even if the project doesnโt have any server-rendered pages.
{ 'astro:config:done': ({ setAdapter, config }) => { setAdapter({ name: 'my-adapter', adapterFeatures: { buildOutput: 'server', }, }); },}If your adapter specifies buildOutput: 'static', and the userโs project contains server-rendered pages, Astro will warn in development and error at build time. Note that a hybrid output, containing both static and server-rendered pages, is considered to be a server output, as a server is required to serve the server-rendered pages.
#11941 b6a5f39 Thanks @Princesseuh! - Adds a new buildOutput property to the astro:config:done hook returning the build output type.
This can be used to know if the userโs project will be built as a static site (HTML files), or a server-rendered site (whose exact output depends on the adapter).
#11960 4410130 Thanks @ascorbic! - Fixes an issue where the refresh context data was not passed correctly to content layer loaders
#11952 50a0146 Thanks @ascorbic! - Adds support for array patterns in the built-in glob() content collections loader
The glob loader can now accept an array of multiple patterns as well as string patterns. This allows you to more easily combine multiple patterns into a single collection, and also means you can use negative matches to exclude files from the collection.
const probes = defineCollection({ // Load all markdown files in the space-probes directory, except for those that start with "voyager-" loader: glob({ pattern: ['*.md', '!voyager-*'], base: 'src/data/space-probes' }), schema: z.object({ name: z.string(), type: z.enum(['Space Probe', 'Mars Rover', 'Comet Lander']), launch_date: z.date(), status: z.enum(['Active', 'Inactive', 'Decommissioned']), destination: z.string(), operator: z.string(), notable_discoveries: z.array(z.string()), }),});#11916 46ea29f Thanks @bluwy! - Updates how the build.client and build.server option values get resolved to match existing documentation. With this fix, the option values will now correctly resolve relative to the outDir option. So if outDir is set to ./dist/nested/, then by default:
build.client will resolve to <root>/dist/nested/client/build.server will resolve to <root>/dist/nested/server/Previously the values were incorrectly resolved:
build.client was resolved to <root>/dist/nested/dist/client/build.server was resolved to <root>/dist/nested/dist/server/If you were relying on the previous build paths, make sure that your project code is updated to the new build paths.
#11875 a8a3d2c Thanks @florian-lefebvre! - Adds a new property isPrerendered to the globals Astro and APIContext . This boolean value represents whether or not the current page is prerendered:
---export const prerender = true;---export const onRequest = (ctx, next) => { console.log(ctx.isPrerendered); // it will log true return next();};#11927 5b4e3ab Thanks @florian-lefebvre! - Updates the env configuration reference docs to include a full API reference for envField.
#11943 fa4671c Thanks @sarah11918! - Updates error messages that assume content collections are located in src/content/ with more generic language
#11879 bd1d4aa Thanks @matthewp! - Allow passing a cryptography key via ASTRO_KEY
For Server islands Astro creates a cryptography key in order to hash props for the islands, preventing accidental leakage of secrets.
If you deploy to an environment with rolling updates then there could be multiple instances of your app with different keys, causing potential key mismatches.
To fix this you can now pass the ASTRO_KEY environment variable to your build in order to reuse the same key.
To generate a key use:
astro create-keyThis will print out an environment variable to set like:
ASTRO_KEY=PIAuyPNn2aKU/bviapEuc/nVzdzZPizKNo3OqF/5PmQ=#11935 c58193a Thanks @Princesseuh! - Fixes astro add not using the proper export point when adding certain adapters
#11902 d63bc50 Thanks @ascorbic! - Fixes case where content layer did not update during clean dev builds on Linux and Windows
#11886 7ff7134 Thanks @matthewp! - Fixes a missing error message when actions throws during astro sync
#11904 ca54e3f Thanks @wtchnm! - perf(assets): avoid downloading original image when using cache
#11859 3804711 Thanks @florian-lefebvre! - Changes the default tsconfig.json with better defaults, and makes src/env.d.ts optional
Astroโs default tsconfig.json in starter examples has been updated to include generated types and exclude your build output. This means that src/env.d.ts is only necessary if you have added custom type declarations or if youโre not using a tsconfig.json file.
Additionally, running astro sync no longer creates, nor updates, src/env.d.ts as it is not required for type-checking standard Astro projects.
To update your project to Astroโs recommended TypeScript settings, please add the following include and exclude properties to tsconfig.json:
{ "extends": "astro/tsconfigs/base", "include": ["**/*", ".astro/types.d.ts"], "exclude": ["dist"]}#11911 c3dce83 Thanks @ascorbic! - The Content Layer API introduced behind a flag in 4.14.0 is now stable and ready for use in Astro v5.0.
The new Content Layer API builds upon content collections, taking them beyond local files in src/content/ and allowing you to fetch content from anywhere, including remote APIs. These new collections work alongside your existing content collections, and you can migrate them to the new API at your own pace. There are significant improvements to performance with large collections of local files. For more details, see the Content Layer RFC.
If you previously used this feature, you can now remove the experimental.contentLayer flag from your Astro config:
import { defineConfig } from 'astro'
export default defineConfig({ experimental: { contentLayer: true }})The core of the new Content Layer API is the loader, a function that fetches content from a source and caches it in a local data store. Astro 4.14 ships with built-in glob() and file() loaders to handle your local Markdown, MDX, Markdoc, and JSON files:
import { defineCollection, z } from 'astro:content';import { glob } from 'astro/loaders';
const blog = defineCollection({ // The ID is a slug generated from the path of the file relative to `base` loader: glob({ pattern: '**/*.md', base: './src/data/blog' }), schema: z.object({ title: z.string(), description: z.string(), publishDate: z.coerce.date(), }),});
export const collections = { blog };You can then query using the existing content collections functions, and use a simplified render() function to display your content:
---import { getEntry, render } from 'astro:content';
const post = await getEntry('blog', Astro.params.slug);
const { Content } = await render(entry);---
<Content />Youโre not restricted to the built-in loaders โ we hope youโll try building your own. You can fetch content from anywhere and return an array of entries:
const countries = defineCollection({ loader: async () => { const response = await fetch('https://restcountries.com/v3.1/all'); const data = await response.json(); // Must return an array of entries with an id property, // or an object with IDs as keys and entries as values return data.map((country) => ({ id: country.cca3, ...country, })); }, // optionally add a schema to validate the data and make it type-safe for users // schema: z.object...});
export const collections = { countries };For more advanced loading logic, you can define an object loader. This allows incremental updates and conditional loading, and gives full access to the data store. It also allows a loader to define its own schema, including generating it dynamically based on the source API. See the the Content Layer API RFC for more details.
Loaders are better when theyโre shared. You can create a package that exports a loader and publish it to npm, and then anyone can use it on their site. Weโre excited to see what the community comes up with! To get started, take a look at some examples. Hereโs how to load content using an RSS/Atom feed loader:
import { defineCollection } from 'astro:content';import { feedLoader } from '@ascorbic/feed-loader';
const podcasts = defineCollection({ loader: feedLoader({ url: 'https://feeds.99percentinvisible.org/99percentinvisible', }),});
export const collections = { podcasts };To learn more, see the Content Layer RFC.
#11902 d63bc50 Thanks @ascorbic! - Fixes case where content layer did not update during clean dev builds on Linux and Windows
#11914 b5d827b Thanks @ascorbic! - Exports types for all LoaderContext properties from astro/loaders to make it easier to use them in custom loaders.
The ScopedDataStore interface (which was previously internal) is renamed to DataStore, to reflect the fact that itโs the only public API for the data store.
#11861 3ab3b4e Thanks @bluwy! - Cleans up Astro-specfic metadata attached to vfile.data in Remark and Rehype plugins. Previously, the metadata was attached in different locations with inconsistent names. The metadata is now renamed as below:
vfile.data.__astroHeadings -> vfile.data.astro.headingsvfile.data.imagePaths -> vfile.data.astro.imagePathsThe types of imagePaths has also been updated from Set<string> to string[]. The vfile.data.astro.frontmatter metadata is left unchanged.
While we donโt consider these APIs public, they can be accessed by Remark and Rehype plugins that want to re-use Astroโs metadata. If you are using these APIs, make sure to access them in the new locations.
#11825 560ef15 Thanks @bluwy! - Updates internal Shiki rehype plugin to highlight code blocks as hast (using Shikiโs codeToHast() API). This allows a more direct Markdown and MDX processing, and improves the performance when building the project, but may cause issues with existing Shiki transformers.
If you are using Shiki transformers passed to markdown.shikiConfig.transformers, you must make sure they do not use the postprocess hook as it no longer runs on code blocks in .md and .mdx files. (See the Shiki documentation on transformer hooks for more information).
Code blocks in .mdoc files and <Code /> component do not use the internal Shiki rehype plugin and are unaffected.
#11819 2bdde80 Thanks @bluwy! - Updates the Astro config loading flow to ignore processing locally-linked dependencies with Vite (e.g. npm link, in a monorepo, etc). Instead, they will be normally imported by the Node.js runtime the same way as other dependencies from node_modules.
Previously, Astro would process locally-linked dependencies which were able to use Vite features like TypeScript when imported by the Astro config file.
However, this caused confusion as integration authors may test against a package that worked locally, but not when published. This method also restricts using CJS-only dependencies because Vite requires the code to be ESM. Therefore, Astroโs behaviour is now changed to ignore processing any type of dependencies by Vite.
In most cases, make sure your locally-linked dependencies are built to JS before running the Astro project, and the config loading should work as before.
#11878 334948c Thanks @ascorbic! - Adds a new function refreshContent to the astro:server:setup hook that allows integrations to refresh the content layer. This can be used, for example, to register a webhook endpoint during dev, or to open a socket to a CMS to listen for changes.
By default, refreshContent will refresh all collections. You can optionally pass a loaders property, which is an array of loader names. If provided, only collections that use those loaders will be refreshed. For example, A CMS integration could use this property to only refresh its own collections.
You can also pass a context object to the loaders. This can be used to pass arbitrary data, such as the webhook body, or an event from the websocket.
{ name: 'my-integration', hooks: { 'astro:server:setup': async ({ server, refreshContent }) => { server.middlewares.use('/_refresh', async (req, res) => { if(req.method !== 'POST') { res.statusCode = 405 res.end('Method Not Allowed'); return } let body = ''; req.on('data', chunk => { body += chunk.toString(); }); req.on('end', async () => { try { const webhookBody = JSON.parse(body); await refreshContent({ context: { webhookBody }, loaders: ['my-loader'] }); res.writeHead(200, { 'Content-Type': 'application/json' }); res.end(JSON.stringify({ message: 'Content refreshed successfully' })); } catch (error) { res.writeHead(500, { 'Content-Type': 'application/json' }); res.end(JSON.stringify({ error: 'Failed to refresh content: ' + error.message })); } }); }); } }}Updated dependencies [3ab3b4e, 560ef15, 3ab3b4e]:
#11870 8e5257a Thanks @ArmandPhilippot! - Fixes typo in documenting the fallbackType property in i18n routing
#11884 e450704 Thanks @ascorbic! - Correctly handles content layer data where the transformed value does not match the input schema
#11900 80b4a18 Thanks @delucis! - Fixes the user-facing type of the new i18n.routing.fallbackType option to be optional
#11826 7315050 Thanks @matthewp! - Deprecate Astro.glob
The Astro.glob function has been deprecated in favor of Content Collections and import.meta.glob.
import.meta.glob(https://vitejs.dev/guide/features.html#glob-import).Also consider using glob packages from npm, like fast-glob, especially if statically generating your site, as it is faster for most use-cases.
The easiest path is to migrate to import.meta.glob like so:
const posts = Astro.glob('./posts/*.md');const posts = Object.values(import.meta.glob('./posts/*.md', { eager: true }));#11827 a83e362 Thanks @matthewp! - Prevent usage of astro:content in the client
Usage of astro:content in the client has always been discouraged because it leads to all of your content winding up in your client bundle, and can possibly leaks secrets.
This formally makes doing so impossible, adding to the previous warning with errors.
In the future Astro might add APIs for client-usage based on needs.
#11253 4e5cc5a Thanks @kevinzunigacuellar! - Changes the data returned for page.url.current, page.url.next, page.url.prev, page.url.first and page.url.last to include the value set for base in your Astro config.
Previously, you had to manually prepend your configured value for base to the URL path. Now, Astro automatically includes your base value in next and prev URLs.
If you are using the paginate() function for โpreviousโ and โnextโ URLs, remove any existing base value as it is now added for you:
---export async function getStaticPaths({ paginate }) { const astronautPages = [{ astronaut: 'Neil Armstrong', }, { astronaut: 'Buzz Aldrin', }, { astronaut: 'Sally Ride', }, { astronaut: 'John Glenn', }]; return paginate(astronautPages, { pageSize: 1 });}const { page } = Astro.props;// `base: /'docs'` configured in `astro.config.mjs` const prev = "/docs" + page.url.prev; const prev = page.url.prev;---<a id="prev" href={prev}>Back</a>#11698 05139ef Thanks @ematipico! - Adds a new property to the globals Astro and APIContext called routePattern. The routePattern represents the current route (component)
that is being rendered by Astro. Itโs usually a path pattern will look like this: blog/[slug]:
---const route = Astro.routePattern;console.log(route); // it will log "blog/[slug]"---export const GET = (ctx) => { console.log(ctx.routePattern); // it will log src/pages/index.js return new Response.json({ loreum: 'ipsum' });};#11791 9393243 Thanks @bluwy! - Updates Astroโs default <script> rendering strategy and removes the experimental.directRenderScript option as this is now the default behavior: scripts are always rendered directly. This new strategy prevents scripts from being executed in pages where they are not used.
Scripts will directly render as declared in Astro files (including existing features like TypeScript, importing node_modules, and deduplicating scripts). You can also now conditionally render scripts in your Astro file.
However, this means scripts are no longer hoisted to the <head>, multiple scripts on a page are no longer bundled together, and the <script> tag may interfere with the CSS styling.
As this is a potentially breaking change to your script behavior, please review your <script> tags and ensure that they behave as expected.
#11767 d1bd1a1 Thanks @ascorbic! - Refactors content layer sync to use a queue
#11729 1c54e63 Thanks @ematipico! - Adds a new variant sync for the astro:config:setup hookโs command property. This value is set when calling the command astro sync.
If your integration previously relied on knowing how many variants existed for the command property, you must update your logic to account for this new option.
#11743 cce0894 Thanks @ph1p! - Adds a new, optional property timeout for the client:idle directive.
This value allows you to specify a maximum time to wait, in milliseconds, before hydrating a UI framework component, even if the page is not yet done with its initial load. This means you can delay hydration for lower-priority UI elements with more control to ensure your element is interactive within a specified time frame.
<ShowHideButton client:idle={{ timeout: 500 }} />#11677 cb356a5 Thanks @ematipico! - Adds a new option fallbackType to i18n.routing configuration that allows you to control how fallback pages are handled.
When i18n.fallback is configured, this new routing option controls whether to redirect to the fallback page, or to rewrite the fallback pageโs content in place.
The "redirect" option is the default value and matches the current behavior of the existing fallback system.
The option "rewrite" uses the new rewriting system to create fallback pages that render content on the original, requested URL without a browser refresh.
For example, the following configuration will generate a page /fr/index.html that will contain the same HTML rendered by the page /en/index.html when src/pages/fr/index.astro does not exist.
export default defineConfig({ i18n: { locals: ['en', 'fr'], defaultLocale: 'en', routing: { prefixDefaultLocale: true, fallbackType: 'rewrite', }, fallback: { fr: 'en', }, },});#11708 62b0d20 Thanks @martrapp! - Adds a new object swapFunctions to expose the necessary utility functions on astro:transitions/client that allow you to build custom swap functions to be used with view transitions.
The example below uses these functions to replace Astroโs built-in default swap function with one that only swaps the <main> part of the page:
<script> import { swapFunctions } from 'astro:transitions/client';
document.addEventListener('astro:before-swap', (e) => { e.swap = () => swapMainOnly(e.newDocument) });
function swapMainOnly(doc: Document) { swapFunctions.deselectScripts(doc); swapFunctions.swapRootAttributes(doc); swapFunctions.swapHeadElements(doc); const restoreFocusFunction = swapFunctions.saveFocus(); const newMain = doc.querySelector('main'); const oldMain = document.querySelector('main'); if (newMain && oldMain) { swapFunctions.swapBodyElement(newMain, oldMain); } else { swapFunctions.swapBodyElement(doc.body, document.body); } restoreFocusFunction(); };</script>See the view transitions guide for more information about hooking into the astro:before-swap lifecycle event and adding a custom swap implementation.
#11843 5b4070e Thanks @bholmesdev! - Exposes z from the new astro:schema module. This is the new recommended import source for all Zod utilities when using Astro Actions.
z will no longer be exposed from astro:actions. To use z in your actions, import it from astro:schema instead:
import { defineAction, z,} from 'astro:actions'; import { z } from 'astro:schema';#11843 5b4070e Thanks @bholmesdev! - The Astro Actions API introduced behind a flag in v4.8.0 is no longer experimental and is available for general use.
Astro Actions allow you to define and call backend functions with type-safety, performing data fetching, JSON parsing, and input validation for you.
Actions can be called from client-side components and HTML forms. This gives you to flexibility to build apps using any technology: React, Svelte, HTMX, or just plain Astro components. This example calls a newsletter action and renders the result using an Astro component:
---import { actions } from 'astro:actions';const result = Astro.getActionResult(actions.newsletter);---
{result && !result.error && <p>Thanks for signing up!</p>}<form method="POST" action={actions.newsletter}> <input type="email" name="email" /> <button>Sign up</button></form>If you were previously using this feature, please remove the experimental flag from your Astro config:
import { defineConfig } from 'astro'
export default defineConfig({ experimental: { actions: true, }})If you have been waiting for stabilization before using Actions, you can now do so.
For more information and usage examples, see our brand new Actions guide.
#11677 cb356a5 Thanks @ematipico! - Fixes a bug in the logic of Astro.rewrite() which led to the value for base, if configured, being automatically prepended to the rewrite URL passed. This was unintended behavior and has been corrected, and Astro now processes the URLs exactly as passed.
If you use the rewrite() function on a project that has base configured, you must now prepend the base to your existing rewrite URL:
export default defineConfig({ base: '/blog',});export function onRequest(ctx, next) { return ctx.rewrite("/about") return ctx.rewrite("/blog/about")}#11862 0e35afe Thanks @ascorbic! - BREAKING CHANGE to experimental content layer loaders only!
Passes AstroConfig instead of AstroSettings object to content layer loaders.
This will not affect you unless you have created a loader that uses the settings object. If you have, you will need to update your loader to use the config object instead.
export default function myLoader() { return { name: 'my-loader' async load({ settings }) { const base = settings.config.base; async load({ config }) { const base = config.base; // ... } }}Other properties of the settings object are private internals, and should not be accessed directly. If you think you need access to other properties, please open an issue to discuss your use case.
#11772 6272e6c Thanks @bluwy! - Uses magicast to update the config for astro add
#11845 440a4be Thanks @bluwy! - Replaces execa with tinyexec internally
#11858 8bab233 Thanks @ascorbic! - Correctly resolves content layer images when filePath is not set
#11847 45b599c Thanks @ascorbic! - Fixes a case where Vite would be imported by the SSR runtime, causing bundling errors and bloat.
#11822 6fcaab8 Thanks @bluwy! - Marks internal vite-plugin-fileurl plugin with enforce: 'pre'
#11713 497324c Thanks @voidfill! - Prevents prefetching of the same urls with different hashes.
#11814 2bb72c6 Thanks @eduardocereto! - Updates the documentation for experimental Content Layer API with a corrected code example
#11842 1ffaae0 Thanks @stephan281094! - Fixes a typo in the MissingImageDimension error message
#11828 20d47aa Thanks @bholmesdev! - Improves error message when invalid data is returned by an Action.
#11798 e9e2139 Thanks @matthewp! - Unflag globalRoutePriority
The previously experimental feature globalRoutePriority is now the default in Astro 5.
This was a refactoring of route prioritization in Astro, making it so that injected routes, file-based routes, and redirects are all prioritized using the same logic. This feature has been enabled for all Starlight projects since it was added and should not affect most users.
#11679 ea71b90 Thanks @florian-lefebvre! - The astro:env feature introduced behind a flag in v4.10.0 is no longer experimental and is available for general use. If you have been waiting for stabilization before using astro:env, you can now do so.
This feature lets you configure a type-safe schema for your environment variables, and indicate whether they should be available on the server or the client.
To configure a schema, add the env option to your Astro config and define your client and server variables. If you were previously using this feature, please remove the experimental flag from your Astro config and move your entire env configuration unchanged to a top-level option.
import { defineConfig, envField } from 'astro/config';
export default defineConfig({ env: { schema: { API_URL: envField.string({ context: 'client', access: 'public', optional: true }), PORT: envField.number({ context: 'server', access: 'public', default: 4321 }), API_SECRET: envField.string({ context: 'server', access: 'secret' }), }, },});You can import and use your defined variables from the appropriate /client or /server module:
---import { API_URL } from 'astro:env/client';import { API_SECRET_TOKEN } from 'astro:env/server';
const data = await fetch(`${API_URL}/users`, { method: 'GET', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${API_SECRET_TOKEN}`, },});---
<script> import { API_URL } from 'astro:env/client';
fetch(`${API_URL}/ping`);</script>#11788 7c0ccfc Thanks @ematipico! - Updates the default value of security.checkOrigin to true, which enables Cross-Site Request Forgery (CSRF) protection by default for pages rendered on demand.
If you had previously configured security.checkOrigin: true, you no longer need this set in your Astro config. This is now the default and it is safe to remove.
To disable this behavior and opt out of automatically checking that the โoriginโ header matches the URL sent by each request, you must explicitly set security.checkOrigin: false:
export default defineConfig({ security: { checkOrigin: false }})#11741 6617491 Thanks @bluwy! - Removes internal JSX handling and moves the responsibility to the @astrojs/mdx package directly. The following exports are also now removed:
astro/jsx/babel.jsastro/jsx/component.jsastro/jsx/index.jsastro/jsx/renderer.jsastro/jsx/server.jsastro/jsx/transform-options.jsIf your project includes .mdx files, you must upgrade @astrojs/mdx to the latest version so that it doesnโt rely on these entrypoints to handle your JSX.
#11782 9a2aaa0 Thanks @Princesseuh! - Makes the compiledContent property of Markdown content an async function, this change should fix underlying issues where sometimes when using a custom image service and images inside Markdown, Node would exit suddenly without any error message.
---import * as myPost from "../post.md";
const content = myPost.compiledContent(); const content = await myPost.compiledContent();---
<Fragment set:html={content} />#11770 cfa6a47 Thanks @Princesseuh! - Removed support for the Squoosh image service. As the underlying library libsquoosh is no longer maintained, and the image service sees very little usage we have decided to remove it from Astro.
Our recommendation is to use the base Sharp image service, which is more powerful, faster, and more actively maintained.
import { squooshImageService } from "astro/config";import { defineConfig } from "astro/config";
export default defineConfig({ image: { service: squooshImageService() }});If you are using this service, and cannot migrate to the base Sharp image service, a third-party extraction of the previous service is available here: https://github.com/Princesseuh/astro-image-service-squoosh
#11780 c6622ad Thanks @Princesseuh! - Deprecates the Squoosh image service, to be removed in Astro 5.0. We recommend migrating to the default Sharp service.
#11732 4cd6c43 Thanks @matthewp! - Use GET requests with preloading for Server Islands
Server Island requests include the props used to render the island as well as any slots passed in (excluding the fallback slot). Since browsers have a max 4mb URL length we default to using a POST request to avoid overflowing this length.
However in reality most usage of Server Islands are fairly isolated and wonโt exceed this limit, so a GET request is possible by passing this same information via search parameters.
Using GET means we can also include a <link rel="preload"> tag to speed up the request.
This change implements this, with safe fallback to POST.
#11773 86a3391 Thanks @ematipico! - Changes messages logged when using unsupported, deprecated, or experimental adapter features for clarity
#11774 c6400ab Thanks @florian-lefebvre! - Fixes the path returned by injectTypes
#11771 49650a4 Thanks @florian-lefebvre! - Fixes an error thrown by astro sync when an astro:env virtual module is imported inside the Content Collections config
#11744 b677429 Thanks @bluwy! - Disables the WebSocket server when creating a Vite server for loading config files
#11809 62e97a2 Thanks @bholmesdev! - Fixes usage of .transform(), .refine(), .passthrough(), and other effects on Action form inputs.
#11812 260c4be Thanks @bholmesdev! - Exposes ActionAPIContext type from the astro:actions module.
#11813 3f7630a Thanks @bholmesdev! - Fixes unexpected undefined value when calling an action from the client without a return value.
#11794 3691a62 Thanks @bholmesdev! - Fixes unexpected warning log when using Actions on โhybridโ rendered projects.
#11801 9f943c1 Thanks @delucis! - Fixes a bug where the filePath property was not available on content collection entries when using the content layer file() loader with a JSON file that contained an object instead of an array. This was breaking use of the image() schema utility among other things.
#11780 c6622ad Thanks @Princesseuh! - Deprecates the Squoosh image service, to be removed in Astro 5.0. We recommend migrating to the default Sharp service.
#11790 41c3fcb Thanks @sarah11918! - Updates the documentation for experimental astro:env with a corrected link to the RFC proposal
#11773 86a3391 Thanks @ematipico! - Changes messages logged when using unsupported, deprecated, or experimental adapter features for clarity
#11745 89bab1e Thanks @bluwy! - Prints prerender dynamic value usage warning only if itโs used
#11774 c6400ab Thanks @florian-lefebvre! - Fixes the path returned by injectTypes
#11730 2df49a6 Thanks @florian-lefebvre! - Simplifies path operations of astro sync
#11771 49650a4 Thanks @florian-lefebvre! - Fixes an error thrown by astro sync when an astro:env virtual module is imported inside the Content Collections config
#11744 b677429 Thanks @bluwy! - Disables the WebSocket server when creating a Vite server for loading config files
#10742 b6fbdaa Thanks @ematipico! - The lowest version of Node supported by Astro is now Node v18.17.1 and higher.
#11715 d74617c Thanks @Princesseuh! - Refactor the exported types from the astro module. There should normally be no breaking changes, but if you relied on some previously deprecated types, these might now have been fully removed.
In most cases, updating your code to move away from previously deprecated APIs in previous versions of Astro should be enough to fix any issues.
#11660 e90f559 Thanks @bluwy! - Fixes attribute rendering for non-boolean HTML attributes with boolean values to match proper attribute handling in browsers.
Previously, non-boolean attributes may not have included their values when rendered to HTML. In Astro v5.0, the values are now explicitly rendered as ="true" or ="false"
In the following .astro examples, only allowfullscreen is a boolean attribute:
<!-- src/pages/index.astro --><!-- `allowfullscreen` is a boolean attribute --><p allowfullscreen={true}></p><p allowfullscreen={false}></p>
<!-- `inherit` is *not* a boolean attribute --><p inherit={true}></p><p inherit={false}></p>
<!-- `data-*` attributes are not boolean attributes --><p data-light={true}></p><p data-light={false}></p>Astro v5.0 now preserves the full data attribute with its value when rendering the HTML of non-boolean attributes:
<p allowfullscreen></p><p></p>
<p inherit="true"></p><p inherit></p><p inherit="false"></p>
<p data-light></p><p data-light="true"></p><p></p><p data-light="false"></p>If you rely on attribute values, for example to locate elements or to conditionally render, update your code to match the new non-boolean attribute values:
el.getAttribute('inherit') === ''el.getAttribute('inherit') === 'false'
el.hasAttribute('data-light')el.dataset.light === 'true'#11714 8a53517 Thanks @matthewp! - Remove support for functionPerRoute
This change removes support for the functionPerRoute option both in Astro and @astrojs/vercel.
This option made it so that each route got built as separate entrypoints so that they could be loaded as separate functions. The hope was that by doing this it would decrease the size of each function. However in practice routes use most of the same code, and increases in function size limitations made the potential upsides less important.
Additionally there are downsides to functionPerRoute, such as hitting limits on the number of functions per project. The feature also never worked with some Astro features like i18n domains and request rewriting.
Given this, the feature has been removed from Astro.
#11725 6c1560f Thanks @ascorbic! - Prevents content layer importing node builtins in runtime
#11692 35af73a Thanks @matthewp! - Prevent errant HTML from crashing server islands
When an HTML minifier strips away the server island comment, the script canโt correctly know where the end of the fallback content is. This makes it so that it simply doesnโt remove any DOM in that scenario. This means the fallback isnโt removed, but it also doesnโt crash the browser.
#11727 3c2f93b Thanks @florian-lefebvre! - Fixes a type issue when using the Content Layer in dev
#11657 a23c69d Thanks @bluwy! - Deprecates the option for route-generating files to export a dynamic value for prerender. Only static values are now supported (e.g. export const prerender = true or = false). This allows for better treeshaking and bundling configuration in the future.
Adds a new "astro:route:setup" hook to the Integrations API to allow you to dynamically set options for a route at build or request time through an integration, such as enabling on-demand server rendering.
To migrate from a dynamic export to the new hook, update or remove any dynamic prerender exports from individual routing files:
export const prerender = import.meta.env.PRERENDERInstead, create an integration with the "astro:route:setup" hook and update the routeโs prerender option:
import { defineConfig } from 'astro/config';import { loadEnv } from 'vite';
export default defineConfig({ integrations: [setPrerender()],});
function setPrerender() { const { PRERENDER } = loadEnv(process.env.NODE_ENV, process.cwd(), '');
return { name: 'set-prerender', hooks: { 'astro:route:setup': ({ route }) => { if (route.component.endsWith('/blog/[slug].astro')) { route.prerender = PRERENDER; } }, }, };}#11360 a79a8b0 Thanks @ascorbic! - Adds a new injectTypes() utility to the Integration API and refactors how type generation works
Use injectTypes() in the astro:config:done hook to inject types into your userโs project by adding a new a *.d.ts file.
The filename property will be used to generate a file at /.astro/integrations/<normalized_integration_name>/<normalized_filename>.d.ts and must end with ".d.ts".
The content property will create the body of the file, and must be valid TypeScript.
Additionally, injectTypes() returns a URL to the normalized path so you can overwrite its content later on, or manipulate it in any way you want.
export default { name: 'my-integration', 'astro:config:done': ({ injectTypes }) => { injectTypes({ filename: 'types.d.ts', content: "declare module 'virtual:my-integration' {}", }); },};Codegen has been refactored. Although src/env.d.ts will continue to work as is, we recommend you update it:
/// <reference types="astro/client" />/// <reference path="../.astro/types.d.ts" />/// <reference path="../.astro/env.d.ts" />/// <reference path="../.astro/actions.d.ts" />#11605 d3d99fb Thanks @jcayzac! - Adds a new property meta to Astroโs built-in <Code /> component.
This allows you to provide a value for Shikiโs meta attribute to pass options to transformers.
The following example passes an option to highlight lines 1 and 3 to Shikiโs tranformerMetaHighlight:
---import { Code } from 'astro:components';import { transformerMetaHighlight } from '@shikijs/transformers';---
<Code code={code} lang="js" transformers={[transformerMetaHighlight()]} meta="{1,3}" />#11360 a79a8b0 Thanks @ascorbic! - Adds support for Intellisense features (e.g. code completion, quick hints) for your content collection entries in compatible editors under the experimental.contentIntellisense flag.
import { defineConfig } from 'astro';
export default defineConfig({ experimental: { contentIntellisense: true, },});When enabled, this feature will generate and add JSON schemas to the .astro directory in your project. These files can be used by the Astro language server to provide Intellisense inside content files (.md, .mdx, .mdoc).
Note that at this time, this also require enabling the astro.content-intellisense option in your editor, or passing the contentIntellisense: true initialization parameter to the Astro language server for editors using it directly.
See the experimental content Intellisense docs for more information updates as this feature develops.
#11360 a79a8b0 Thanks @ascorbic! - Adds experimental support for the Content Layer API.
The new Content Layer API builds upon content collections, taking them beyond local files in src/content/ and allowing you to fetch content from anywhere, including remote APIs. These new collections work alongside your existing content collections, and you can migrate them to the new API at your own pace. There are significant improvements to performance with large collections of local files.
To try out the new Content Layer API, enable it in your Astro config:
import { defineConfig } from 'astro';
export default defineConfig({ experimental: { contentLayer: true, },});You can then create collections in your src/content/config.ts using the Content Layer API.
The core of the new Content Layer API is the loader, a function that fetches content from a source and caches it in a local data store. Astro 4.14 ships with built-in glob() and file() loaders to handle your local Markdown, MDX, Markdoc, and JSON files:
import { defineCollection, z } from 'astro:content';import { glob } from 'astro/loaders';
const blog = defineCollection({ // The ID is a slug generated from the path of the file relative to `base` loader: glob({ pattern: '**/*.md', base: './src/data/blog' }), schema: z.object({ title: z.string(), description: z.string(), publishDate: z.coerce.date(), }),});
export const collections = { blog };You can then query using the existing content collections functions, and enjoy a simplified render() function to display your content:
---import { getEntry, render } from 'astro:content';
const post = await getEntry('blog', Astro.params.slug);
const { Content } = await render(entry);---
<Content />Youโre not restricted to the built-in loaders โย we hope youโll try building your own. You can fetch content from anywhere and return an array of entries:
const countries = defineCollection({ loader: async () => { const response = await fetch('https://restcountries.com/v3.1/all'); const data = await response.json(); // Must return an array of entries with an id property, // or an object with IDs as keys and entries as values return data.map((country) => ({ id: country.cca3, ...country, })); }, // optionally add a schema to validate the data and make it type-safe for users // schema: z.object...});
export const collections = { countries };For more advanced loading logic, you can define an object loader. This allows incremental updates and conditional loading, and gives full access to the data store. It also allows a loader to define its own schema, including generating it dynamically based on the source API. See the the Content Layer API RFC for more details.
Loaders are better when theyโre shared. You can create a package that exports a loader and publish it to npm, and then anyone can use it on their site. Weโre excited to see what the community comes up with! To get started, take a look at some examples. Hereโs how to load content using an RSS/Atom feed loader:
import { defineCollection } from 'astro:content';import { feedLoader } from '@ascorbic/feed-loader';
const podcasts = defineCollection({ loader: feedLoader({ url: 'https://feeds.99percentinvisible.org/99percentinvisible', }),});
export const collections = { podcasts };To find out more about using the Content Layer API, check out the Content Layer RFC and share your feedback.
#11716 f4057c1 Thanks @florian-lefebvre! - Fixes content types sync in dev
#11645 849e4c6 Thanks @bluwy! - Refactors internally to use node:util parseArgs instead of yargs-parser
#11712 791d809 Thanks @matthewp! - Fix mixed use of base + trailingSlash in Server Islands
#11709 3d8ae76 Thanks @matthewp! - Fix adapter causing Netlify to break
#11678 34da907 Thanks @ematipico! - Fixes a case where omitting a semicolon and line ending with carriage return - CRLF - in the prerender option could throw an error.
#11535 932bd2e Thanks @matthewp! - Encrypt server island props
Server island props are now encrypted with a key generated at build-time. This is intended to prevent accidentally leaking secrets caused by exposing secrets through prop-passing. This is not intended to allow a server island to be trusted to skip authentication, or to protect against any other vulnerabilities other than secret leakage.
See the RFC for an explanation: https://github.com/withastro/roadmap/blob/server-islands/proposals/server-islands.md#props-serialization
#11655 dc0a297 Thanks @billy-le! - Fixes Astro Actions input validation when using default values with a form input.
#11689 c7bda4c Thanks @ematipico! - Fixes an issue in the Astro actions, where the size of the generated cookie was exceeding the size permitted by the Set-Cookie header.
#11653 32be549 Thanks @florian-lefebvre! - Updates astro:env docs to reflect current developments and usage guidance
#11658 13b912a Thanks @bholmesdev! - Fixes orThrow() type when calling an Action without an input validator.
#11603 f31d466 Thanks @bholmesdev! - Improves user experience when render an Action result from a form POST request:
?_astroAction=NAME flag when a result is rendered.Also improves the DX of directing to a new route on success. Actions will now redirect to the route specified in your action string on success, and redirect back to the previous page on error. This follows the routing convention of established backend frameworks like Laravel.
For example, say you want to redirect to a /success route when actions.signup succeeds. You can add /success to your action string like so:
<form method="POST" action={'/success' + actions.signup}></form>/success.You can retrieve the action result from either page using the Astro.getActionResult() function.
This uses a temporary cookie to forward the action result to the next page. The cookie will be deleted when that page is rendered.
โ The action result is not encrypted. In general, we recommend returning minimal data from an action handler to a) avoid leaking sensitive information, and b) avoid unexpected render issues once the temporary cookie is deleted. For example, a login function may return a userโs session id to retrieve from your Astro frontmatter, rather than the entire user object.
#11648 589d351 Thanks @bholmesdev! - Fixes unexpected error when refreshing a POST request from a form using Actions.
#11600 09ec2ca Thanks @ArmandPhilippot! - Deprecates getEntryBySlug and getDataEntryById functions exported by astro:content in favor of getEntry.
#11593 81d7150 Thanks @bholmesdev! - Adds support for Date(), Map(), and Set() from action results. See devalue for a complete list of supported values.
Also fixes serialization exceptions when deploying Actions with edge middleware on Netlify and Vercel.
#11617 196092a Thanks @abubakriz! - Fix toolbar audit incorrectly flagging images as above the fold.
#11634 2716f52 Thanks @bholmesdev! - Fixes internal server error when calling an Astro Action without arguments on Vercel.
#11628 9aaf58c Thanks @madbook! - Ensures consistent CSS chunk hashes across different environments
#11584 a65ffe3 Thanks @bholmesdev! - Removes async local storage dependency from Astro Actions. This allows Actions to run in Cloudflare and Stackblitz without opt-in flags or other configuration.
This also introduces a new convention for calling actions from server code. Instead of calling actions directly, you must wrap function calls with the new Astro.callAction() utility.
callAction()is meant to trigger an action from server code.getActionResult()usage with form submissions remains unchanged.
---import { actions } from 'astro:actions';
const result = await Astro.callAction(actions.searchPosts, { searchTerm: Astro.url.searchParams.get('search'),});---
{ result.data && { /* render the results */ }}If you call actions directly from server code, update function calls to use the Astro.callAction() wrapper for pages and context.callAction() for endpoints:
---import { actions } from 'astro:actions';
const result = await actions.searchPosts({ searchTerm: 'test' }); const result = await Astro.callAction(actions.searchPosts, { searchTerm: 'test' });---If you deploy with Cloudflare and added the nodejs_compat or nodejs_als flags for Actions, we recommend removing these:
compatibility_flags = [ "nodejs_compat", "nodejs_als"]You can also remove node:async_hooks from the vite.ssr.external option in your astro.config file:
import { defineConfig } from 'astro/config';
export default defineConfig({ vite: { ssr: { external: ["node:async_hooks"] } }})
#11507 a62345f Thanks @ematipico! - Adds color-coding to the console output during the build to highlight slow pages.
Pages that take more than 500 milliseconds to render will have their build time logged in red. This change can help you discover pages of your site that are not performant and may need attention.
#11379 e5e2d3e Thanks @alexanderniebuhr! - The experimental.contentCollectionJsonSchema feature introduced behind a flag in v4.5.0 is no longer experimental and is available for general use.
If you are working with collections of type data, Astro will now auto-generate JSON schema files for your editor to get IntelliSense and type-checking. A separate file will be created for each data collection in your project based on your collections defined in src/content/config.ts using a library called zod-to-json-schema.
This feature requires you to manually set your schemaโs file path as the value for $schema in each data entry file of the collection:
{ "$schema": "../../../.astro/collections/authors.schema.json", "name": "Armand", "skills": ["Astro", "Starlight"]}Alternatively, you can set this value in your editor settings. For example, to set this value in VSCodeโs json.schemas setting, provide the path of files to match and the location of your JSON schema:
{ "json.schemas": [ { "fileMatch": ["/src/content/authors/**"], "url": "./.astro/collections/authors.schema.json" } ]}If you were previously using this feature, please remove the experimental flag from your Astro config:
import { defineConfig } from 'astro'
export default defineConfig({ experimental: { contentCollectionJsonSchema: true }})If you have been waiting for stabilization before using JSON Schema generation for content collections, you can now do so.
Please see the content collections guide for more about this feature.
#11542 45ad326 Thanks @ematipico! - The experimental.rewriting feature introduced behind a flag in v4.8.0 is no longer experimental and is available for general use.
Astro.rewrite() and context.rewrite() allow you to render a different page without changing the URL in the browser. Unlike using a redirect, your visitor is kept on the original page they visited.
Rewrites can be useful for showing the same content at multiple paths (e.g. /products/shoes/men/ and /products/men/shoes/) without needing to maintain two identical source files.
Rewrites are supported in Astro pages, endpoints, and middleware.
Return Astro.rewrite() in the frontmatter of a .astro page component to display a different pageโs content, such as fallback localized content:
---return Astro.rewrite("/es/articles/introduction")---Use context.rewrite() in endpoints, for example to reroute to a different page:
export function GET(context) { if (!context.locals.allowed) { return context.rewrite('/'); }}The middleware next() function now accepts a parameter with the same type as the rewrite() function. For example, with next("/"), you can call the next middleware function with a new Request.
export function onRequest(context, next) { if (!context.cookies.get('allowed')) { return next('/'); // new signature } return next();}If you were previously using this feature, please remove the experimental flag from your Astro config:
export default defineConfig({ experimental: { rewriting: true }})If you have been waiting for stabilization before using rewrites in Astro, you can now do so.
Please see the routing guide in docs for more about using this feature.
#11509 dfbca06 Thanks @bluwy! - Excludes hoisted scripts and styles from Astro components imported with ?url or ?raw
#11561 904f1e5 Thanks @ArmandPhilippot! - Uses the correct pageSize default in page.size JSDoc comment
#11571 1c3265a Thanks @bholmesdev! - BREAKING CHANGE to the experimental Actions API only. Install the latest @astrojs/react integration as well if youโre using React 19 features.
Make .safe() the default return value for actions. This means { data, error } will be returned when calling an action directly. If you prefer to get the data while allowing errors to throw, chain the .orThrow() modifier.
import { actions } from 'astro:actions';
// Beforeconst { data, error } = await actions.like.safe();// Afterconst { data, error } = await actions.like();
// Beforeconst newLikes = await actions.like();// Afterconst newLikes = await actions.like.orThrow();To migrate your existing action calls:
.safe from existing safe action calls.orThrow to existing unsafe action calls#11546 7f26de9 Thanks @ArmandPhilippot! - Remove โSSR Onlyโ mention in Astro.redirect inline documentation and update reference link.
#11525 8068131 Thanks @ematipico! - Fixes a case where the build was failing when experimental.actions was enabled, an adapter was in use, and there were not actions inside the user code base.
#11574 e3f29d4 Thanks @Princesseuh! - Fixes line with the error not being properly highlighted in the error overlay
#11570 84189b6 Thanks @bholmesdev! - BREAKING CHANGE to the experimental Actions API only. Install the latest @astrojs/react integration as well if youโre using React 19 features.
Updates the Astro Actions fallback to support action={actions.name} instead of using getActionProps(). This will submit a form to the server in zero-JS scenarios using a search parameter:
---import { actions } from 'astro:actions';---
<form action={actions.logOut}> <!--output: action="?_astroAction=logOut"--> <button>Log Out</button></form>You may also construct form action URLs using string concatenation, or by using the URL() constructor, with the an actionโs .queryString property:
---import { actions } from 'astro:actions';
const confirmationUrl = new URL('/confirmation', Astro.url);confirmationUrl.search = actions.queryString;---
<form method="POST" action={confirmationUrl.pathname}> <button>Submit</button></form>getActionProps() is now deprecated. To use the new fallback pattern, remove the getActionProps() input from your form and pass your action function to the form action attribute:
---import { actions, getActionProps,} from 'astro:actions';---
<form method="POST" action={actions.logOut}> <form method="POST"> <input {...getActionProps(actions.logOut)} /> <button>Log Out</button></form>#11559 1953dbb Thanks @bryanwood! - Allows actions to return falsy values without an error
#11553 02c85b5 Thanks @ematipico! - Fixes an issue in content collection caching, where two documents with the same contents were generating an error during the build.
#11548 602c5bf Thanks @TheOtterlord! - Fixes astro add for packages with only prerelease versions
#11566 0dcef3a Thanks @Princesseuh! - Fixes DomException errors not being handled properly
#11529 504c383 Thanks @matthewp! - Fix server islands with trailingSlash: always
#11505 8ff7658 Thanks @ematipico! - Enhances the dev server logging when rewrites occur during the lifecycle or rendering.
The dev server will log the status code before and after a rewrite:
08:16:48 [404] (rewrite) /foo/about 200ms08:22:13 [200] (rewrite) /about 23ms#11506 026e8ba Thanks @sarah11918! - Fixes typo in documenting the slot="fallback" attribute for Server Islands experimental feature.
#11508 ca335e1 Thanks @cramforce! - Escapes HTML in serialized props
#11501 4db78ae Thanks @martrapp! - Adds the missing export for accessing the getFallback() function of the client site router.
#11486 9c0c849 Thanks @ematipico! - Adds a new function called addClientRenderer to the Container API.
This function should be used when rendering components using the client:* directives. The addClientRenderer API must be used
after the use of the addServerRenderer:
const container = await experimental_AstroContainer.create();container.addServerRenderer({ renderer });container.addClientRenderer({ name: '@astrojs/react', entrypoint: '@astrojs/react/client.js' });const response = await container.renderToResponse(Component);#11500 4e142d3 Thanks @Princesseuh! - Fixes inferRemoteSize type not working
#11496 53ccd20 Thanks @alfawal! - Hide the dev toolbar on window.print() (CTRL + P)
#11341 49b5145 Thanks @madcampos! - Adds support for Shikiโs defaultColor option.
This option allows you to override the values of a themeโs inline style, adding only CSS variables to give you more flexibility in applying multiple color themes.
Configure defaultColor: false in your Shiki config to apply throughout your site, or pass to Astroโs built-in <Code> component to style an individual code block.
import { defineConfig } from 'astro/config';export default defineConfig({ markdown: { shikiConfig: { themes: { light: 'github-light', dark: 'github-dark', }, defaultColor: false, }, },});---import { Code } from 'astro:components';---
<Code code={`const useMyColors = true`} lang="js" defaultColor={false} />#11304 2e70741 Thanks @Fryuni! - Refactors the type for integration hooks so that integration authors writing custom integration hooks can now allow runtime interactions between their integration and other integrations.
This internal change should not break existing code for integration authors.
To declare your own hooks for your integration, extend the Astro.IntegrationHooks interface:
declare global { namespace Astro { interface IntegrationHooks { 'myLib:eventHappened': (your: string, parameters: number) => Promise<void>; } }}Call your hooks on all other integrations installed in a project at the appropriate time. For example, you can call your hook on initialization before either the Vite or Astro config have resolved:
import './types.ts';
export default (): AstroIntegration => { return { name: 'your-integration', hooks: { 'astro:config:setup': async ({ config }) => { for (const integration of config.integrations) { await integration.hooks['myLib:eventHappened'].?('your values', 123); } }, } }}Other integrations can also now declare your hooks:
import 'your-integration/types.ts';
export default (): AstroIntegration => { return { name: 'other-integration', hooks: { 'myLib:eventHappened': async (your, values) => { // ... }, }, };};#11305 d495df5 Thanks @matthewp! - Experimental Server Islands
Server Islands allow you to specify components that should run on the server, allowing the rest of the page to be more aggressively cached, or even generated statically. Turn any .astro component into a server island by adding the server:defer directive and optionally, fallback placeholder content:
---import Avatar from '../components/Avatar.astro';import GenericUser from '../components/GenericUser.astro';---
<header> <h1>Page Title</h1> <div class="header-right"> <Avatar server:defer> <GenericUser slot="fallback" /> </Avatar> </div></header>The server:defer directive can be used on any Astro component in a project using hybrid or server mode with an adapter. There are no special APIs needed inside of the island.
Enable server islands by adding the experimental flag to your Astro config with an appropriate output mode and adatper:
import { defineConfig } from 'astro/config';import netlify from '@astrojs/netlify';
export default defineConfig({ output: 'hybrid', adapter: netlify(), experimental { serverIslands: true, },});For more information, see the server islands documentation.
#11482 7c9ed71 Thanks @Princesseuh! - Adds a --noSync parameter to the astro check command to skip the type-gen step. This can be useful when running astro check inside packages that have Astro components, but are not Astro projects
#11098 36e30a3 Thanks @itsmatteomanf! - Adds a new inferRemoteSize() function that can be used to infer the dimensions of a remote image.
Previously, the ability to infer these values was only available by adding the [inferSize] attribute to the <Image> and <Picture> components or getImage(). Now, you can also access this data outside of these components.
This is useful for when you need to know the dimensions of an image for styling purposes or to calculate different densities for responsive images.
---import { inferRemoteSize, Image } from 'astro:assets';
const imageUrl = 'https://...';const { width, height } = await inferRemoteSize(imageUrl);---
<Image src={imageUrl} width={width / 2} height={height} densities={[1.5, 2]} />#11391 6f9b527 Thanks @ARipeAppleByYoursTruly! - Adds Shikiโs defaultColor option to the <Code /> component, giving you more control in applying multiple themes
#11176 a751458 Thanks @tsawada! - Adds two new values to the pagination page prop: page.first and page.last for accessing the URLs of the first and last pages.
#11477 7e9c4a1 Thanks @ematipico! - Fixes an issue where the development server was emitting a 404 status code when the user uses a rewrite that emits a 200 status code.
#11479 ca969d5 Thanks @florian-lefebvre! - Fixes a case where invalid astro:env variables at runtime would not throw correctly
#11489 061f1f4 Thanks @ematipico! - Move root inside the manifest and make serialisable
#11415 e9334d0 Thanks @florian-lefebvre! - Refactors how sync works and when itโs called. Fixes an issue with astro:env types in dev not being generated
#11478 3161b67 Thanks @bluwy! - Supports importing Astro components with Vite queries, like ?url, ?raw, and ?direct
#11491 fe3afeb Thanks @matthewp! - Fix for Server Islands in Vercel adapter
Vercel, and probably other adapters only allow pre-defined routes. This makes it so that the astro:build:done hook includes the _server-islands/ route as part of the route data, which is used to configure available routes.
#11483 34f9c25 Thanks @Princesseuh! - Fixes Astro not working on low versions of Node 18 and 20
Updated dependencies [49b5145]:
#11459 bc2e74d Thanks @mingjunlu! - Fixes false positive audit warnings on elements with the role โtabpanelโ.
#11472 cb4e6d0 Thanks @delucis! - Avoids targeting all files in the src/ directory for eager optimization by Vite. After this change, only JSX, Vue, Svelte, and Astro components get scanned for early optimization.
#11387 b498461 Thanks @bluwy! - Fixes prerendering not removing unused dynamic imported chunks
#11437 6ccb30e Thanks @NuroDev! - Fixes a case where Astroโs config experimental.env.schema keys did not allow numbers. Numbers are still not allowed as the first character to be able to generate valid JavaScript identifiers
#11439 08baf56 Thanks @bholmesdev! - Expands the isInputError() utility from astro:actions to accept errors of any type. This should now allow type narrowing from a try / catch block.
import { actions, isInputError } from 'astro:actions';
try { await actions.like(new FormData());} catch (error) { if (isInputError(error)) { console.log(error.fields); }}#11452 0e66849 Thanks @FugiTech! - Fixes an issue where using .nullish() in a formdata Astro action would always parse as a string
#11438 619f07d Thanks @bholmesdev! - Exposes utility types from astro:actions for the defineAction handler (ActionHandler) and the ActionError code (ActionErrorCode).
#11456 17e048d Thanks @RickyC0626! - Fixes astro dev --open unexpected behavior that spawns a new tab every time a config file is saved
#11337 0a4b31f Thanks @florian-lefebvre! - Adds a new property experimental.env.validateSecrets to allow validating private variables on the server.
By default, this is set to false and only public variables are checked on start. If enabled, secrets will also be checked on start (dev/build modes). This is useful for example in some CIs to make sure all your secrets are correctly set before deploying.
import { defineConfig, envField } from 'astro/config';
export default defineConfig({ experimental: { env: { schema: { // ... }, validateSecrets: true, }, },});#11443 ea4bc04 Thanks @bholmesdev! - Expose new ActionReturnType utility from astro:actions. This infers the return type of an action by passing typeof actions.name as a type argument. This example defines a like action that returns likes as an object:
import { defineAction } from 'astro:actions';
export const server = { like: defineAction({ handler: () => { /* ... */ return { likes: 42 }; }, }),};In your client code, you can infer this handler return value with ActionReturnType:
import { actions, ActionReturnType } from 'astro:actions';
type LikesResult = ActionReturnType<typeof actions.like>;// -> { likes: number }#11436 7dca68f Thanks @bholmesdev! - Fixes astro:actions autocompletion for the defineAction accept property
#11455 645e128 Thanks @florian-lefebvre! - Improves astro:env invalid variables errors
#11362 93993b7 Thanks @ematipico! - Fixes an issue where creating manually the i18n middleware could break the logic of the functions of the virtual module astro:i18n
#11349 98d9ce4 Thanks @ematipico! - Fixes an issue where Astro didnโt throw an error when Astro.rewrite was used without providing the experimental flag
#11352 a55ee02 Thanks @ematipico! - Fixes an issue where the rewrites didnโt update the status code when using manual i18n routing.
#11388 3a223b4 Thanks @mingjunlu! - Adjusts the color of punctuations in error overlay.
#11369 e6de11f Thanks @bluwy! - Fixes attribute rendering for non-boolean attributes with boolean values
#11335 4c4741b Thanks @ematipico! - Reverts #11292, which caused a regression to the input type
#11326 41121fb Thanks @florian-lefebvre! - Fixes a case where running astro sync when using the experimental astro:env feature would fail if environment variables were missing
#11338 9752a0b Thanks @zaaakher! - Fixes svg icon margin in devtool tooltip title to look coherent in rtl and ltr layouts
#11331 f1b78a4 Thanks @bluwy! - Removes resolve package and simplify internal resolve check
#11339 8fdbf0e Thanks @matthewp! - Remove non-fatal errors from telemetry
Previously we tracked non-fatal errors in telemetry to get a good idea of the types of errors that occur in astro dev. However this has become noisy over time and results in a lot of data that isnโt particularly useful. This removes those non-fatal errors from being tracked.
#11308 44c61dd Thanks @ematipico! - Fixes an issue where custom 404.astro and 500.astro were not returning the correct status code when rendered inside a rewriting cycle.
#11302 0622567 Thanks @martrapp! - Fixes an issue with the view transition router when redirecting to an URL with different origin.
Updated dependencies [b6afe6a, 41064ce]:
#11197 4b46bd9 Thanks @braebo! - Adds ShikiTransformer support to the <Code /> component with a new transformers prop.
Note that transformers only applies classes and you must provide your own CSS rules to target the elements of your code block.
---import { transformerNotationFocus } from '@shikijs/transformers';import { Code } from 'astro:components';
const code = `const foo = 'hello'const bar = ' world'console.log(foo + bar) // [!code focus]`;---
<Code {code} lang="js" transformers={[transformerNotationFocus()]} />
<style is:global> pre.has-focused .line:not(.focused) { filter: blur(1px); }</style>#11134 9042be0 Thanks @florian-lefebvre! - Improves the developer experience of the 500.astro file by passing it a new error prop.
When an error is thrown, the special src/pages/500.astro page now automatically receives the error as a prop. This allows you to display more specific information about the error on a custom 500 page.
---interface Props { error: unknown;}
const { error } = Astro.props;---
<div>{error instanceof Error ? error.message : 'Unknown error'}</div>If an error occurs rendering this page, your hostโs default 500 error page will be shown to your visitor in production, and Astroโs default error overlay will be shown in development.
#11280 fd3645f Thanks @ascorbic! - Fixes a bug that prevented cookies from being set when using experimental rewrites
#11275 bab700d Thanks @syhily! - Drop duplicated brackets in data collections schema generation.
#11272 ea987d7 Thanks @ematipico! - Fixes a case where rewriting / would cause an issue, when trailingSlash was set to "never".
#11272 ea987d7 Thanks @ematipico! - Reverts a logic where it wasnโt possible to rewrite /404 in static mode. Itโs now possible again
#11264 5a9c9a6 Thanks @Fryuni! - Fixes type generation for empty content collections
#11279 9a08d74 Thanks @ascorbic! - Improves type-checking and error handling to catch case where an image import is passed directly to getImage()
#11292 7f8f347 Thanks @jdtjenkins! - Fixes a case where defineAction autocomplete for the accept prop would not show "form" as a possible value
#11273 cb4d078 Thanks @ascorbic! - Corrects an inconsistency in dev where middleware would run for prerendered 404 routes.
Middleware is not run for prerendered 404 routes in production, so this was incorrect.
#11284 f4b029b Thanks @ascorbic! - Fixes an issue that would break Astro.request.url and Astro.request.headers in astro dev if HTTP/2 was enabled.
HTTP/2 is now enabled by default in astro dev if https is configured in the Vite config.
#11213 94ac7ef Thanks @florian-lefebvre! - Removes the PUBLIC_ prefix constraint for astro:env public variables
#11213 94ac7ef Thanks @florian-lefebvre! - BREAKING CHANGE to the experimental astro:env feature only
Server secrets specified in the schema must now be imported from astro:env/server. Using getSecret() is no longer required to use these environment variables in your schema:
import { getSecret } from 'astro:env/server'const API_SECRET = getSecret("API_SECRET")import { API_SECRET } from 'astro:env/server'Note that using getSecret() with these keys is still possible, but no longer involves any special handling and the raw value will be returned, just like retrieving secrets not specified in your schema.
#11234 4385bf7 Thanks @ematipico! - Adds a new function called addServerRenderer to the Container API. Use this function to manually store renderers inside the instance of your container.
This new function should be preferred when using the Container API in environments like on-demand pages:
import type { APIRoute } from 'astro';import { experimental_AstroContainer } from 'astro/container';import reactRenderer from '@astrojs/react/server.js';import vueRenderer from '@astrojs/vue/server.js';import ReactComponent from '../components/button.jsx';import VueComponent from '../components/button.vue';
// MDX runtime is contained inside the Astro coreimport mdxRenderer from 'astro/jsx/server.js';
// In case you need to import a custom rendererimport customRenderer from '../renderers/customRenderer.js';
export const GET: APIRoute = async (ctx) => { const container = await experimental_AstroContainer.create(); container.addServerRenderer({ renderer: reactRenderer }); container.addServerRenderer({ renderer: vueRenderer }); container.addServerRenderer({ renderer: customRenderer }); // You can pass a custom name too container.addServerRenderer({ name: 'customRenderer', renderer: customRenderer, }); const vueComponent = await container.renderToString(VueComponent); return await container.renderToResponse(Component);};#11249 de60c69 Thanks @markgaze! - Fixes a performance issue with JSON schema generation
#11242 e4fc2a0 Thanks @ematipico! - Fixes a case where the virtual module astro:container wasnโt resolved
#11236 39bc3a5 Thanks @ascorbic! - Fixes a case where symlinked content collection directories were not correctly resolved
#11258 d996db6 Thanks @ascorbic! - Adds a new error RewriteWithBodyUsed that throws when Astro.rewrite is used after the request body has already been read.
#11243 ba2b14c Thanks @V3RON! - Fixes a prerendering issue for libraries in node_modules when a folder with an underscore is in the path.
#11244 d07d2f7 Thanks @ematipico! - Improves the developer experience of the custom 500.astro page in development mode.
Before, in development, an error thrown during the rendering phase would display the default error overlay, even when users had the 500.astro page.
Now, the development server will display the 500.astro and the original error is logged in the console.
#11240 2851b0a Thanks @ascorbic! - Ignores query strings in module identifiers when matching โ.astroโ file extensions in Vite plugin
#11245 e22be22 Thanks @bluwy! - Refactors prerendering chunk handling to correctly remove unused code during the SSR runtime
#11231 58d7dbb Thanks @ematipico! - Fixes a regression for getViteConfig, where the inline config wasnโt merged in the final config.
#11228 1e293a1 Thanks @ascorbic! - Updates getCollection() to always return a cloned array
#11207 7d9aac3 Thanks @ematipico! - Fixes an issue in the rewriting logic where old data was not purged during the rewrite flow. This caused some false positives when checking the validity of URL path names during the rendering phase.
#11189 75a8fe7 Thanks @ematipico! - Improve error message when using getLocaleByPath on path that doesnโt contain any locales.
#11195 0a6ab6f Thanks @florian-lefebvre! - Adds support for enums to astro:env
You can now call envField.enum:
import { defineConfig, envField } from 'astro/config';
export default defineConfig({ experimental: { env: { schema: { API_VERSION: envField.enum({ context: 'server', access: 'secret', values: ['v1', 'v2'], }), }, }, },});#11210 66fc028 Thanks @matthewp! - Close the iterator only after rendering is complete
#11195 0a6ab6f Thanks @florian-lefebvre! - Adds additional validation options to astro:env
astro:env schema datatypes string and number now have new optional validation rules:
import { defineConfig, envField } from 'astro/config';
export default defineConfig({ experimental: { env: { schema: { FOO: envField.string({ // ... max: 32, min: 3, length: 12, url: true, includes: 'foo', startsWith: 'bar', endsWith: 'baz', }), BAR: envField.number({ // ... gt: 2, min: 3, lt: 10, max: 9, int: true, }), }, }, },});#11211 97724da Thanks @matthewp! - Let middleware handle the original request URL
#10607 7327c6a Thanks @frankbits! - Fixes an issue where a leading slash created incorrect conflict resolution between pages generated from static routes and catch-all dynamic routes
#11198 8b9a499 Thanks @florian-lefebvre! - Fixes a case where astro:env getSecret would not retrieve environment variables properly in dev and build modes
#11206 734b98f Thanks @florian-lefebvre! - BREAKING CHANGE to the experimental astro:env feature only
Updates the adapter astro:env entrypoint from astro:env/setup to astro/env/setup
#11205 8c45391 Thanks @Nin3lee! - Fixes a typo in the config reference
#10974 2668ef9 Thanks @florian-lefebvre! - Adds experimental support for the astro:env API.
The astro:env API lets you configure a type-safe schema for your environment variables, and indicate whether they should be available on the server or the client. Import and use your defined variables from the appropriate /client or /server module:
---import { PUBLIC_APP_ID } from 'astro:env/client';import { PUBLIC_API_URL, getSecret } from 'astro:env/server';const API_TOKEN = getSecret('API_TOKEN');
const data = await fetch(`${PUBLIC_API_URL}/users`, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${API_TOKEN}`, }, body: JSON.stringify({ appId: PUBLIC_APP_ID }),});---To define the data type and properties of your environment variables, declare a schema in your Astro config in experimental.env.schema. The envField helper allows you define your variable as a string, number, or boolean and pass properties in an object:
import { defineConfig, envField } from 'astro/config';
export default defineConfig({ experimental: { env: { schema: { PUBLIC_API_URL: envField.string({ context: 'client', access: 'public', optional: true }), PUBLIC_PORT: envField.number({ context: 'server', access: 'public', default: 4321 }), API_SECRET: envField.string({ context: 'server', access: 'secret' }), }, }, },});There are three kinds of environment variables, determined by the combination of context (client or server) and access (private or public) settings defined in your env.schema:
Public client variables: These variables end up in both your final client and server bundles, and can be accessed from both client and server through the astro:env/client module:
import { PUBLIC_API_URL } from 'astro:env/client';Public server variables: These variables end up in your final server bundle and can be accessed on the server through the astro:env/server module:
import { PUBLIC_PORT } from 'astro:env/server';Secret server variables: These variables are not part of your final bundle and can be accessed on the server through the getSecret() helper function available from the astro:env/server module:
import { getSecret } from 'astro:env/server';
const API_SECRET = getSecret('API_SECRET'); // typedconst SECRET_NOT_IN_SCHEMA = getSecret('SECRET_NOT_IN_SCHEMA'); // string | undefinedNote: Secret client variables are not supported because there is no safe way to send this data to the client. Therefore, it is not possible to configure both context: "client" and access: "secret" in your schema.
To learn more, check out the documentation.
#11192 58b10a0 Thanks @liruifengv! - Improves DX by throwing the original AstroUserError when an error is thrown inside a .mdx file.
#11136 35ef53c Thanks @ematipico! - Errors that are emitted during a rewrite are now bubbled up and shown to the user. A 404 response is not returned anymore.
#11144 803dd80 Thanks @ematipico! - The integration now exposes a function called getContainerRenderer, that can be used inside the Container APIs to load the relative renderer.
import { experimental_AstroContainer as AstroContainer } from 'astro/container';import ReactWrapper from '../src/components/ReactWrapper.astro';import { loadRenderers } from 'astro:container';import { getContainerRenderer } from '@astrojs/react';
test('ReactWrapper with react renderer', async () => { const renderers = await loadRenderers([getContainerRenderer()]); const container = await AstroContainer.create({ renderers, }); const result = await container.renderToString(ReactWrapper);
expect(result).toContain('Counter'); expect(result).toContain('Count: <!-- -->5');});#11144 803dd80 Thanks @ematipico! - BREAKING CHANGE to the experimental Container API only
Changes the type of the renderers option of the AstroContainer::create function and adds a dedicated function loadRenderers() to load the rendering scripts from renderer integration packages (@astrojs/react, @astrojs/preact, @astrojs/solid-js, @astrojs/svelte, @astrojs/vue, @astrojs/lit, and @astrojs/mdx).
You no longer need to know the individual, direct file paths to the client and server rendering scripts for each renderer integration package. Now, there is a dedicated function to load the renderer from each package, which is available from getContainerRenderer():
import { experimental_AstroContainer as AstroContainer } from 'astro/container';import ReactWrapper from '../src/components/ReactWrapper.astro';import { loadRenderers } from "astro:container";import { getContainerRenderer } from "@astrojs/react";
test('ReactWrapper with react renderer', async () => { const renderers = await loadRenderers([getContainerRenderer()]) const renderers = [ { name: '@astrojs/react', clientEntrypoint: '@astrojs/react/client.js', serverEntrypoint: '@astrojs/react/server.js', }, ]; const container = await AstroContainer.create({ renderers, }); const result = await container.renderToString(ReactWrapper);
expect(result).toContain('Counter'); expect(result).toContain('Count: <!-- -->5');});The new loadRenderers() helper function is available from astro:container, a virtual module that can be used when running the Astro container inside vite.
#11136 35ef53c Thanks @ematipico! - Itโs not possible anymore to use Astro.rewrite("/404") inside static pages. This isnโt counterproductive because Astro will end-up emitting a page that contains the HTML of 404 error page.
Itโs still possible to use Astro.rewrite("/404") inside on-demand pages, or pages that opt-out from prerendering.
#11191 6e29a17 Thanks @matthewp! - Fixes a case where Astro.url would be incorrect when having build.format set to 'preserve' in the Astro config
#11182 40b0b4d Thanks @ematipico! - Fixes an issue where Astro.rewrite wasnโt carrying over the body of a Request in on-demand pages.
#11194 97fbe93 Thanks @ematipico! - Fixes an issue where the function getViteConfig wasnโt returning the correct merged Astro configuration
#11171 ff8004f Thanks @Princesseuh! - Guard globalThis.astroAsset usage in proxy code to avoid errors in wonky situations
#11178 1734c49 Thanks @theoephraim! - Improves isPromise utility to check the presence of then on an object before trying to access it - which can cause undesired side-effects on Proxy objects
#11183 3cfa2ac Thanks @66Leo66! - Suggest pnpm dlx instead of pnpx in update check.
#11147 2d93902 Thanks @kitschpatrol! - Fixes invalid MIME types in Picture source elements for jpg and svg extensions, which was preventing otherwise valid source variations from being shown by the browser
#11141 19df89f Thanks @ematipico! - Fixes an internal error that prevented the AstroContainer to render the Content component.
You can now write code similar to the following to render content collections:
const entry = await getEntry(collection, slug);const { Content } = await entry.render();const content = await container.renderToString(Content);#11170 ba20c71 Thanks @matthewp! - Retain client scripts in content cache
#11138 98e0372 Thanks @ematipico! - You can now pass props when rendering a component using the Container APIs:
import { experimental_AstroContainer as AstroContainer } from 'astro/contaienr';import Card from '../src/components/Card.astro';
const container = await AstroContainer.create();const result = await container.renderToString(Card, { props: { someState: true, },});
#11051 12a1bcc Thanks @ematipico! - Introduces an experimental Container API to render .astro components in isolation.
This API introduces three new functions to allow you to create a new container and render an Astro component returning either a string or a Response:
create(): creates a new instance of the container.renderToString(): renders a component and return a string.renderToResponse(): renders a component and returns the Response emitted by the rendering phase.The first supported use of this new API is to enable unit testing. For example, with vitest, you can create a container to render your component with test data and check the result:
import { experimental_AstroContainer as AstroContainer } from 'astro/container';import { expect, test } from 'vitest';import Card from '../src/components/Card.astro';
test('Card with slots', async () => { const container = await AstroContainer.create(); const result = await container.renderToString(Card, { slots: { default: 'Card content', }, });
expect(result).toContain('This is a card'); expect(result).toContain('Card content');});For a complete reference, see the Container API docs.
For a feature overview, and to give feedback on this experimental API, see the Container API roadmap discussion.
#11021 2d4c8fa Thanks @ematipico! - The CSRF protection feature that was introduced behind a flag in v4.6.0 is no longer experimental and is available for general use.
To enable the stable version, add the new top-level security option in astro.config.mjs. If you were previously using the experimental version of this feature, also delete the experimental flag:
export default defineConfig({ experimental: { security: { csrfProtection: { origin: true } } }, security: { checkOrigin: true }})Enabling this setting performs a check that the "origin" header, automatically passed by all modern browsers, matches the URL sent by each Request.
This check is executed only for pages rendered on demand, and only for the requests POST, PATCH, DELETE and PUT with one of the following "content-type" headers: 'application/x-www-form-urlencoded', 'multipart/form-data', 'text/plain'.
If the "origin" header doesnโt match the pathname of the request, Astro will return a 403 status code and wonโt render the page.
For more information, see the security configuration docs.
#11022 be68ab4 Thanks @ematipico! - The i18nDomains routing feature introduced behind a flag in v3.4.0 is no longer experimental and is available for general use.
This routing option allows you to configure different domains for individual locales in entirely server-rendered projects using the @astrojs/node or @astrojs/vercel adapter with a site configured.
If you were using this feature, please remove the experimental flag from your Astro config:
import { defineConfig } from 'astro'
export default defineConfig({ experimental: { i18nDomains: true, }})If you have been waiting for stabilization before using this routing option, you can now do so.
Please see the internationalization docs for more about this feature.
#11071 8ca7c73 Thanks @bholmesdev! - Adds two new functions experimental_getActionState() and experimental_withState() to support the React 19 useActionState() hook when using Astro Actions. This introduces progressive enhancement when calling an Action with the withState() utility.
This example calls a like action that accepts a postId and returns the number of likes. Pass this action to the experimental_withState() function to apply progressive enhancement info, and apply to useActionState() to track the result:
import { actions } from 'astro:actions';import { experimental_withState } from '@astrojs/react/actions';
export function Like({ postId }: { postId: string }) { const [state, action, pending] = useActionState( experimental_withState(actions.like), 0 // initial likes );
return ( <form action={action}> <input type="hidden" name="postId" value={postId} /> <button disabled={pending}>{state} โค๏ธ</button> </form> );}You can also access the state stored by useActionState() from your action handler. Call experimental_getActionState() with the API context, and optionally apply a type to the result:
import { defineAction, z } from 'astro:actions';import { experimental_getActionState } from '@astrojs/react/actions';
export const server = { like: defineAction({ input: z.object({ postId: z.string(), }), handler: async ({ postId }, ctx) => { const currentLikes = experimental_getActionState<number>(ctx); // write to database return currentLikes + 1; }, }),};#11101 a6916e4 Thanks @linguofeng! - Updates Astroโs code for adapters to use the header x-forwarded-for to initialize the clientAddress.
To take advantage of the new change, integration authors must upgrade the version of Astro in their adapter peerDependencies to 4.9.0.
#11071 8ca7c73 Thanks @bholmesdev! - Adds compatibility for Astro Actions in the React 19 beta. Actions can be passed to a form action prop directly, and Astro will automatically add metadata for progressive enhancement.
import { actions } from 'astro:actions';
function Like() { return ( <form action={actions.like}> {/* auto-inserts hidden input for progressive enhancement */} <button type="submit">Like</button> </form> );}#11088 9566fa0 Thanks @bholmesdev! - Allow actions to be called on the server. This allows you to call actions as utility functions in your Astro frontmatter, endpoints, and server-side UI components.
Import and call directly from astro:actions as you would for client actions:
---import { actions } from 'astro:actions';
await actions.like({ postId: Astro.params.postId });---#11112 29a8650 Thanks @bholmesdev! - Deprecate the getApiContext() function. API Context can now be accessed from the second parameter to your Action handler():
import { defineAction, z, getApiContext,} from 'astro:actions';
export const server = { login: defineAction({ input: z.object({ id: z.string }), handler(input, context) { const user = context.locals.auth(input.id); return user; } }),}#11073 f5c8fee Thanks @matthewp! - Prevent cache content from being left in dist folder
When contentCollectionsCache is enabled temporary cached content is copied into the outDir for processing. This fixes it so that this content is cleaned out, along with the rest of the temporary build JS.
#11054 f6b171e Thanks @bholmesdev! - Respect error status when handling Actions with a progressive fallback.
#11092 bfe9c73 Thanks @duckycoding-dev! - Change slot attribute of IntrinsicAttributes to match the definition of HTMLAttributesโs own slot attribute of type string | undefined | null
#10875 b5f95b2 Thanks @W1M0R! - Fixes a typo in a JSDoc annotation
#11111 a5d79dd Thanks @bholmesdev! - Fix unexpected headers warning on prerendered routes when using Astro Actions.
#11081 af42e05 Thanks @V3RON! - Correctly position inspection tooltip in RTL mode
When RTL mode is turned on, the inspection tooltip tend to overflow the window on the left side. Additional check has been added to prevent that.
#11065 1f988ed Thanks @ematipico! - Fixes a bug in the Astro rewrite logic, where rewriting the index with parameters - next("/?foo=bar") - didnโt work as expected.
#10924 3a0c02a Thanks @Its-Just-Nans! - Handle image-size errors by displaying a clearer message
#11058 749a7ac Thanks @matthewp! - Fix streaming in Node.js fast path
#11052 a05ca38 Thanks @florian-lefebvre! - Fixes a case where rewriting would conflict with the actions internal middleware
#11062 16f12e4 Thanks @ematipico! - Fixes a bug where astro build didnโt create custom 404.html and 500.html when a certain combination of i18n options was applied
#10965 a8f0372 Thanks @Elias-Chairi! - Update generator.ts to allow %23 (#) in dynamic urls
#11069 240a70a Thanks @ematipico! - Improves debug logging for on-demand pages
#11026 8dfb1a2 Thanks @bluwy! - Skips rendering script tags if itโs inlined and empty when experimental.directRenderScript is enabled
#11043 d0d1710 Thanks @bholmesdev! - Fixes minor type issues in actions component example
#10999 5f353e3 Thanks @bluwy! - The prefetch feature is updated to better support different browsers and different cache headers setup, including:
<link rel="prefetch"> if supported, or will fall back to fetch().prefetch() programmatic APIโs with option is deprecated in favour of an automatic approach that will also try to use <link rel="prefetch> if supported, or will fall back to fetch().This change shouldnโt affect most sites and should instead make prefetching more effective.
#11041 6cc3fb9 Thanks @bholmesdev! - Fixes 500 errors when sending empty params or returning an empty response from an action.
#11028 771d1f7 Thanks @bholmesdev! - Throw on missing server output when using Astro Actions.
#11029 bd34452 Thanks @bholmesdev! - Actions: include validation error in thrown error message for debugging.
#11046 086694a Thanks @HiDeoo! - Fixes getViteConfig() type definition to allow passing an inline Astro configuration as second argument
#11026 8dfb1a2 Thanks @bluwy! - Fixes CSS handling if imported in a script tag in an Astro file when experimental.directRenderScript is enabled
#11020 2e2d6b7 Thanks @xsynaptic! - Add type declarations for import.meta.env.ASSETS_PREFIX when defined as an object for handling different file types.
#11030 18e7f33 Thanks @bholmesdev! - Actions: Fix missing message for custom Action errors.
#10981 ad9227c Thanks @mo! - Adds deprecated HTML attribute โnameโ to the list of valid attributes. This attribute has been replaced by the global id attribute in recent versions of HTML.
#11013 4ea38e7 Thanks @QingXia-Ela! - Prevents unhandledrejection error when checking for latest Astro version
#11034 5f2dd45 Thanks @arganaphang! - Add popovertargetaction to the attribute that can be passed to the button and input element
7418bb0 Thanks @bholmesdev! - Fix locals access from action handlers#10990 4161a2a Thanks @liruifengv! - fix incorrect actions path on windows
#10979 6fa89e8 Thanks @BryceRussell! - Fix loading of non-index routes that end with index.html
#10987 05db5f7 Thanks @ematipico! - Fix a regression where the flag experimental.rewriting was marked mandatory. Is is now optional.
#10975 6b640b3 Thanks @bluwy! - Passes the scoped style attribute or class to the <picture> element in the <Picture /> component so scoped styling can be applied to the <picture> element
#10935 ddd8e49 Thanks @bluwy! - Exports astro/jsx/rehype.js with utilities to generate an Astro metadata object
#10625 698c2d9 Thanks @goulvenclech! - Adds the ability for multiple pages to use the same component as an entrypoint when building an Astro integration. This change is purely internal, and aligns the build process with the behaviour in the development server.
#10906 7bbd664 Thanks @Princesseuh! - Adds a new radio checkbox component to the dev toolbar UI library (astro-dev-toolbar-radio-checkbox)
#10963 61f47a6 Thanks @delucis! - Adds support for passing an inline Astro configuration object to getViteConfig()
If you are using getViteConfig() to configure the Vitest test runner, you can now pass a second argument to control how Astro is configured. This makes it possible to configure unit tests with different Astro options when using Vitestโs workspaces feature.
import { getViteConfig } from 'astro/config';
export default getViteConfig( /* Vite configuration */ { test: {} }, /* Astro configuration */ { site: 'https://example.com', trailingSlash: 'never', });#10867 47877a7 Thanks @ematipico! - Adds experimental rewriting in Astro with a new rewrite() function and the middleware next() function.
The feature is available via an experimental flag in astro.config.mjs:
export default defineConfig({ experimental: { rewriting: true, },});When enabled, you can use rewrite() to render another page without changing the URL of the browser in Astro pages and endpoints.
---if (!Astro.props.allowed) { return Astro.rewrite('/');}---export function GET(ctx) { if (!ctx.locals.allowed) { return ctx.rewrite('/'); }}The middleware next() function now accepts a parameter with the same type as the rewrite() function. For example, with next("/"), you can call the next middleware function with a new Request.
export function onRequest(ctx, next) { if (!ctx.cookies.get('allowed')) { return next('/'); // new signature } return next();}NOTE: please read the RFC to understand the current expectations of the new APIs.
#10858 c0c509b Thanks @bholmesdev! - Adds experimental support for the Actions API. Actions let you define type-safe endpoints you can query from client components with progressive enhancement built in.
Actions help you write type-safe backend functions you can call from anywhere. Enable server rendering using the output property and add the actions flag to the experimental object:
{ output: 'hybrid', // or 'server' experimental: { actions: true, },}Declare all your actions in src/actions/index.ts. This file is the global actions handler.
Define an action using the defineAction() utility from the astro:actions module. These accept the handler property to define your server-side request handler. If your action accepts arguments, apply the input property to validate parameters with Zod.
This example defines two actions: like and comment. The like action accepts a JSON object with a postId string, while the comment action accepts FormData with postId, author, and body strings. Each handler updates your database and return a type-safe response.
import { defineAction, z } from 'astro:actions';
export const server = { like: defineAction({ input: z.object({ postId: z.string() }), handler: async ({ postId }, context) => { // update likes in db
return likes; }, }), comment: defineAction({ accept: 'form', input: z.object({ postId: z.string(),
body: z.string(), }), handler: async ({ postId }, context) => { // insert comments in db
return comment; }, }),};Then, call an action from your client components using the actions object from astro:actions. You can pass a type-safe object when using JSON, or a FormData object when using accept: 'form' in your action definition:
import { actions } from 'astro:actions';import { useState } from 'preact/hooks';
export function Like({ postId }: { postId: string }) { const [likes, setLikes] = useState(0); return ( <button onClick={async () => { const newLikes = await actions.like({ postId }); setLikes(newLikes); }} > {likes} likes </button> );}
export function Comment({ postId }: { postId: string }) { return ( <form onSubmit={async (e) => { e.preventDefault(); const formData = new FormData(e.target); const result = await actions.blog.comment(formData); // handle result }} > <input type="hidden" name="postId" value={postId} /> <label for="author">Author</label> <input id="author" type="text" name="author" /> <textarea rows={10} name="body"></textarea> <button type="submit">Post</button> </form> );}For a complete overview, and to give feedback on this experimental API, see the Actions RFC.
#10906 7bbd664 Thanks @Princesseuh! - Adds a new buttonBorderRadius property to the astro-dev-toolbar-button component for the dev toolbar component library. This property can be useful to make a fully rounded button with an icon in the center.
#10977 59571e8 Thanks @BryceRussell! - Improve error message when accessing clientAddress on prerendered routes
#10935 ddd8e49 Thanks @bluwy! - Improves the error message when failed to render MDX components
#10917 3412535 Thanks @jakobhellermann! - Fixes a case where the local server would crash when the host also contained the port, eg. with X-Forwarded-Host: hostname:8080 and X-Forwarded-Port: 8080 headers
#10959 685fc22 Thanks @bluwy! - Refactors internal handling of styles and scripts for content collections to improve build performance
#10889 4d905cc Thanks @matthewp! - Preserve content modules properly in cache
#10955 2978287 Thanks @florian-lefebvre! - Handles AstroUserErrors thrown while syncing content collections and exports BaseSchema and CollectionConfig types
#10911 a86dc9d Thanks @bluwy! - Skips adding CSS dependencies of CSS Vite modules as style tags in the HTML
#10900 36bb3b6 Thanks @martrapp! - Detects overlapping navigation and view transitions and automatically aborts all but the most recent one.
#10933 007d17f Thanks @Princesseuh! - Fixes app.toggleState not working correctly
#10931 4ce5ced Thanks @ktym4a! - Fixes toggleNotification()โs parameter type for the notification level not using the proper levels
#10665 7b4f284 Thanks @Princesseuh! - Adds new utilities to ease the creation of toolbar apps including defineToolbarApp to make it easier to define your toolbar app and app and server helpers for easier communication between the toolbar and the server. These new utilities abstract away some of the boilerplate code that is common in toolbar apps, and lower the barrier of entry for app authors.
For example, instead of creating an event listener for the app-toggled event and manually typing the value in the callback, you can now use the onAppToggled method. Additionally, communicating with the server does not require knowing any of the Vite APIs anymore, as a new server object is passed to the init function that contains easy to use methods for communicating with the server.
import { defineToolbarApp } from "astro/toolbar";
export default defineToolbarApp({ init(canvas, app, server) {
app.addEventListener("app-toggled", (e) => { console.log(`App is now ${state ? "enabled" : "disabled"}`);. });
app.onToggled(({ state }) => { console.log(`App is now ${state ? "enabled" : "disabled"}`); });
if (import.meta.hot) { import.meta.hot.send("my-app:my-client-event", { message: "world" }); }
server.send("my-app:my-client-event", { message: "world" })
if (import.meta.hot) { import.meta.hot.on("my-server-event", (data: {message: string}) => { console.log(data.message); }); }
server.on<{ message: string }>("my-server-event", (data) => { console.log(data.message); // data is typed using the type parameter }); },})Server helpers are also available on the server side, for use in your integrations, through the new toolbar object:
"astro:server:setup": ({ toolbar }) => { toolbar.on<{ message: string }>("my-app:my-client-event", (data) => { console.log(data.message); toolbar.send("my-server-event", { message: "hello" }); });}This is a backwards compatible change and your your existing dev toolbar apps will continue to function. However, we encourage you to build your apps with the new helpers, following the updated Dev Toolbar API documentation.
#10734 6fc4c0e Thanks @Princesseuh! - Astro will now automatically check for updates when you run the dev server. If a new version is available, a message will appear in the terminal with instructions on how to update. Updates will be checked once per 10 days, and the message will only appear if the project is multiple versions behind the latest release.
This behavior can be disabled by running astro preferences disable checkUpdates or setting the ASTRO_DISABLE_UPDATE_CHECK environment variable to false.
#10762 43ead8f Thanks @bholmesdev! - Enables type checking for JavaScript files when using the strictest TS config. This ensures consistency with Astroโs other TS configs, and fixes type checking for integrations like Astro DB when using an astro.config.mjs.
If you are currently using the strictest preset and would like to still disable .js files, set allowJS: false in your tsconfig.json.
#10861 b673bc8 Thanks @mingjunlu! - Fixes an issue where astro build writes type declaration files to outDir when itโs outside of root directory.
#10684 8b59d5d Thanks @PeterDraex! - Update sharp to 0.33 to fix issue with Alpine Linux
#10846 3294f7a Thanks @matthewp! - Prevent getCollection breaking in vitest
#10856 30cf82a Thanks @robertvanhoesel! - Prevents inputs with a name attribute of action or method to break ViewTransitionsโ form submission
#10833 8d5f3e8 Thanks @renovate! - Updates esbuild dependency to v0.20. This should not affect projects in most cases.
#10801 204b782 Thanks @rishi-raj-jain! - Fixes an issue where images in MD required a relative specifier (e.g. ./)
Now, you can use the standard  syntax in MD files for images colocated in the same folder: no relative specifier required!
There is no need to update your project; your existing images will still continue to work. However, you may wish to remove any relative specifiers from these MD images as they are no longer necessary:
 <!-- This dog lives in the same folder as my article! -->#10841 a2df344 Thanks @martrapp! - Due to regression on mobile WebKit browsers, reverts a change made for JavaScript animations during view transitions.
#10799 dc74afca9f5eebc2d61331298d6ef187d92051e0 Thanks @martrapp! - Fixes an issue with persisted non-text input fields that have the focus during view transition navigation.
#10773 35e43ecdaae7adc4b9a0b974192a033568cfb3f0 Thanks @lilnasy! - Improves performance for frequent use of small components.
#10763 63132771373ce1510be3e8814897accc0bf62ef8 Thanks @matthewp! - Invalidate CC cache manifest when lockfile or config changes
#10811 77822a822b04b5113726f713df104e8667333c59 Thanks @AvinashReddy3108! - Update list of available integrations in the astro add CLI help.
#10732 a92e263beb6e0166f1f13c97803d1861793e2a99 Thanks @rishi-raj-jain! - Correctly sets build.assets directory during vite config setup
#10776 1607face67051b16d4648555f1001b2a9308e377 Thanks @fshafiee! - Fixes cookies type inference
#10796 90669472df3a05b33f0de46fd2d039e3eba7f7dd Thanks @bluwy! - Disables streaming when rendering site with output: "static"
#10782 b0589d05538fcc77dd3c38198bf93f3548362cd8 Thanks @nektro! - Handles possible null value when calling which-pm during dynamic package installation
#10774 308b5d8c122f44e7724bb2f3ad3aa5c43a83e584 Thanks @Princesseuh! - Fixes astro add sometimes modifying baseUrl unintentionally
#10783 4dbd545304d1a8af903c8c97f237eb55c988c40b Thanks @jurajkapsz! - Fixes Picture component specialFormatsFallback fallback check
#10775 06843121450899ecf0390ca4efaff6c9a6fe0f75 Thanks @Princesseuh! - Fixes assets endpoint in serverless returning 404 in certain situations where the website might be under a protected route
#10787 699f4559a279b374bddb3e5e48c72afe2709e8e7 Thanks @martrapp! - Fixes a timing issue in the view transition simulation.
#10708 742866c5669a2be4f8b5a4c861cadb933c381415 Thanks @horo-fox! - Limits parallel imports within getCollection() to prevent EMFILE errors when accessing files
#10755 c6d59b6fb7db20af957a8706c8159c50619235ef Thanks @ematipico! - Fixes a case where the i18n fallback failed to correctly redirect to the index page with SSR enabled
#10591 39988ef8e2c4c4888543c973e06d9b9939e4ac95 Thanks @mingjunlu! - Adds a new dev toolbar settings option to change the horizontal placement of the dev toolbar on your screen: bottom left, bottom center, or bottom right.
#10689 683d51a5eecafbbfbfed3910a3f1fbf0b3531b99 Thanks @ematipico! - Deprecate support for versions of Node.js older than v18.17.1 for Node.js 18, older than v20.0.3 for Node.js 20, and the complete Node.js v19 release line.
This change is in line with Astroโs Node.js support policy.
#10678 2e53b5fff6d292b7acdf8c30a6ecf5e5696846a1 Thanks @ematipico! - Adds a new experimental security option to prevent Cross-Site Request Forgery (CSRF) attacks. This feature is available only for pages rendered on demand:
import { defineConfig } from 'astro/config';export default defineConfig({ experimental: { security: { csrfProtection: { origin: true, }, }, },});Enabling this setting performs a check that the โoriginโ header, automatically passed by all modern browsers, matches the URL sent by each Request.
This experimental โoriginโ check is executed only for pages rendered on demand, and only for the requests POST, PATCH, DELETEandPUTwith one of the followingcontent-type` headers: โapplication/x-www-form-urlencodedโ, โmultipart/form-dataโ, โtext/plainโ.
It the โoriginโ header doesnโt match the pathname of the request, Astro will return a 403 status code and wonโt render the page.
#10193 440681e7b74511a17b152af0fd6e0e4dc4014025 Thanks @ematipico! - Adds a new i18n routing option manual to allow you to write your own i18n middleware:
import { defineConfig } from 'astro/config';export default defineConfig({ i18n: { locales: ['en', 'fr'], defaultLocale: 'fr', routing: 'manual', },});Adding routing: "manual" to your i18n config disables Astroโs own i18n middleware and provides you with helper functions to write your own: redirectToDefaultLocale, notFound, and redirectToFallback:
import { redirectToDefaultLocale } from 'astro:i18n';export const onRequest = defineMiddleware(async (context, next) => { if (context.url.startsWith('/about')) { return next(); } else { return redirectToDefaultLocale(context, 302); }});Also adds a middleware function that manually creates Astroโs i18n middleware. This allows you to extend Astroโs i18n routing instead of completely replacing it. Run middleware in combination with your own middleware, using the sequence utility to determine the order:
import { defineMiddleware, sequence } from 'astro:middleware';import { middleware } from 'astro:i18n'; // Astro's own i18n routing config
export const userMiddleware = defineMiddleware();
export const onRequest = sequence( userMiddleware, middleware({ redirectToDefaultLocale: false, prefixDefaultLocale: true, }));#10671 9e14a78cb05667af9821948c630786f74680090d Thanks @fshafiee! - Adds the httpOnly, sameSite, and secure options when deleting a cookie
#10747 994337c99f84304df1147a14504659439a9a7326 Thanks @lilnasy! - Fixes an issue where functions could not be used as named slots.
#10750 7e825604ddf90c989537e07939a39dc249343897 Thanks @OliverSpeir! - Fixes a false positive for โInvalid tabindex on non-interactive elementโ rule for roleless elements ( div and span ).
#10745 d51951ce6278d4b59deed938d65e1cb72b5102df Thanks @lilnasy! - Fixes an issue where CLI commands could not report the reason for failure before exiting.
#10661 e2cd7f4291912dadd4a654bc7917856c58a72a97 Thanks @liruifengv! - Fixed errorOverlay theme toggle bug.
Updated dependencies [ccafa8d230f65c9302421a0ce0a0adc5824bfd55, 683d51a5eecafbbfbfed3910a3f1fbf0b3531b99]:
#10728 f508c4b7d54316e737f454a3777204b23636d4a0 Thanks @ematipico! - Fixes a regression where some very specific code rendered using expressive-code was not escaped properly.
#10737 8a30f257b1f3618b01212a591b82ad7a63c82fbb Thanks @lilnasy! - Fixes a regression where constructing and returning 404 responses from a middleware resulted in the dev server getting stuck in a loop.
#10719 b21b3ba307235510707ee9f5bd49f71473a07004 Thanks @ematipico! - Fixes a false positive for div and span elements when running the Dev Toolbar accessibility audits.
Those are special elements that donโt have an interaction assigned by default. Instead, it is assigned through the role attribute. This means that cases like the following are now deemed correct:
<div role="tablist"></div><span role="button" onclick="" onkeydown=""></span>#10688 799f6f3f29a3ef4f76347870a209ffa89651adfa Thanks @bluwy! - Marks renderer jsxImportSource and jsxTransformOptions options as deprecated as they are no longer used since Astro 3.0
#10657 93d353528fa1a85b67e3f1e9514ed2a1b42dfd94 Thanks @natemoo-re! - Improves the color contrast for notification badges on dev toolbar apps
#10693 1d26e9c7f7d8f47e33bc68d3b30bbffce25c7b63 Thanks @apetta! - Adds the disableremoteplayback attribute to MediaHTMLAttributes interface
#10695 a15975e41cb5eaf6ed8eb3ebaee676a17e433052 Thanks @bluwy! - Skips prerender chunk if building with static output
#10707 5e044a5eafaa206d2ef8b62c37d1bcd37f0a4078 Thanks @horo-fox! - Logs an error when a pageโs getStaticPaths fails
#10686 fa0f593890502faf5709ab881fe0e45519d2f7af Thanks @bluwy! - Prevents inlining scripts if used by other chunks when using the experimental.directRenderScript option
#10679 ca6bb1f31ef041e6ccf8ef974856fa945ff5bb31 Thanks @martrapp! - Generates missing popstate events for Firefox when navigating to hash targets on the same page.
#10669 0464563e527f821e53d78028d9bbf3c4e1050f5b Thanks @Princesseuh! - Fixes Astro waiting infinitely in CI when a required package was not installed
#10666 55ddb2ba4889480f776a8d29b9dcd531b9f5ab3e Thanks @lilnasy! - Fixes an issue where forwarded requests did not include hostname on node-based adapters. This also makes error pages more reliable.
#10642 4f5dc14f315eba7ea6ec5cc8e5dacb0cb81288dd Thanks @OliverSpeir! - Fixes typing issues when using format and quality options with remote images
#10616 317d18ef8c9cf4fd13647518e3fd352774a86481 Thanks @NikolaRHristov! - This change disables the sharp libvips image cache as it errors when the
file is too small and operations are happening too fast (runs into a race
condition)
#10470 320c309ca9fbe51c40e6ba846d04a0cb49aced5f Thanks @liruifengv! - improves client:only error message
#10496 ce985631129e49f7ea90e6ea690ef9f9cf0e6987 Thanks @florian-lefebvre! - Makes the warning less scary when adding 3rd-party integrations using astro add
#10495 046d69d517118ab5c0e71604b321729d66ddffff Thanks @satyarohith! - This patch allows astro to run in node-compat mode in Deno. Deno doesnโt support
construction of response from async iterables in node-compat mode so we need to
use ReadableStream.
#10605 a16a829f4e25ad5c9a1b4557ec089fc8ab53320f Thanks @martrapp! - Fixes an issue with outdated page titles in browser history when using text fragments in view transition navigation.
#10584 e648c5575a8774af739231cfa9fc27a32086aa5f Thanks @duanwilliam! - Fixes a bug where JSX runtime would error on components with nullish prop values in certain conditions.
#10608 e31bea0704890ff92ce4f9b0ce536c1c90715f2c Thanks @matthewp! - Fixes bug with head content being pushed into body
Updated dependencies [2cf116f80cb5e421ab5cc5eb4a654e7b78c1b8de, 374efcdff9625ca43309d89e3b9cfc9174351512]:
#10596 20463a6c1e1271d8dc3cb0ab3419ee5c72abd218 Thanks @Princesseuh! - Add removeBase function
Updated dependencies [20463a6c1e1271d8dc3cb0ab3419ee5c72abd218]:
#10567 fbdc10f90f7baa5c49f2f53e3e4ce8f453814c01 Thanks @Princesseuh! - Fixes astro:assets not working when using complex config with vite.build.rollupOptions.output.assetFileNames
#10593 61e283e5a0d95b6ef5d3c4c985d6ee78f74bbd8e Thanks @Princesseuh! - Fixes Polymorphic type helper causing TypeScript errors in certain cases after the previous update
#10543 0fd36bdb383297b32cc523b57d2442132da41595 Thanks @matthewp! - Fixes inline stylesheets with content collections cache
#10582 a05953538fcf524786385830b99c0c5a015173e8 Thanks @lilnasy! - Fixes an issue where the dev server got stuck in a loop while routing responses with a 404 status code to the 404 route.
#10549 54c2f9707f5d038630143f769e3075c698474654 Thanks @admirsaheta! - Updates the HTMLAttributes type exported from astro to allow data attributes
#10562 348c1ca1323d0516c2dcf8e963343cd12cb5407f Thanks @apetta! - Fixes minor type issues inside the built-in components of Astro
#10550 34fa8e131b85531e6629390307108ffc4adb7ed1 Thanks @Skn0tt! - Fixes bug where server builds would include unneeded assets in SSR Function, potentially leading to upload errors on Vercel, Netlify because of size limits
Updated dependencies [c585528f446ccca3d4c643f4af5d550b93c18902]:
#10532 8306ce1ff7b71a2a0d7908336c9be462a54d395a Thanks @martrapp! - Fixes a style issue of client:only components in DEV mode during view transitions.
#10473 627e47d67af4846cea2acf26a96b4124001b26fc Thanks @bluwy! - Fixes and improves performance when rendering Astro JSX
#10504 8e4e554cc211e59c329c0a5d110c839c886ff120 Thanks @Princesseuh! - Update Babel version to fix regression in Babelโs 7.24.2.
Updated dependencies [19e42c368184013fc30d1e46753b9e9383bb2bdf]:
e4a6462751725878bfe47632eeafa6854cad5bf2 Thanks @firefoxic! - <link> tags created by astro for optimized stylesheets now do not include the closing forward slash. This slash is optional for void elements such as link, but made some html validation fail.#10455 c12666166db724915e42e37a048483c99f88e6d9 Thanks @lilnasy! - Adds a helpful error message that will be shown when an endpoint does not return a Response.
#10426 6a9a35ee15069541c3144012385366a3c689240a Thanks @markgaze! - Fixes an issue with generating JSON schemas when the schema is a function
#10448 fcece3658697248ab58f77b3d4a8b14d362f3c47 Thanks @lilnasy! - Fixes an issue where multiple rendering errors resulted in a crash of the SSR app server.
#10379 3776ecf0aa9e08a992d3ae76e90682fd04093721 Thanks @1574242600! - Fixes a routing issue with partially truncated dynamic segments.
#10442 f8e0ad3c52a37b8a2175fe2f5ff2bd0cd738f499 Thanks @Princesseuh! - Fixes small rendering issues with the dev toolbar in certain contexts
#10438 5b48cc0fc8383b0659a595afd3a6ee28b28779c3 Thanks @bholmesdev! - Generate Astro DB types when running astro sync.
#10456 1900a8f9bc337f3a882178d1770e10ab67fab0ce Thanks @martrapp! - Fixes an error when using astro:transtions/client without <ViewTransitions/>
128c7a36397d99608dea918885b68bd302d00e7f Thanks @lilnasy! - Fixes an issue where error pages did not have access to the Astro.locals fields provided by the adapter.#10410 055fe293c6702dd27bcd6c4f59297c6d4385abb1 Thanks @lilnasy! - Fixes an issue where configured redirects could not include certain characters in the target path.
#9820 8edc42aa7c209b12d98ecf20cdecccddf7314af0 Thanks @alexnguyennz! - Prevents fully formed URLs in attributes from being escaped
629c9d7c4d96ae5711d95601e738b3d31d268116 Thanks @mingjunlu! - Fixes an issue where dev toolbar x-ray didnโt escape props content.#10392 02aeb01cb8b62b9cc4dfe6069857219404343b73 Thanks @martrapp! - Fixes broken types for some functions of astro:transitions/client.
#10390 236cdbb611587692d3c781850cb949604677ef82 Thanks @bholmesdev! - Adds --help reference for new db and studio CLI commands
#10206 dc87214141e7f8406c0fdf6a7f425dad6dea6d3e Thanks @lilnasy! - Allows middleware to run when a matching page or endpoint is not found. Previously, a pages/404.astro or pages/[...catch-all].astro route had to match to allow middleware. This is now not necessary.
When a route does not match in SSR deployments, your adapter may show a platform-specific 404 page instead of running Astroโs SSR code. In these cases, you may still need to add a 404.astro or fallback route with spread params, or use a routing configuration option if your adapter provides one.
#9960 c081adf998d30419fed97d8fccc11340cdc512e0 Thanks @StandardGage! - Allows passing any props to the <Code /> component
#10102 e3f02f5fb1cf0dae3c54beb3a4af3dbf3b06abb7 Thanks @bluwy! - Adds a new experimental.directRenderScript configuration option which provides a more reliable strategy to prevent scripts from being executed in pages where they are not used.
This replaces the experimental.optimizeHoistedScript flag introduced in v2.10.4 to prevent unused componentsโ scripts from being included in a page unexpectedly. That experimental option no longer exists and must be removed from your configuration, whether or not you enable directRenderScript:
import { defineConfig } from 'astro/config';
export default defineConfig({ experimental: { optimizeHoistedScript: true, directRenderScript: true }});With experimental.directRenderScript configured, scripts are now directly rendered as declared in Astro files (including existing features like TypeScript, importing node_modules, and deduplicating scripts). You can also now conditionally render scripts in your Astro file.
However, this means scripts are no longer hoisted to the <head> and multiple scripts on a page are no longer bundled together. If you enable this option, you should check that all your <script> tags behave as expected.
This option will be enabled by default in Astro 5.0.
#10130 5a9528741fa98d017b269c7e4f013058028bdc5d Thanks @bluwy! - Stabilizes markdown.shikiConfig.experimentalThemes as markdown.shikiConfig.themes. No behaviour changes are made to this option.
#10189 1ea0a25b94125e4f6f2ac82b42f638e22d7bdffd Thanks @peng! - Adds the option to pass an object to build.assetsPrefix. This allows for the use of multiple CDN prefixes based on the target file type.
When passing an object to build.assetsPrefix, you must also specify a fallback domain to be used for all other file types not specified.
Specify a file extension as the key (e.g. โjsโ, โpngโ) and the URL serving your assets of that file type as the value:
import { defineConfig } from 'astro/config';
export default defineConfig({ build: { assetsPrefix: { js: 'https://js.cdn.example.com', mjs: 'https://js.cdn.example.com', // if you have .mjs files, you must add a new entry like this png: 'https://images.cdn.example.com', fallback: 'https://generic.cdn.example.com', }, },});#10252 3307cb34f17159dfd3f03144697040fcaa10e903 Thanks @Princesseuh! - Adds support for emitting warning and info notifications from dev toolbar apps.
When using the toggle-notification event, the severity can be specified through detail.level:
eventTarget.dispatchEvent( new CustomEvent('toggle-notification', { detail: { level: 'warning', }, }));#10186 959ca5f9f86ef2c0a5a23080cc01c25f53d613a9 Thanks @Princesseuh! - Adds the ability to set colors on all the included UI elements for dev toolbar apps. Previously, only badge and buttons could be customized.
#10136 9cd84bd19b92fb43ae48809f575ee12ebd43ea8f Thanks @matthewp! - Changes the default behavior of transition:persist to update the props of persisted islands upon navigation. Also adds a new view transitions option transition:persist-props (default: false) to prevent props from updating as needed.
Islands which have the transition:persist property to keep their state when using the <ViewTransitions /> router will now have their props updated upon navigation. This is useful in cases where the component relies on page-specific props, such as the current page title, which should update upon navigation.
For example, the component below is set to persist across navigation. This component receives a products props and might have some internal state, such as which filters are applied:
<ProductListing transition:persist products={products} />Upon navigation, this component persists, but the desired products might change, for example if you are visiting a category of products, or you are performing a search.
Previously the props would not change on navigation, and your island would have to handle updating them externally, such as with API calls.
With this change the props are now updated, while still preserving state.
You can override this new default behavior on a per-component basis using transition:persist-props=true to persist both props and state during navigation:
<ProductListing transition:persist-props="true" products={products} />#9977 0204b7de37bf626e1b97175b605adbf91d885386 Thanks @OliverSpeir! - Supports adding the data-astro-rerun attribute on script tags so that they will be re-executed after view transitions
<script is:inline data-astro-rerun> ...</script>#10145 65692fa7b5f4440c644c8cf3dd9bc50103d2c33b Thanks @alexanderniebuhr! - Adds experimental JSON Schema support for content collections.
This feature will auto-generate a JSON Schema for content collections of type: 'data' which can be used as the $schema value for TypeScript-style autocompletion/hints in tools like VSCode.
To enable this feature, add the experimental flag:
import { defineConfig } from 'astro/config';
export default defineConfig({ experimental: { contentCollectionJsonSchema: true }});This experimental implementation requires you to manually reference the schema in each data entry file of the collection:
{ "$schema": "../../../.astro/collections/test.schema.json", "test": "test"}Alternatively, you can set this in your VSCode json.schemas settings:
"json.schemas": [ { "fileMatch": [ "/src/content/test/**" ], "url": "../../../.astro/collections/test.schema.json" }]Note that this initial implementation uses a library with known issues for advanced Zod schemas, so you may wish to consult these limitations before enabling the experimental flag.
#10130 5a9528741fa98d017b269c7e4f013058028bdc5d Thanks @bluwy! - Migrates shikiji to shiki 1.0
#10268 2013e70bce16366781cc12e52823bb257fe460c0 Thanks @Princesseuh! - Adds support for page mutations to the audits in the dev toolbar. Astro will now rerun the audits whenever elements are added or deleted from the page.
#10217 5c7862a9fe69954f8630538ebb7212cd04b8a810 Thanks @Princesseuh! - Updates the UI for dev toolbar audits with new information
#10360 ac766647b0e6156b7c4a0bb9a11981fe168852d7 Thanks @nmattia! - Fixes an issue where some CLI commands attempted to directly read vite config files.
#10291 8107a2721b6abb07c3120ac90e03c39f2a44ab0c Thanks @bluwy! - Treeshakes unused Astro component scoped styles
#10368 78bafc5d661ff7dd071c241cb1303c4d8a774d21 Thanks @Princesseuh! - Updates the base tsconfig.json preset with jsx: 'preserve' in order to fix errors when importing Astro files inside .js and .ts files.
Updated dependencies [c081adf998d30419fed97d8fccc11340cdc512e0, 1ea0a25b94125e4f6f2ac82b42f638e22d7bdffd, 5a9528741fa98d017b269c7e4f013058028bdc5d, a31bbd7ff8f3ec62ee507f72d1d25140b82ffc18]:
33583e8b31ee8a33e26cf57f30bb422921f4745d Thanks @lilnasy! - Fixes an issue where elements slotted within interactive framework components disappeared after hydration.#10355 8ce9fffd44b0740621178d61fb1425bf4155c2d7 Thanks @ematipico! - Fixes a regression where full dynamic routes were prioritized over partial dynamic routes. Now a route like food-[name].astro is matched before [name].astro.
#10356 d121311a3f4b5345e344e31f75d4e7164d65f729 Thanks @mingjunlu! - Fixes an issue where getCollection might return undefined when content collection is empty
#10325 f33cce8f6c3a2e17847658cdedb015bd93cc1ee3 Thanks @lilnasy! - Fixes an issue where ctx.site included the configured base in API routes and middleware, unlike Astro.site in astro pages.
#10343 f973aa9110592fa9017bbe84387f22c24a6d7159 Thanks @ematipico! - Fixes some false positive in the dev toolbar a11y audits, by adding the a element to the list of interactive elements.
#10295 fdd5bf277e5c1cfa30c1bd2ca123f4e90e8d09d9 Thanks @rossrobino! - Adds a prefetch fallback when using the experimental.clientPrerender option. If prerendering fails, which can happen if Chrome extensions block prerendering, it will fallback to prefetching the URL. This works by adding a prefetch field to the speculationrules script, but does not create an extra request.
a2e9b2b936666b2a4779feb00dcb8ff0ab82c2ec Thanks @matthewp! - Fixes @astrojs/db loading TS in the fixturesf2e60a96754ed1d86001fe4d5d3a0c0ef657408d Thanks @FredKSchott! - Fixes an issue where slotting interactive components within a โclient:onlyโ component prevented all component code in the page from running.#10281 9deb919ff95b1d2ffe5a5f70ec683e32ebfafd05 Thanks @lilnasy! - Fixes an issue where 404.astro was ignored with i18n routing enabled.
#10279 9ba3e2605daee3861e3bf6c5768f1d8bced4709d Thanks @lilnasy! - Fixes an issue where returning redirect responses resulted in missing files with certain adapters.
#10319 19ecccedaab6d8fa0ff23711c88fa7d4fa34df38 Thanks @lilnasy! - Fixes an issue where streaming SSR responses sometimes failed with โiterator.result is not a functionโ on node-based adapters.
#10302 992537e79f1847b590a2e226aac88a47a6304f68 Thanks @florian-lefebvre! - Fixes an issue that causes static entrypoints build to fail because of the path in certain conditions. Specifically, it failed if the path had an extension (like .astro, .mdx etc) and such extension would be also within the path (like ./.astro/index.astro).
#10298 819d20a89c0d269333c2d397c1080884f516307a Thanks @Fryuni! - Fix an incorrect conflict resolution between pages generated from static routes and rest parameters
4bc360cd5f25496aca3232f6efb3710424a14a34 Thanks @sanman1k98! - Fixes jerky scrolling on IOS when using view transitions.#10278 a548a3a99c2835c19662fc38636f92b2bda26614 Thanks @Princesseuh! - Fixes original images sometimes being kept / deleted when they shouldnโt in both MDX and Markdoc
#10280 3488be9b59d1cb65325b0e087c33bcd74aaa4926 Thanks @bholmesdev! - Finalize db API to a shared db/ directory.
5e3e74b61daa2ba44c761c9ab5745818661a656e Thanks @Princesseuh! - Fixes dev toolbar warning about using the proper loading attributes on images using data: URIs#10287 a90d685d7 Thanks @ematipico! - Fixes an issue where in Node SSR, the image endpoint could be used maliciously to reveal unintended information about the underlying system.
Thanks to Google Security Team for reporting this issue.
#10274 e556151603a2f0173059d0f98fdcbec0610b48ff Thanks @lilnasy! - Fixes a regression introduced in v4.4.5 where image optimization did not work in dev mode when a base was configured.
#10263 9bdbed723e0aa4243d7d6ee64d1c1df3b75b9aeb Thanks @martrapp! - Adds auto completion for astro: event names when adding or removing event listeners on document.
#10284 07f89429a1ef5173d3321e0b362a9dc71fc74fe5 Thanks @Princesseuh! - Fixes an issue where in Node SSR, the image endpoint could be used maliciously to reveal unintended information about the underlying system.
Thanks to Google Security Team for reporting this issue.
#10247 fb773c9161bf8faa5ebd7e115f3564c3359e56ea Thanks @martrapp! - Fixes an issue where transition:animate="none" still allowed the browser-native morph animation.
#10248 8ae5d99534fc09d650e10e64a09b61a2807574f2 Thanks @ematipico! - Fixes an issue where multiple injected routes with the same entrypoint but different pattern were incorrectly cached, causing some of them not being rendered in the dev server.
#10250 57655a99db34e20e9661c039fab253b867013318 Thanks @log101! - Fixes the overwriting of localised index pages with redirects
#10239 9c21a9df6b03e36bd78dc553e13c55b9ef8c44cd Thanks @mingjunlu! - Improves the message of MiddlewareCantBeLoaded for clarity
#10222 ade9759cae74ca262b988260250bcb202235e811 Thanks @martrapp! - Adds a warning in DEV mode when using view transitions on a device with prefer-reduced-motion enabled.
#10251 9b00de0a76b4f4b5b808e8c78e4906a2497e8ecf Thanks @mingjunlu! - Fixes TypeScript type definitions for Code component theme and experimentalThemes props
#10221 4db82d9c7dce3b73fe43b86020fcfa326c1357ec Thanks @matthewp! - Prevents errors in templates from crashing the server
#10219 afcb9d331179287629b5ffce4020931258bebefa Thanks @matthewp! - Fix dynamic slots missing hydration scripts
#10220 1eadb1c5290f2f4baf538c34889a09d5fcfb9bd4 Thanks @Princesseuh! - Fixes some built-in apps of the dev toolbar not closing when clicking the page
#10154 e64bd0740b44aed5cfaf67e5c37a1c56ed4442f4 Thanks @Cherry! - Fixes an issue where config.vite.build.assetsInlineLimit could not be set as a function.
#10196 8fb32f390d40cfa12a82c0645928468d27218866 Thanks @lilnasy! - Fixes an issue where a warning about headers being accessed in static mode is unnecessarily shown when i18n is enabled.
#10199 6aa660ae7abc6841d7a3396b29f10b9fb7910ce5 Thanks @lilnasy! - Fixes an issue where prerendered pages had access to query params in dev mode.
#10195 903eace233033998811b72e27a54c80d8e59ff37 Thanks @1574242600! - Fix build failure caused by read-only files under /public (in the presence of client-side JS).
#10205 459f74bc71748279fe7dce0688f38bd74b51c5c1 Thanks @martrapp! - Adds an error message for non-string transition:name values
#10208 8cd38f02456640c063552aef00b2b8a216b3935d Thanks @log101! - Fixes custom headers are not added to the Node standalone server responses in preview mode
#10143 7c5fcd2fa817472f480bbfbbc11b9ed71a7210ab Thanks @bluwy! - Improves the default optimizeDeps.entries Vite config to avoid globbing server endpoints, and respect the srcDir option
#10197 c856c729404196900a7386c8426b81e79684a6a9 Thanks @Princesseuh! - Fixes errors being logged twice in some cases
#10166 598f30c7cd6c88558e3806d9bc5a15d426d83992 Thanks @bluwy! - Improves Astro style tag HMR when updating imported styles
#10194 3cc20109277813ccb9578ca87a8b0d680a73c35c Thanks @matthewp! - Fixes an issue related to content collections usage in browser context caused by csssec