#9118000e8f465 Thanks @Princesseuh! - Redesign Dev Overlay main screen to show more information, such as the coolest integrations, your current Astro version and more.
#9118000e8f465 Thanks @Princesseuh! - Fixes an issue where links with the same pathname as the current page, but different search params, were not prefetched.
#9138abf601233 Thanks @bluwy! - Updates the unified, remark, and rehype dependencies to latest. Make sure to update your custom remark and rehype plugins as well to be compatible with the latest versions.
Potentially breaking change: The default value of markdown.remarkRehype.footnoteBackLabel is changed from "Back to content" to "Back to reference 1". See the mdast-util-to-hastcommit for more information.
#9181cdabf6ef0 Thanks @bluwy! - Removes support for returning simple objects from endpoints (deprecated since Astro 3.0). You should return a Response instead.
ResponseWithEncoding is also removed. You can refactor the code to return a response with an array buffer instead, which is encoding agnostic.
The types for middlewares have also been revised. To type a middleware function, you should now use MiddlewareHandler instead of MiddlewareResponseHandler. If you used defineMiddleware() to type the function, no changes are needed.
#91221c48ed286 Thanks @bluwy! - Adds Vite 5 support. There are no breaking changes from Astro. Check the Vite migration guide for details of the breaking changes from Vite instead.
#919637697a2c5 Thanks @bluwy! - Removes support for Shiki custom languageβs path property. The language JSON file should be imported and passed to the option instead.
#9161bd0c2e9ae Thanks @bluwy! - Renames the entryPoint property of the injectRoute integrations API to entrypoint for consistency. A warning will be shown prompting you to update your code when using the old name.
π Patch Changes
#91490fe3a7ed5 Thanks @bluwy! - Removes vendored Viteβs importMeta.d.ts file in favour of Vite 5βs new vite/types/import-meta.d.ts export
#9150710be505c Thanks @bluwy! - Refactors virtual modules exports. This should not break your project unless you import Astroβs internal modules, including:
Three new events now complement the existing astro:after-swap and astro:page-load events:
astro: before - preparation; // Control how the DOM and other resources of the target page are loaded
astro: after - preparation; // Last changes before taking off? Remove that loading indicator? Here you go!
astro: before - swap; // Control how the DOM is updated to match the new page
The astro:before-* events allow you to change properties and strategies of the view transition implementation.
The astro:after-* events are notifications that a phase is complete.
Head over to docs to see the full view transitions lifecycle including these new events!
#90920ea4bd47e Thanks @smitbarmase! - Changes the fallback prefetch behavior on slow connections and when data saver mode is enabled. Instead of disabling prefetch entirely, the tap strategy will be used.
The <Picture /> component, part of astro:assets, has exited experimental status and is now recommended for use. There are no code changes to the component, and no upgrade to your project is necessary.
This is only a change in documentation/recommendation. If you were waiting to use the <Picture /> component until it had exited the experimental stage, wait no more!
#90920ea4bd47e Thanks @smitbarmase! - Adds a ignoreSlowConnection option to the prefetch() API to prefetch even on data saver mode or slow connection.
#9091536c6c9fd Thanks @ematipico! - The routingStrategyprefix-always should not force its logic to endpoints. This fixes some regression with astro:assets and @astrojs/rss.
#910260e8210b0 Thanks @Princesseuh! - In the dev overlay, when thereβs too many plugins enabled at once, some of the plugins will now be hidden in a separate sub menu to avoid the bar becoming too long
#9085fc66ecff1 Thanks @ematipico! - When redirecting to the default root locale, Astro middleare should take into consideration the value of trailingSlash
#9087b895113a0 Thanks @alexanderniebuhr! - Fixes the regression which broke bundling of image service for pre-rendered pages, which was introduced by #8854
Itβs now possible in Astro for an integration to add middleware on behalf of the user. Previously when a third party wanted to provide middleware, the user would need to create a src/middleware.ts file themselves. Now, adding third-party middleware is as easy as adding a new integration.
For integration authors, there is a new addMiddleware function in the astro:config:setup hook. This function allows you to specify a middleware module and the order in which it should be applied:
if (response.headers.get('content-type') ==='text/html') {
let html =await response.text();
html =minify(html);
returnnewResponse(html, {
status: response.status,
headers: response.headers,
});
}
return response;
});
You can now add your integrationβs middleware and specify that it runs either before or after the applicationβs own defined middleware (defined in src/middleware.{js,ts})
my-package/integration.js
exportfunctionmyIntegration() {
return {
name: 'my-integration',
hooks: {
'astro:config:setup': ({ addMiddleware }) => {
addMiddleware({
entrypoint: 'my-package/middleware',
order: 'pre',
});
},
},
};
}
#88543e1239e42 Thanks @natemoo-re! - Provides a new, experimental build cache for Content Collections as part of the Incremental Build RFC. This includes multiple refactors to Astroβs build process to optimize how Content Collections are handled, which should provide significant performance improvements for users with many collections.
Users building a static site can opt-in to preview the new build cache by adding the following flag to your Astro config:
astro.config.mjs
exportdefault {
experimental: {
contentCollectionCache: true,
},
};
When this experimental feature is enabled, the files generated from your content collections will be stored in the cacheDir (by default, node_modules/.astro) and reused between builds. Most CI environments automatically restore files in node_modules/ by default.
In our internal testing on the real world Astro Docs project, this feature reduces the bundling step of astro build from 133.20s to 10.46s, about 92% faster. The end-to-end astro build process used to take 4min 58s and now takes just over 1min for a total reduction of 80%.
If you run into any issues with this experimental feature, please let us know!
You can always bypass the cache for a single build by passing the --force flag to astro build.
The <ViewTransitions /> router can now handle form submissions, allowing the same animated transitions and stateful UI retention on form posts that are already available on <a> links. With this addition, your Astro project can have animations in all of these scenarios:
Clicking links between pages.
Making stateful changes in forms (e.g. updating site preferences).
Manually triggering navigation via the navigate() API.
This feature is opt-in for semver reasons and can be enabled by adding the handleForms prop to the ` component:
Just as with links, if you donβt want the routing handling a form submission, you can opt out on a per-form basis with the data-astro-reload property:
Form support works on post method="get" and method="post" forms.
#8954f0031b0a3 Thanks @Princesseuh! - Updates the Image Services API to now delete original images from the final build that are not used outside of the optimization pipeline. For users with a large number of these images (e.g. thumbnails), this should reduce storage consumption and deployment times.
#898426b1484e8 Thanks @Princesseuh! - Adds a new property propertiesToHash to the Image Services API to allow specifying which properties of getImage() / <Image /> / <Picture /> should be used for hashing the result files when doing local transformations. For most services, this will include properties such as src, width or quality that directly changes the content of the generated image.
#9010100b61ab5 Thanks @jasikpark! - The <Picture /> component will now use jpg and jpeg respectively as fallback formats when the original image is in those formats.
Astroβs experimental i18n routing API allows you to add your multilingual content with support for configuring a default language, computing relative page URLs, and accepting preferred languages provided by your visitorβs browser. You can also specify fallback languages on a per-language basis so that your visitors can always be directed to existing content on your site.
Enable the experimental routing option by adding an i18n object to your Astro configuration with a default location and a list of all languages to support:
astro.config.mjs
import { defineConfig } from'astro/config';
exportdefaultdefineConfig({
experimental: {
i18n: {
defaultLocale: 'en',
locales: ['en', 'es', 'pt-br'],
},
},
});
Organize your content folders by locale depending on your i18n.routingStrategy, and Astro will handle generating your routes and showing your preferred URLs to your visitors.
βββ src
β βββ pages
β β βββ about.astro
β β βββ index.astro
β β βββ es
β β β βββ about.astro
β β β βββ index.astro
β β βββ pt-br
β β β βββ about.astro
β β β βββ index.astro
Compute relative URLs for your links with getRelativeLocaleUrl from the new astro:i18n module:
<p>Learn more <ahref={aboutURL}>About</a> this site!</p>
Enabling i18n routing also provides two new properties for browser language detection: Astro.preferredLocale and Astro.preferredLocaleList. These combine the browserβs Accept-Langauge header, and your siteβs list of supported languages and can be used to automatically respect your visitorβs preferred languages.
You can enable prefetching for your site with the prefetch: true config. It is enabled by default when using View Transitions and can also be used to configure the prefetch behaviour used by View Transitions.
You can enable prefetching by setting prefetch:true in your Astro config:
astro.config.js
import { defineConfig } from'astro/config';
exportdefaultdefineConfig({
prefetch: true,
});
This replaces the @astrojs/prefetch integration, which is now deprecated and will eventually be removed.
Visit the Prefetch guide for more information.
#8903c5010aad3 Thanks @horo-fox! - Adds experimental support for multiple shiki themes with the new markdown.shikiConfig.experimentalThemes option.
π Patch Changes
#90161ecc9aa32 Thanks @Princesseuh! - Add ability to βClick to go editorβ on auditted elements in the dev overlay
#902929b83e9e4 Thanks @Princesseuh! - Use UInt8Array instead of Buffer for both the input and return values of the transform() hook of the Image Service API to ensure compatibility with non-Node runtimes.
This change is unlikely to affect you, but if you were previously relying on the return value being a Buffer, you may convert an UInt8Array to a Buffer using Buffer.from(your_array).
#900035739d01e Thanks @martrapp! - Fixes an error in dev mode on Safari where view transitions prevented navigating to pages with client:only components
#9014d979b8f0a Thanks @Princesseuh! - Add animations, shadows and general styling tweaks to the Dev Overlay to better match the intended design.
#89963988bbcc9 Thanks @bluwy! - Adds compatibility for shiki languages with the path property
#8986910eb00fe Thanks @Princesseuh! - Fix sizes attribute not being present on source elements when using it on the Picture component
#8966262cef248 Thanks @Princesseuh! - Fix Dev Overlay not working properly when view transitions are enabled
#89325fed432b0 Thanks @Princesseuh! - Fixed window component appearing over the dev overlay on small windows. Added a maximum length to sections of the tooltip component
A page component can now be identified as a partial page, which will render its HTML content without including a <! DOCTYPE html> declaration nor any <head> content.
A rendering library, like htmx or Stimulus or even just jQuery can access partial content on the client to dynamically update only parts of a page.
Pages marked as partials do not have a doctype or any head content included in the rendered result. You can mark any page as a partial by setting this option:
---
exportconstpartial=true;
---
<li>This is a single list item.</li>
Other valid page files that can export a value (e.g. .mdx) can also be marked as partials.
Astro will now generate optimized images concurrently at build time, which can significantly speed up build times for sites with many images. Additionally, Astro will now reuse the same buffer for all variants of an image. This should improve performance for websites with many variants of the same image, especially when using remote images.
No code changes are required to take advantage of these improvements.
Provides a new dev overlay for your browser preview that allows you to inspect your page islands, see helpful audits on performance and accessibility, and more. A Dev Overlay Plugin API is also included to allow you to add new features and third-party integrations to it.
You can enable access to the dev overlay and its API by adding the following flag to your Astro config:
#88808c3d4a859 Thanks @alexanderniebuhr! - Moves the logic for overriding the image service out of core and into adapters. Also fixes a regression where a valid astro:assets image service configuration could be overridden.