packages/astro/CHANGELOG-v3.md
#9226 8f8a40e93 Thanks @outofambit! - Fix i18n fallback routing with routing strategy of always-prefix
#9179 3f28336d9 Thanks @lilnasy! - Fixes an issue where the presence of a slot in a page led to an error.
#9219 067a65f5b Thanks @natemoo-re! - Fix edge case where <style> updates inside of .astro files would occasionally fail to update without reloading the page.
#9236 27d3e86e4 Thanks @ematipico! - The configuration i18n.routingStrategy has been replaced with an object called routing.
export default defineConfig({
experimental: {
i18n: {
- routingStrategy: "prefix-always",
+ routing: {
+ prefixDefaultLocale: true,
+ }
}
}
})
export default defineConfig({
experimental: {
i18n: {
- routingStrategy: "prefix-other-locales",
+ routing: {
+ prefixDefaultLocale: false,
+ }
}
}
})
0dc99c9a2 Thanks @florian-lefebvre! - Prevents the Code component from crashing if the lang isn't supported by falling back to plaintext.d90714fc3 Thanks @SpencerWhitehead7! - Fixes an issue where links with the same pathname as the current page, but different search params, were not prefetched.#9226 8f8a40e93 Thanks @outofambit! - Fix i18n fallback routing with routing strategy of always-prefix
#9179 3f28336d9 Thanks @lilnasy! - Fixes an issue where the presence of a slot in a page led to an error.
#9219 067a65f5b Thanks @natemoo-re! - Fix edge case where <style> updates inside of .astro files would occasionally fail to update without reloading the page.
#9236 27d3e86e4 Thanks @ematipico! - The configuration i18n.routingStrategy has been replaced with an object called routing.
export default defineConfig({
experimental: {
i18n: {
- routingStrategy: "prefix-always",
+ routing: {
+ prefixDefaultLocale: true,
+ }
}
}
})
export default defineConfig({
experimental: {
i18n: {
- routingStrategy: "prefix-other-locales",
+ routing: {
+ prefixDefaultLocale: false,
+ }
}
}
})
0dc99c9a2 Thanks @florian-lefebvre! - Prevents the Code component from crashing if the lang isn't supported by falling back to plaintext.d90714fc3 Thanks @SpencerWhitehead7! - Fixes an issue where links with the same pathname as the current page, but different search params, were not prefetched.#9173 04fdc1c61 Thanks @lilnasy! - Fixes an issue where having a middleware prevented the SSR app from being deployed on Netlify.
#9186 607542c7c Thanks @martrapp! - Fixes a view transition issue on webKit browsers that prevented scrolling to #fragments
#9090 c87223c21 Thanks @martrapp! - Take full control over the behavior of view transitions!
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!
#9092 0ea4bd47e 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.
#9166 cba6cf32d Thanks @matthewp! - The Picture component is no longer experimental
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!
#9092 0ea4bd47e Thanks @smitbarmase! - Adds a ignoreSlowConnection option to the prefetch() API to prefetch even on data saver mode or slow connection.
7ff8d62bf Thanks @ematipico! - Revert fix around fallback system, which broken injected styles#9121 f4efd1c80 Thanks @peng! - Adds a warning if astro add fetches a package but returns a non-404 status
#9142 7d55cf68d Thanks @ematipico! - Consistently emit fallback routes in the correct folders.
#9119 306781795 Thanks @ematipico! - Fix a flaw in the i18n fallback logic, where the routes didn't preserve their metadata, such as hoisted scripts
#9140 7742fd7dc Thanks @martrapp! - View Transitions: handle clicks on SVGAElements and image maps"
#9101 e3dce215a Thanks @ematipico! - Add a new property Astro.currentLocale, available when i18n is enabled.
#9091 536c6c9fd Thanks @ematipico! - The routingStrategy prefix-always should not force its logic to endpoints. This fixes some regression with astro:assets and @astrojs/rss.
#9102 60e8210b0 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
#9085 fc66ecff1 Thanks @ematipico! - When redirecting to the default root locale, Astro middleware should take into consideration the value of trailingSlash
#9067 c6e449c5b Thanks @danielhajduk! - Fixes display of debug messages when using the --verbose flag
#9075 c5dc8f2ec Thanks @Princesseuh! - Fix Passthrough image service generating multiple images with the same content in certain cases
#9083 4537ecf0d Thanks @bluwy! - Uses new createShikiHighlighter API from @astrojs/markdown-remark to avoid code duplication
#9084 045e5ec97 Thanks @matthewp! - Supports formmethod and formaction for form overrides
#9087 b895113a0 Thanks @alexanderniebuhr! - Fixes the regression which broke bundling of image service for pre-rendered pages, which was introduced by #8854
#9058 5ef89ef33 Thanks @Princesseuh! - Add a new settings panel to the dev overlay
#9045 84312f24f Thanks @rishi-raj-jain! - Fixes preview server trailingSlash handling for request URLs with query strings
Updated dependencies [4537ecf0d]:
50164f5e3 Thanks @natemoo-re! - Fix a regression introduced in 3.5.0 related to content collection styles1bc331968 Thanks @ematipico! - Correctly infer the presence of an user middleware#9037 ea71975ec Thanks @sarah11918! - Updates i18n configuration reference
#9051 15b84ccb9 Thanks @ematipico! - Fix a regression where endpoints were incorrectly processed during SSG build when trailingSlash: "always"
#9042 7dedd17fc Thanks @rishi-raj-jain! - Safely bail when the xclip command does not exist on Linux when trying to copy to clipboard with astro info
#9050 bf0286e50 Thanks @Princesseuh! - Fix --verbose flag not working
#9049 49b82edb2 Thanks @Princesseuh! - Fix image errors when images were used on the client
#8869 f5bdfa272 Thanks @matthewp! - ## Integration Hooks to add Middleware
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:
// my-package/middleware.js
import { defineMiddleware } from 'astro:middleware';
export const onRequest = defineMiddleware(async (context, next) => {
const response = await next();
if (response.headers.get('content-type') === 'text/html') {
let html = await response.text();
html = minify(html);
return new Response(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
export function myIntegration() {
return {
name: 'my-integration',
hooks: {
'astro:config:setup': ({ addMiddleware }) => {
addMiddleware({
entrypoint: 'my-package/middleware',
order: 'pre',
});
},
},
};
}
#8854 3e1239e42 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
export default {
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.
astro build --force
#8963 fda3a0213 Thanks @matthewp! - Form support in View Transitions router
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:
navigate() API.This feature is opt-in for semver reasons and can be enabled by adding the handleForms prop to the `<ViewTransitions /> component:
---
// src/layouts/MainLayout.astro
import { ViewTransitions } from 'astro:transitions';
---
<html>
<head>
<!-- ... -->
<ViewTransitions handleForms />
</head>
<body>
<!-- ... -->
</body>
</html>
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:
---
// src/components/Contact.astro
---
<form class="contact-form" action="/request" method="post" data-astro-reload>
<!-- ...-->
</form>
Form support works on post method="get" and method="post" forms.
#8954 f0031b0a3 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.
#8984 26b1484e8 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.
#9010 100b61ab5 Thanks @jasikpark! - The <Picture /> component will now use jpg and jpeg respectively as fallback formats when the original image is in those formats.
#8974 143bacf39 Thanks @ematipico! - Experimental support for i18n routing.
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';
export default defineConfig({
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:
---
import { getRelativeLocaleUrl } from 'astro:i18n';
const aboutUrl = getRelativeLocaleUrl('pt-br', 'about');
---
<p>Learn more <a href={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-Language header, and your site's list of supported languages and can be used to automatically respect your visitor's preferred languages.
Read more about Astro's experimental i18n routing in our documentation.
#8951 38e21d127 Thanks @bluwy! - Prefetching is now supported in core
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';
export default defineConfig({
prefetch: true,
});
This replaces the @astrojs/prefetch integration, which is now deprecated and will eventually be removed.
Visit the Prefetch guide for more information.
#8903 c5010aad3 Thanks @horo-fox! - Adds experimental support for multiple shiki themes with the new markdown.shikiConfig.experimentalThemes option.
#9016 1ecc9aa32 Thanks @Princesseuh! - Add ability to "Click to go editor" on audited elements in the dev overlay
#9029 29b83e9e4 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).
Updated dependencies [c5010aad3]:
#9000 35739d01e Thanks @martrapp! - Fixes an error in dev mode on Safari where view transitions prevented navigating to pages with client:only components
#9014 d979b8f0a Thanks @Princesseuh! - Add animations, shadows and general styling tweaks to the Dev Overlay to better match the intended design.
#8996 3988bbcc9 Thanks @bluwy! - Adds compatibility for shiki languages with the path property
#8986 910eb00fe Thanks @Princesseuh! - Fix sizes attribute not being present on source elements when using it on the Picture component
#8981 ab7e745cc Thanks @matthewp! - Increase the scroll restoration throttle time
#8940 937522fb7 Thanks @MarvinXu! - Omit nullish and falsy (non-zero) values when stringifying object-form style attributes in Astro files
#8977 40a061679 Thanks @matthewp! - Prevent route announcer from being visible
#8929 2da33b7a1 Thanks @lilnasy! - Fixes an issue where rendering the same slot multiple times invoked it only once.
#8978 cc3278bb6 Thanks @Princesseuh! - In the dev overlay, add a tooltip showing the currently hovered / focused plugin's name
#8966 262cef248 Thanks @Princesseuh! - Fix Dev Overlay not working properly when view transitions are enabled
#8932 5fed432b0 Thanks @Princesseuh! - Fixed window component appearing over the dev overlay on small windows. Added a maximum length to sections of the tooltip component
#8965 430c470ac Thanks @matthewp! - Move VT route announcer styles to a class
Doing so allows stricter CSP policies.
#8762 35cd810f0 Thanks @evadecker! - Upgrades Zod to 3.22.4
#8928 ca90b47cf Thanks @HiDeoo! - Renames dev overlay UI Toolkit component names for consistency.
#8755 fe4079f05 Thanks @matthewp! - Page Partials
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:
---
export const partial = 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.
Read more about Astro page partials in our documentation.
#8821 4740d761a Thanks @Princesseuh! - Improved image optimization performance
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.
#8757 e99586787 Thanks @Princesseuh! - Dev Overlay (experimental)
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:
// astro.config.mjs
export default {
experimental: {
devOverlay: true,
},
};
Read the Dev Overlay Plugin API documentation for information about building your own plugins to integrate with Astro's dev overlay.
#8880 8c3d4a859 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.
#8877 26b77b8fe Thanks @bluwy! - Fixes CSS modules ordering by rendering styles before links
Updated dependencies [341ef6578]:
#8870 5ea6ee0ed Thanks @xstevenyung! - prevent production install on astro add cmd
#8840 5c888c10b Thanks @martrapp! - Fixes styles of client:only components not persisting during view transitions in dev mode
#8814 ad2bb9155 Thanks @lilnasy! - Fix an issue where 500.astro did not render when the middleware threw an error.
#8863 326e17893 Thanks @florian-lefebvre! - Fixes an issue where the dev server logged the full file path on updates.
#8852 2c18e2d12 Thanks @rayriffy! - Only use Vite config from astro.config.mjs as source of truth
#8828 11f45b9a3 Thanks @rishi-raj-jain! - fix file system path references
#8779 2b8a459a6 Thanks @ematipico! - Enriches the explanation of the base configuration with examples.
#8823 8946f2a25 Thanks @Princesseuh! - Fix duplicate images being created in some cases when using densities and/or widths
#8842 b405b039a Thanks @Princesseuh! - Fixes Picture component not taking into account the fallback format specified
#8827 ce3025cfa Thanks @rishi-raj-jain! - better error handling there whenever we don't get a normal 200 response
#8817 f8de1983b Thanks @bluwy! - Fix error overlay syntax highlighting
#8838 2f9e2083d Thanks @dominikg! - deps: unpin and update tsconfck from 3.0.0-next.9 to ^3.0.0
#8823 8946f2a25 Thanks @Princesseuh! - fix remote srcset images not being resized
#8808 2993055be Thanks @delucis! - Adds support for an --outDir CLI flag to astro build
#8502 c4270e476 Thanks @bluwy! - Updates the internal shiki syntax highlighter to shikiji, an ESM-focused alternative that simplifies bundling and maintenance.
There are no new options and no changes to how you author code blocks and syntax highlighting.
Potentially breaking change: While this refactor should be transparent for most projects, the transition to shikiji now produces a smaller HTML markup by attaching a fallback color style to the pre or code element, instead of to the line span directly. For example:
Before:
<code class="astro-code" style="background-color: #24292e">
<pre>
<span class="line" style="color: #e1e4e8">my code</span>
</pre>
</code>
After:
<code class="astro-code" style="background-color: #24292e; color: #e1e4e8">
<pre>
<span class="line">my code<span>
</pre>
</code>
This does not affect the colors as the span will inherit the color from the parent, but if you're relying on a specific HTML markup, please check your site carefully after upgrading to verify the styles.
#8798 f369fa250 Thanks @Princesseuh! - Fixed tsconfig.json's new array format for extends not working. This was done by migrating Astro to use tsconfck instead of tsconfig-resolver to find and parse tsconfig.json files.
#8620 b2ae9ee0c Thanks @Princesseuh! - Adds experimental support for generating srcset attributes and a new <Picture /> component.
srcset supportTwo new properties have been added to Image and getImage(): densities and widths.
These properties can be used to generate a srcset attribute, either based on absolute widths in pixels (e.g. [300, 600, 900]) or pixel density descriptors (e.g. ["2x"] or [1.5, 2]).
---
import { Image } from 'astro';
import myImage from './my-image.jpg';
---
<Image src={myImage} width={myImage.width / 2} densities={[1.5, 2]} alt="My cool image" />
The experimental <Picture /> component can be used to generate a <picture> element with multiple <source> elements.
The example below uses the format property to generate a <source> in each of the specified image formats:
---
import { Picture } from 'astro:assets';
import myImage from './my-image.jpg';
---
<Picture src={myImage} formats={['avif', 'webp']} alt="My super image in multiple formats!" />
The above code will generate the following HTML, and allow the browser to determine the best image to display:
<picture>
<source srcset="..." type="image/avif" />
<source srcset="..." type="image/webp" />
</picture>
The Picture component takes all the same props as the Image component, including the new densities and widths properties.
#8771 bd5aa1cd3 Thanks @lilnasy! - Fixed an issue where the transitions router did not work within framework components.
#8800 391729686 Thanks @lilnasy! - Fixed an issue where attempting to assign a variable onto locals threw an error.
#8795 f999365b8 Thanks @bluwy! - Fix markdown page charset to be utf-8 by default (same as Astro 2)
#8810 0abff97fe Thanks @jacobthesheep! - Remove network-information-types package since TypeScript supports Network Information API natively.
#8813 3bef32f81 Thanks @martrapp! - Save and restore focus for persisted input elements during view transitions
Updated dependencies [c4270e476]:
#8638 160d1cd75 Thanks @florian-lefebvre! - The @astrojs/tailwind integration now creates a tailwind.config.mjs file by default
#8767 30de32436 Thanks @martrapp! - Revert fix #8472
#8472 caused some style files from previous pages to not be cleanly deleted on view transitions. For a discussion of a future fix for the original issue #8144 see #8745.
#8741 c4a7ec425 Thanks @lilnasy! - Fixed an issue on Windows where lowercase drive letters in current working directory led to missing scripts and styles.
#8772 c24f70d91 Thanks @martrapp! - Fix flickering during view transitions
#8754 93b092266 Thanks @bluwy! - Make CSS chunk names less confusing
#8776 29cdfa024 Thanks @martrapp! - Fix transition attributes on islands
#8773 eaed844ea Thanks @sumimakito! - Fix an issue where HTML attributes do not render if getHTMLAttributes in an image service returns a Promise
#8737 6f60da805 Thanks @ematipico! - Add provenance statement when publishing the library from CI
#8747 d78806dfe Thanks @natemoo-re! - Improve error message when user attempts to render a dynamic component reference
#8736 d1c75fe15 Thanks @bluwy! - Fix tsconfig.json update causing the server to crash
#8743 aa265d730 Thanks @bluwy! - Remove unused CSS output files when inlined
#8700 78adbc443 Thanks @jacobthesheep! - Update link for Netlify SSR
#8729 21e0757ea Thanks @lilnasy! - Node-based adapters now create less server-side javascript
#8730 357270f2a Thanks @natemoo-re! - Improve astro info copy to clipboard compatibility
Updated dependencies [21f482657, 6f60da805, 21e0757ea]:
#8710 4c2bec681 Thanks @matthewp! - Fixes View transition styles being missing when component used multiple times
#8680 31c59ad8b Thanks @bluwy! - Fix hydration on slow connection
#8698 47ea310f0 Thanks @Princesseuh! - Use a Node-specific image endpoint to resolve images in dev and Node SSR. This should fix many issues related to getting 404 from the _image endpoint under certain configurations
#8706 345808170 Thanks @bluwy! - Fix duplicated Astro and Vite injected styles
#8696 2167ffd72 Thanks @matthewp! - Support adding integrations dynamically
Astro integrations can now themselves dynamically add and configure additional integrations during set-up. This makes it possible for integration authors to bundle integrations more intelligently for their users.
In the following example, a custom integration checks whether @astrojs/sitemap is already configured. If not, the integration adds Astro’s sitemap integration, passing any desired configuration options:
import sitemap from '@astrojs/sitemap';
import type { AstroIntegration } from 'astro';
const MyIntegration = (): AstroIntegration => {
return {
name: 'my-integration',
'astro:config:setup': ({ config, updateConfig }) => {
// Look for sitemap in user-configured integrations.
const userSitemap = config.integrations.find(
({ name }) => name === '@astrojs/sitemap'
);
if (!userSitemap) {
// If sitemap wasn’t found, add it.
updateConfig({
integrations: [sitemap({ /* opts */ }],
});
}
},
};
};
#8696 2167ffd72 Thanks @matthewp! - View transitions can now be triggered from JavaScript!
Import the client-side router from "astro:transitions/client" and enjoy your new remote control for navigation:
import { navigate } from 'astro:transitions/client';
// Navigate to the selected option automatically.
document.querySelector('select').onchange = (ev) => {
let href = ev.target.value;
navigate(href);
};
#8696 2167ffd72 Thanks @matthewp! - Route Announcer in <ViewTransitions />
The View Transitions router now does route announcement. When transitioning between pages with a traditional MPA approach, assistive technologies will announce the page title when the page finishes loading. This does not automatically happen during client-side routing, so visitors relying on these technologies to announce routes are not aware when a page has changed.
The view transitions route announcer runs after the astro:page-load event, looking for the page <title> to announce. If one cannot be found, the announcer falls back to the first <h1> it finds, or otherwise announces the pathname. We recommend you always include a <title> in each page for accessibility.
See the View Transitions docs for more on how accessibility is handled.
#8647 408b50c5e Thanks @lilnasy! - Fixed an issue where configured redirects with dynamic routes did not work in dev mode.
#8696 2167ffd72 Thanks @matthewp! - Fix logLevel passed to Vite build
#8696 2167ffd72 Thanks @matthewp! - Fix NoImageMetadata image path error message
#8670 e797b6816 Thanks @MichailiK! - Fix asset optimization failing when outDir is outside the project directory
#8684 824dd4670 Thanks @matthewp! - Support content collections with % in filename
#8648 cfd895d87 Thanks @lilnasy! - Fixed an issue where a response with status code 404 led to an endless loop of implicit rerouting in dev mode.
#8591 863f5171e Thanks @rishi-raj-jain! - add site url to the location of redirect
#8633 63141f3f3 Thanks @Princesseuh! - Fix build not working when having multiple images in the same Markdown file
#8636 974d5117a Thanks @martrapp! - fix: no deletion of scripts during view transition
#8645 cb838b84b Thanks @matthewp! - Fix getDataEntryById to lookup by basename
#8640 f36c4295b Thanks @matthewp! - Warn on empty content collections
#8615 4c4ad9d16 Thanks @alexanderniebuhr! - Improve the logging of assets for adapters that do not support image optimization
#8612 bcad715ce Thanks @matthewp! - Ensure cookies are attached when middleware changes the Response
#8598 bdd267d08 Thanks @Princesseuh! - Fix relative images in Markdown breaking the build process in certain circumstances
#8382 e522a5eb4 Thanks @DerTimonius! - Do not throw an error for an empty collection directory.
#8600 ed54d4644 Thanks @FredKSchott! - Improve config info telemetry
#8592 70f2a8003 Thanks @bluwy! - Fix alias plugin causing CSS ordering issue
#8614 4398e9298 Thanks @lilnasy! - Fixed an issue where spaces and unicode characters in project path prevented middleware from running.
#8603 8f8b9069d Thanks @matthewp! - Prevent body scripts from re-executing on navigation
#8609 5a988eaf6 Thanks @bluwy! - Fix Astro HMR from a CSS dependency
Updated dependencies [ed54d4644]:
#8580 8d361169b Thanks @rishi-raj-jain! - add hide to style & script generated for island
#8568 95b5f6280 Thanks @Princesseuh! - Fix small types issues related to astro:assets's AVIF support and getImage
#8579 0586e20e8 Thanks @rishi-raj-jain! - show redirect symbol as of the page
#8467 ecc65abbf Thanks @Princesseuh! - Add a new image.endpoint setting to allow using a custom endpoint in dev and SSR
#8518 2c4fc878b Thanks @Princesseuh! - Adds support for using AVIF (.avif) files with the Image component. Importing an AVIF file will now correctly return the same object shape as other image file types. See the Image docs for more information on the different properties available on the returned object.
#8464 c92e0acd7 Thanks @Princesseuh! - Add types for the object syntax for style (ex: style={{color: 'red'}})
#8532 7522bb491 Thanks @bluwy! - Improve markdown rendering performance by sharing processor instance
#8537 f95febf96 Thanks @martrapp! - bugfix checking media-type in client-side router
#8536 b85c8a78a Thanks @Princesseuh! - Improved error messages around astro:assets
#7607 45364c345 Thanks @FineWolf! - Add CollectionKey, ContentCollectionKey, and DataCollectionKey exports to astro:content
Updated dependencies [d93987824, 7522bb491]:
#8484 78b82bb39 Thanks @bb010g! - fix(astro): add support for src/content/config.mts files
#8504 5e1099f68 Thanks @ematipico! - Minify the HTML of the redirects emitted during the build.
#8480 644825845 Thanks @yamanoku! - Do not add type="text/css" to inline style tag
#8472 fa77fa63d Thanks @matthewp! - Prevent client:only styles from being removed in dev (View Transitions)
#8506 23f9536de Thanks @mascii! - chore: correct description of attribute option in scopedStyleStrategy
#8505 2db9762eb Thanks @martrapp! - Restore horizontal scroll position on history navigation (view transitions)
#8461 435b10549 Thanks @rdwz! - Fix lang unspecified code blocks (markdownlint MD040)
#8492 a6a516d94 Thanks @xiBread! - fix(types): make image.service optional
#8522 43bc5f2a5 Thanks @martrapp! - let view transitions handle same origin redirects
#8491 0ca332ba4 Thanks @martrapp! - Bugfixes for back navigation in the view transition client-side router
#8441 f66053a1e Thanks @martrapp! - Only transition between pages where both have ViewTransitions enabled
#8443 0fa483283 Thanks @the-dijkstra! - Fix "Cannot read properties of null" error in CLI code
Updated dependencies [f3f62a5a2]:
#8437 b3cf1b327 Thanks @Princesseuh! - Fix imports of images with uppercased file extensions not working
#8440 b92d066b7 Thanks @natemoo-re! - Fix issue where renderToFinalDestination would throw in internal Astro code
#8351 7d95bd9ba Thanks @lilnasy! - Fixed a case where dynamic imports tried to preload inlined stylesheets.
#8353 1947ef7a9 Thanks @elevatebart! - Astro will now skip asset optimization when there is a query in the import. Instead, it will let vite deal with it using plugins.
<script>
// This will not return an optimized asset
import Component from './Component.vue?component';
</script>
#8424 61ad70fdc Thanks @itsmatteomanf! - Fixes remote assets caching logic to not use expired assets
#8306 d2f2a11cd Thanks @jacobthesheep! - Support detecting Bun when logging messages with package manager information.
#8414 5126c6a40 Thanks @Princesseuh! - Fix missing type for imageConfig export from astro:assets
#8416 48ff7855b Thanks @Princesseuh! - Installing will no longer fail when Sharp can't be installed
#8332 8935b3b46 Thanks @martrapp! - Fix scroll position when navigating back from page w/o ViewTransitions
#8388 362491b8d Thanks @natemoo-re! - Properly handle BEFORE_HYDRATION_SCRIPT generation, fixing MIME type error on hydration.
#8370 06e7256b5 Thanks @itsmatteomanf! - Removed extra curly brace.
#8366 c5633434f Thanks @natemoo-re! - Update chunkFileNames to avoid emitting invalid characters
#8367 405ad9501 Thanks @Princesseuh! - Fix tsc complaining about imports of .astro files in specific cases
#8357 6b1e79814 Thanks @itsmatteomanf! - Added counter to show progress for assets image generation.
Fixed small unit of measurement error.
Updated dependencies [0ce0720c7]:
#8276 d3a6f9f83 Thanks @FredKSchott! - Sanitize route params for leading and trailing slashes
#8339 f21599671 Thanks @martrapp! - Respect the download attribute in links when using view transitions
#8327 5f3a44aee Thanks @natemoo-re! - Improve astro info command formatting, allow users to copy info automatically
#8320 b21038c19 Thanks @ematipico! - Exclude redirects from split entry points
#8331 7a894eec3 Thanks @matthewp! - Prevent View Transition fallback from waiting on looping animations
#8231 af41b03d0 Thanks @justinbeaty! - Fixes scroll behavior when using View Transitions by enabling manual scroll restoration
#8324 0752cf368 Thanks @matthewp! - Prevent React hook call warnings when used with MDX
When React and MDX are used in the same project, if the MDX integration is added before React, previously you'd get a warning about hook calls.
This makes it so that the MDX integration's JSX renderer is last in order.
d4a6ab733 Thanks @ematipico! - Correctly retrieve middleware when using it in SSR environments.d9bd7cf5c Thanks @Princesseuh! - Fix tsc errors inside astro/components/index.ts#8290 ef37f9e29 Thanks @matthewp! - Remove "experimental" text from the image config options, for docs and editor etc. text displayed.
#8290 ef37f9e29 Thanks @matthewp! - Prevent astro check cache issues
astro check hits cache issues in 3.0 causing it never to work on the first try.
#8283 c32f52a62 Thanks @ematipico! - Add useful warning when deprecated options are still used.
#8188 d0679a666 Thanks @ematipico! - Remove support for Node 16. The lowest supported version by Astro and all integrations is now v18.14.1. As a reminder, Node 16 will be deprecated on the 11th September 2023.
#8188 364d861bd Thanks @ematipico! - Removed automatic flattening of getStaticPaths result. .flatMap and .flat should now be used to ensure that you're returning a flat array.
#8113 2484dc408 Thanks @Princesseuh! - This import alias is no longer included by default with astro:assets. If you were using this alias with experimental assets, you must convert them to relative file paths, or create your own import aliases.
---
// src/pages/posts/post-1.astro
- import rocket from '~/assets/rocket.png'
+ import rocket from '../../assets/rocket.png';
---
#8142 81545197a Thanks @natemoo-re! - Fixes for the class:list directive
class:list would occasionally not be merged the class prop when passed to Astro components. Now, class:list is always converted to a class prop (as a string value).class:list diverged from clsx in a few edge cases. Now, class:list uses clsx directly.
class:list used to deduplicate matching values, but it no longer doesclass:list used to sort individual values, but it no longer doesclass:list used to support Set and other iterables, but it no longer does#8179 6011d52d3 Thanks @matthewp! - Astro 3.0 Release Candidate
#8188 80f1494cd Thanks @ematipico! - The build.split and build.excludeMiddleware configuration options are deprecated and have been replaced by options in the adapter config.
If your config includes the build.excludeMiddleware option, replace it with edgeMiddleware in your adapter options:
import { defineConfig } from "astro/config";
import netlify from "@astrojs/netlify/functions";
export default defineConfig({
build: {
- excludeMiddleware: true
},
adapter: netlify({
+ edgeMiddleware: true
}),
});
If your config includes the build.split option, replace it with functionPerRoute in your adapter options:
import { defineConfig } from "astro/config";
import netlify from "@astrojs/netlify/functions";
export default defineConfig({
build: {
- split: true
},
adapter: netlify({
+ functionPerRoute: true
}),
});
#8207 e45f30293 Thanks @natemoo-re! - Change the View Transition built-in animation options.
The transition:animate value morph has been renamed to initial. Also, this is no longer the default animation.
If no transition:animate directive is specified, your animations will now default to fade.
Astro also supports a new transition:animate value, none. This value can be used on a page's <html> element to disable animated full-page transitions on an entire page.
#8188 c0de7a7b0 Thanks @ematipico! - Sharp is now the default image service used for astro:assets. If you would prefer to still use Squoosh, you can update your config with the following:
import { defineConfig, squooshImageService } from 'astro/config';
// https://astro.build/config
export default defineConfig({
image: {
service: squooshImageService(),
},
});
However, not only do we recommend using Sharp as it is faster and more reliable, it is also highly likely that the Squoosh service will be removed in a future release.
#8188 3c3100851 Thanks @ematipico! - Remove support for Astro.__renderMarkdown which is used by @astrojs/markdown-component.
The <Markdown /> component was deprecated in Astro v1 and is completely removed in v3. This integration must now be removed from your project.
As an alternative, you can use community packages that provide a similar component like https://github.com/natemoo-re/astro-remote instead.
#8019 34cb20021 Thanks @bluwy! - Remove backwards-compatible kebab-case transform for camelCase CSS variable names passed to the style attribute. If you were relying on the kebab-case transform in your styles, make sure to use the camelCase version to prevent missing styles. For example:
---
const myValue = 'red';
---
<!-- input -->
<div style={{ '--myValue': myValue }}></div>
<!-- output (before) -->
<div style="--my-value:var(--myValue);--myValue:red"></div>
<!-- output (after) -->
<div style="--myValue:red"></div>
<style>
div {
- color: var(--my-value);
+ color: var(--myValue);
}
</style>
#8170 be6bbd2c8 Thanks @bluwy! - Remove deprecated config option types, deprecated script/style attributes, and deprecated image export from astro:content
#8188 7511a4980 Thanks @ematipico! - When using an adapter that supports neither Squoosh or Sharp, Astro will now automatically use an image service that does not support processing, but still provides the other benefits of astro:assets such as enforcing alt, no CLS etc to users
#7979 dbc97b121 Thanks @bluwy! - Export experimental dev, build, preview, and sync APIs from astro. These APIs allow you to run Astro's commands programmatically, and replaces the previous entry point that runs the Astro CLI.
While these APIs are experimental, the inline config parameter is relatively stable without foreseeable changes. However, the returned results of these APIs are more likely to change in the future.
import { dev, build, preview, sync, type AstroInlineConfig } from 'astro';
// Inline Astro config object.
// Provide a path to a configuration file to load or set options directly inline.
const inlineConfig: AstroInlineConfig = {
// Inline-specific options...
configFile: './astro.config.mjs',
logLevel: 'info',
// Standard Astro config options...
site: 'https://example.com',
};
// Start the Astro dev server
const devServer = await dev(inlineConfig);
await devServer.stop();
// Build your Astro project
await build(inlineConfig);
// Preview your built project
const previewServer = await preview(inlineConfig);
await previewServer.stop();
// Generate types for your Astro project
await sync(inlineConfig);
#8188 7d2f311d4 Thanks @ematipico! - Removed support for old syntax of the API routes.
#8085 68efd4a8b Thanks @bluwy! - Remove exports for astro/internal/* and astro/runtime/server/* in favour of astro/runtime/*. Add new astro/compiler-runtime export for compiler-specific runtime code.
These are exports for Astro's internal API and should not affect your project, but if you do use these entrypoints, you can migrate like below:
- import 'astro/internal/index.js';
+ import 'astro/runtime/server/index.js';
- import 'astro/server/index.js';
+ import 'astro/runtime/server/index.js';
import { transform } from '@astrojs/compiler';
const result = await transform(source, {
- internalURL: 'astro/runtime/server/index.js',
+ internalURL: 'astro/compiler-runtime',
// ...
});
#7893 7bd1b86f8 Thanks @ematipico! - Implements a new scope style strategy called "attribute". When enabled, styles are applied using data-* attributes.
The default value of scopedStyleStrategy is "attribute".
If you want to use the previous behaviour, you have to use the "where" option:
import { defineConfig } from 'astro/config';
export default defineConfig({
+ scopedStyleStrategy: 'where',
});
#7924 519a1c4e8 Thanks @matthewp! - Astro's JSX handling has been refactored with better support for each framework.
Previously, Astro automatically scanned your components to determine which framework-specific transformations should be used. In practice, supporting advanced features like Fast Refresh with this approach proved difficult.
Now, Astro determines which framework to use with include and exclude config options where you can specify files and folders on a per-framework basis. When using multiple JSX frameworks in the same project, users should manually control which files belong to each framework using the include and exclude options.
export default defineConfig({
// The `include` config is only needed in projects that use multiple JSX frameworks;
// if only using one no extra config is needed.
integrations: [
preact({
include: ['**/preact/*'],
}),
react({
include: ['**/react/*'],
}),
solid({
include: ['**/solid/*'],
}),
],
});
#8030 5208a3c8f Thanks @natemoo-re! - Removed duplicate astro/dist/jsx export. Please use the astro/jsx export instead
#8188 84af8ed9d Thanks @ematipico! - Remove MDX plugin re-ordering hack
#8180 f003e7364 Thanks @ematipico! - The scoped hash created by the Astro compiler is now lowercase.
#7878 0f637c71e Thanks @bluwy! - The value of import.meta.env.BASE_URL, which is derived from the base option, will no longer have a trailing slash added by default or when trailingSlash: "ignore" is set. The existing behavior of base in combination with trailingSlash: "always" or trailingSlash: "never" is unchanged.
If your base already has a trailing slash, no change is needed.
If your base does not have a trailing slash, add one to preserve the previous behaviour:
// astro.config.mjs
- base: 'my-base',
+ base: 'my-base/',
#8118 8a5b0c1f3 Thanks @lilnasy! - Astro is smarter about CSS! Small stylesheets are now inlined by default, and no longer incur the cost of additional requests to your server. Your visitors will have to wait less before they see your pages, especially those in remote locations or in a subway.
This may not be news to you if you had opted-in via the build.inlineStylesheets configuration. Stabilized in Astro 2.6 and set to "auto" by default for Starlight, this configuration allows you to reduce the number of requests for stylesheets by inlining them into <style> tags. The new default is "auto", which selects assets smaller than 4kB and includes them in the initial response.
To go back to the previous default behavior, change build.inlineStylesheets to "never".
import { defineConfig } from 'astro/config';
export default defineConfig({
build: {
inlineStylesheets: 'never',
},
});
#8188 148e61d24 Thanks @ematipico! - Reduced the amount of polyfills provided by Astro. Astro will no longer provide (no-op) polyfills for several web apis such as HTMLElement, Image or Document. If you need access to those APIs on the server, we recommend using more proper polyfills available on npm.
#8169 e79e3779d Thanks @bluwy! - Remove pre-shiki v0.14 theme names for compatibility. Please rename to the new theme names to migrate:
material-darker -> material-theme-darkermaterial-default -> material-themematerial-lighter -> material-theme-lightermaterial-ocean -> material-theme-oceanmaterial-palenight -> material-theme-palenight#8188 96beb883a Thanks @ematipico! - Update tsconfig.json presets with moduleResolution: 'bundler' and other new options from TypeScript 5.0. Astro now assumes that you use TypeScript 5.0 (March 2023), or that your editor includes it, ex: VS Code 1.77
#8188 997a0db8a Thanks @ematipico! - The astro check command now requires an external package @astrojs/check and an install of typescript in your project. This was done in order to make the main astro package smaller and give more flexibility to users in regard to the version of TypeScript they use.
#8188 80f1494cd Thanks @ematipico! - The build.split and build.excludeMiddleware configuration options are deprecated and have been replaced by options in the adapter config.
If your config includes the build.excludeMiddleware option, replace it with edgeMiddleware in your adapter options:
import { defineConfig } from "astro/config";
import vercel from "@astrojs/vercel/serverless";
export default defineConfig({
build: {
- excludeMiddleware: true
},
adapter: vercel({
+ edgeMiddleware: true
}),
});
If your config includes the build.split option, replace it with functionPerRoute in your adapter options:
import { defineConfig } from "astro/config";
import vercel from "@astrojs/vercel/serverless";
export default defineConfig({
build: {
- split: true
},
adapter: vercel({
+ functionPerRoute: true
}),
});
#8188 0f0625504 Thanks @ematipico! - Lowercase names for endpoint functions are now deprecated.
Rename functions to their uppercase equivalent:
- export function get() {
+ export function GET() {
return new Response(JSON.stringify({ "title": "Bob's blog" }));
}
- export function post() {
+ export function POST() {
return new Response(JSON.stringify({ "title": "Bob's blog" }));
}
- export function put() {
+ export function PUT() {
return new Response(JSON.stringify({ "title": "Bob's blog" }));
}
- export function all() {
+ export function ALL() {
return new Response(JSON.stringify({ "title": "Bob's blog" }));
}
// you can use the whole word "DELETE"
- export function del() {
+ export function DELETE() {
return new Response(JSON.stringify({ "title": "Bob's blog" }));
}
#8188 e1ae56e72 Thanks @ematipico! - Astro.cookies.get(key) returns undefined if cookie doesn't exist
With this change, Astro.cookies.get(key) no longer always returns a AstroCookie object. Instead it now returns undefined if the cookie does not exist.
You should update your code if you assume that all calls to get() return a value. When using with has() you still need to assert the value, like so:
---
if (Astro.cookies.has(id)) {
const id = Astro.cookies.get(id)!;
}
---
#8188 f32d093a2 Thanks @ematipico! - The property compressHTML is now true by default. Setting this value to true is no longer required.
If you do not want to minify your HTML output, you must set this value to false in astro.config.mjs.
import {defineConfig} from "astro/config";
export default defineConfig({
+ compressHTML: false
})
#8188 f01eb585e Thanks @ematipico! - Astro's default port when running the dev or preview server is now 4321.
This will reduce conflicts with ports used by other tools.
#7921 b76c166bd Thanks @Princesseuh! - astro:assets is now enabled by default. If you were previously using the experimental.assets flag, please remove it from your config. Also note that the previous @astrojs/image integration is incompatible, and must be removed.
This also brings two important changes to using images in Astro:
![]() syntax will now resolve relative images located anywhere in your project in addition to remote images and images stored in the public/ folder. This notably unlocks storing images next to your content.Please see our existing Assets page in Docs for more information about using astro:assets.
#8188 32669cd47 Thanks @ematipico! - Remove MDX special components export handling
#8188 cd2d7e769 Thanks @ematipico! - Introduced the concept of feature map. A feature map is a list of features that are built-in in Astro, and an Adapter
can tell Astro if it can support it.
import { AstroIntegration } from './astro';
function myIntegration(): AstroIntegration {
return {
name: 'astro-awesome-list',
// new feature map
supportedAstroFeatures: {
hybridOutput: 'experimental',
staticOutput: 'stable',
serverOutput: 'stable',
assets: {
supportKind: 'stable',
isSharpCompatible: false,
isSquooshCompatible: false,
},
},
};
}
#8218 44f7a2872 Thanks @matthewp! - View Transitions unflagged
View Transition support in Astro is now unflagged. For those who have used the experimental feature you can remove the flag in your Astro config:
import { defineConfig } from 'astro'
export default defineConfig({
- experimental: {
- viewTransitions: true,
- }
})
After removing this flag, please also consult the specific upgrade to v3.0 advice as some API features have changed and you may have breaking changes with your existing view transitions.
See the View Transitions guide to learn how to use the API.
#8101 ea7ff5177 Thanks @matthewp! - astro:namespace aliases for middleware and components
This adds aliases of astro:middleware and astro:components for the middleware and components modules. This is to make our documentation consistent between are various modules, where some are virtual modules and others are not. Going forward new built-in modules will use this namespace.
#8188 036388f66 Thanks @ematipico! - Integrations can now log messages using Astro’s built-in logger.
The logger is available to all hooks as an additional parameter:
import { AstroIntegration } from './astro';
// integration.js
export function myIntegration(): AstroIntegration {
return {
name: 'my-integration',
hooks: {
'astro:config:done': ({ logger }) => {
logger.info('Configure integration...');
},
},
};
}
#8181 a8f35777e Thanks @matthewp! - Finalize View Transition event names
#8012 866ed4098 Thanks @ematipico! - Add a new astro/errors module. Developers can import AstroUserError, and provide a message and an optional hint
#8139 db39206cb Thanks @Princesseuh! - Use undici for File changeset for Node 16 compatibility
#8188 adf9fccfd Thanks @ematipico! - Do not throw Error when users pass an object with a "type" property
#8234 0c7b42dc6 Thanks @natemoo-re! - Update telemetry notice
#8251 46c4c0e05 Thanks @Princesseuh! - Adds a link to the error reference in the CLI when an error occurs
#8128 c2c71d90c Thanks @Princesseuh! - Update error message when Sharp couldn't be found (tends to happen on pnpm notably)
#7998 65c354969 Thanks @bluwy! - Call astro sync once before calling astro check
#8232 a824863ab Thanks @matthewp! - Use .js to import logger
#8253 1048aca55 Thanks @matthewp! - Fix, lazily initialize ResponseWithEncoding
#8263 9e021a91c Thanks @Princesseuh! - Add a type param to AstroGlobal to type params. This will eventually be used automatically by our tooling to provide typing and completions for Astro.params
#8217 c37632a20 Thanks @martrapp! - Specify data-astro-reload (no value) on an anchor element to force the browser to ignore view transitions and fall back to default loading.
This is helpful when navigating to documents that have different content-types, e.g. application/pdf, where you want to use the build in viewer of the browser.
Example: <a href='/my.pdf' data-astro-reload>...</a>
#8156 acf652fc1 Thanks @kurtextrem! - The scrollend mechanism is a better way to record the scroll position compared to throttling, so we now use it whenever a browser supports it.
#8188 42785c7b7 Thanks @ematipico! - Improve fidelity of time stats when running astro build
#8266 8450379db Thanks @Princesseuh! - Fix image.service requiring to be set manually when image.domains or image.remotePatterns was assigned a value
#8078 2540feedb Thanks @alexanderniebuhr! - Reimplement https://github.com/withastro/astro/pull/7509 to correctly emit pre-rendered pages now that build.split is deprecated and this configuration has been moved to functionPerRoute inside the adapter.
#8264 1f58a7a1b Thanks @natemoo-re! - Fire astro:unmount event when island is disconnected
#8188 2ae9d37f0 Thanks @ematipico! - Open to configured base when astro dev --open runs
#8188 70f34f5a3 Thanks @ematipico! - Remove StreamingCompatibleResponse polyfill
#8229 ffc9e2d3d Thanks @Princesseuh! - Paginate will now return exact types instead of a naive Record
#8099 732111cdc Thanks @bluwy! - Deprecate the markdown.drafts configuration option.
If you'd like to create draft pages that are visible in dev but not in production, you can migrate to content collections and manually filter out pages with the draft: true frontmatter property instead.
#8188 33b8910cf Thanks @ematipico! - On back navigation only animate view transitions that were animated going forward.
#8196 632579dc2 Thanks @bluwy! - Prevent bundling sharp as it errors in runtime
#8237 3674584e0 Thanks @Princesseuh! - Fix astro check not finding the @astrojs/check package
#8258 1db4e92c1 Thanks @matthewp! - Allow fallback animations on html element
#8270 e7f872e91 Thanks @matthewp! - Prevent ViewTransition script from being added by mistake
#8271 16f09dfff Thanks @matthewp! - Fix video persistence regression
#8072 4477bb41c Thanks @matthewp! - Update Astro types to reflect that compress defaults to true
#8214 55c10d1d5 Thanks @Princesseuh! - Automatically update user's env.d.ts with the proper types to help out migrating away from assets being experimental
#8130 3e834293d Thanks @Princesseuh! - Add some polyfills for Stackblitz until they support Node 18. Running Astro on Node 16 is still not officially supported, however.
#8188 a87cbe400 Thanks @ematipico! - fix: reinsert attribute to specify direction of ViewTransition (forward / back)
#8132 767eb6866 Thanks @bluwy! - Deprecate returning simple objects from endpoints. Endpoints should only return a Response.
To return a result with a custom encoding not supported by a Response, you can use the ResponseWithEncoding utility class instead.
Before:
export function GET() {
return {
body: '...',
encoding: 'binary',
};
}
After:
export function GET({ ResponseWithEncoding }) {
return new ResponseWithEncoding('...', undefined, 'binary');
}
Updated dependencies [d0679a666, 2aa6d8ace, 0c7b42dc6, 6011d52d3, e79e3779d, 3e834293d, b675acb2a]:
#8266 8450379db Thanks @Princesseuh! - Fix image.service requiring to be set manually when image.domains or image.remotePatterns was assigned a value
#8270 e7f872e91 Thanks @matthewp! - Prevent ViewTransition script from being added by mistake
#8234 0c7b42dc6 Thanks @natemoo-re! - Update telemetry notice
#8263 9e021a91c Thanks @Princesseuh! - Add a type param to AstroGlobal to type params. This will eventually be used automatically by our tooling to provide typing and completions for Astro.params
#8264 1f58a7a1b Thanks @natemoo-re! - Fire astro:unmount event when island is disconnected
#8258 1db4e92c1 Thanks @matthewp! - Allow fallback animations on html element
Updated dependencies [0c7b42dc6]:
#8251 46c4c0e05 Thanks @Princesseuh! - Adds a link to the error reference in the CLI when an error occurs
#8253 1048aca55 Thanks @matthewp! - Fix, lazily initialize ResponseWithEncoding
#8229 ffc9e2d3d Thanks @Princesseuh! - Paginate will now return exact types instead of a naive Record
#8237 3674584e0 Thanks @Princesseuh! - Fix astro check not finding the @astrojs/check package
#8207 e45f30293 Thanks @natemoo-re! - Change the View Transition built-in animation options.
The transition:animate value morph has been renamed to initial. Also, this is no longer the default animation.
If no transition:animate directive is specified, your animations will now default to fade.
Astro also supports a new transition:animate value, none. This value can be used on a page's <html> element to disable animated full-page transitions on an entire page.
#8218 44f7a2872 Thanks @matthewp! - View Transitions unflagged
View Transition support in Astro is now unflagged. For those who have used the experimental feature you can remove the flag in your Astro config:
import { defineConfig } from 'astro'
export default defineConfig({
- experimental: {
- viewTransitions: true,
- }
})
After removing this flag, please also consult the specific upgrade to v3.0 advice as some API features have changed and you may have breaking changes with your existing view transitions.
See the View Transitions guide to learn how to use the API.
#8181 a8f35777e Thanks @matthewp! - Finalize View Transition event names
#8217 c37632a20 Thanks @martrapp! - Specify data-astro-reload (no value) on an anchor element to force the browser to ignore view transitions and fall back to default loading.
This is helpful when navigating to documents that have different content-types, e.g. application/pdf, where you want to use the build in viewer of the browser.
Example: <a href='/my.pdf' data-astro-reload>...</a>
#8156 acf652fc1 Thanks @kurtextrem! - The scrollend mechanism is a better way to record the scroll position compared to throttling, so we now use it whenever a browser supports it.
#8196 632579dc2 Thanks @bluwy! - Prevent bundling sharp as it errors in runtime
#8214 55c10d1d5 Thanks @Princesseuh! - Automatically update user's env.d.ts with the proper types to help out migrating away from assets being experimental
#8142 81545197a Thanks @natemoo-re! - Fixes for the class:list directive
class:list would occasionally not be merged the class prop when passed to Astro components. Now, class:list is always converted to a class prop (as a string value).class:list diverged from clsx in a few edge cases. Now, class:list uses clsx directly.
class:list used to deduplicate matching values, but it no longer doesclass:list used to sort individual values, but it no longer doesclass:list used to support Set and other iterables, but it no longer does#8179 6011d52d3 Thanks @matthewp! - Astro 3.0 Release Candidate
#8170 be6bbd2c8 Thanks @bluwy! - Remove deprecated config option types, deprecated script/style attributes, and deprecated image export from astro:content
#8180 f003e7364 Thanks @ematipico! - The scoped hash created by the Astro compiler is now lowercase.
#8169 e79e3779d Thanks @bluwy! - Remove pre-shiki v0.14 theme names for compatibility. Please rename to the new theme names to migrate:
material-darker -> material-theme-darkermaterial-default -> material-themematerial-lighter -> material-theme-lightermaterial-ocean -> material-theme-oceanmaterial-palenight -> material-theme-palenight#8147 adf9fccfd Thanks @astrobot-houston! - Do not throw Error when users pass an object with a "type" property
#8152 582132328 Thanks @andremralves! - Displays a new config error if outDir is placed within publicDir.
#8147 42785c7b7 Thanks @astrobot-houston! - Improve fidelity of time stats when running astro build
#8171 95120efbe Thanks @Princesseuh! - Fix missing type for imageConfig export from astro:assets
#8147 2ae9d37f0 Thanks @astrobot-houston! - Open to configured base when astro dev --open runs
#8099 732111cdc Thanks @bluwy! - Deprecate the markdown.drafts configuration option.
If you'd like to create draft pages that are visible in dev but not in production, you can migrate to content collections and manually filter out pages with the draft: true frontmatter property instead.
#8147 33b8910cf Thanks @astrobot-houston! - On back navigation only animate view transitions that were animated going forward.
#8163 179796405 Thanks @delucis! - Make typing of defineCollection more permissive to support advanced union and intersection types
#8147 a87cbe400 Thanks @astrobot-houston! - fix: reinsert attribute to specify direction of ViewTransition (forward / back)
#8132 767eb6866 Thanks @bluwy! - Deprecate returning simple objects from endpoints. Endpoints should only return a Response.
To return a result with a custom encoding not supported by a Response, you can use the ResponseWithEncoding utility class instead.
Before:
export function GET() {
return {
body: '...',
encoding: 'binary',
};
}
After:
export function GET({ ResponseWithEncoding }) {
return new ResponseWithEncoding('...', undefined, 'binary');
}
Updated dependencies [6011d52d3, e79e3779d]:
db39206cb Thanks @Princesseuh! - Use undici for File changeset for Node 16 compatibility#8113 2484dc408 Thanks @Princesseuh! - This import alias is no longer included by default with astro:assets. If you were using this alias with experimental assets, you must convert them to relative file paths, or create your own import aliases.
---
// src/pages/posts/post-1.astro
- import rocket from '~/assets/rocket.png'
+ import rocket from '../../assets/rocket.png';
---
#7979 dbc97b121 Thanks @bluwy! - Export experimental dev, build, preview, and sync APIs from astro. These APIs allow you to run Astro's commands programmatically, and replaces the previous entry point that runs the Astro CLI.
While these APIs are experimental, the inline config parameter is relatively stable without foreseeable changes. However, the returned results of these APIs are more likely to change in the future.
import { dev, build, preview, sync, type AstroInlineConfig } from 'astro';
// Inline Astro config object.
// Provide a path to a configuration file to load or set options directly inline.
const inlineConfig: AstroInlineConfig = {
// Inline-specific options...
configFile: './astro.config.mjs',
logLevel: 'info',
// Standard Astro config options...
site: 'https://example.com',
};
// Start the Astro dev server
const devServer = await dev(inlineConfig);
await devServer.stop();
// Build your Astro project
await build(inlineConfig);
// Preview your built project
const previewServer = await preview(inlineConfig);
await previewServer.stop();
// Generate types for your Astro project
await sync(inlineConfig);
#8085 68efd4a8b Thanks @bluwy! - Remove exports for astro/internal/* and astro/runtime/server/* in favour of astro/runtime/*. Add new astro/compiler-runtime export for compiler-specific runtime code.
These are exports for Astro's internal API and should not affect your project, but if you do use these entrypoints, you can migrate like below:
- import 'astro/internal/index.js';
+ import 'astro/runtime/server/index.js';
- import 'astro/server/index.js';
+ import 'astro/runtime/server/index.js';
import { transform } from '@astrojs/compiler';
const result = await transform(source, {
- internalURL: 'astro/runtime/server/index.js',
+ internalURL: 'astro/compiler-runtime',
// ...
});
#8030 5208a3c8f Thanks @natemoo-re! - Removed duplicate astro/dist/jsx export. Please use the astro/jsx export instead
#8118 8a5b0c1f3 Thanks @lilnasy! - Astro is smarter about CSS! Small stylesheets are now inlined by default, and no longer incur the cost of additional requests to your server. Your visitors will have to wait less before they see your pages, especially those in remote locations or in a subway.
This may not be news to you if you had opted-in via the build.inlineStylesheets configuration. Stabilized in Astro 2.6 and set to "auto" by default for Starlight, this configuration allows you to reduce the number of requests for stylesheets by inlining them into <style> tags. The new default is "auto", which selects assets smaller than 4kB and includes them in the initial response.
To go back to the previous default behavior, change build.inlineStylesheets to "never".
import { defineConfig } from 'astro/config';
export default defineConfig({
build: {
inlineStylesheets: 'never',
},
});
#7921 b76c166bd Thanks @Princesseuh! - astro:assets is now enabled by default. If you were previously using the experimental.assets flag, please remove it from your config. Also note that the previous @astrojs/image integration is incompatible, and must be removed.
This also brings two important changes to using images in Astro:
![]() syntax will now resolve relative images located anywhere in your project in addition to remote images and images stored in the public/ folder. This notably unlocks storing images next to your content.Please see our existing Assets page in Docs for more information about using astro:assets.
#8101 ea7ff5177 Thanks @matthewp! - astro:namespace aliases for middleware and components
This adds aliases of astro:middleware and astro:components for the middleware and components modules. This is to make our documentation consistent between are various modules, where some are virtual modules and others are not. Going forward new built-in modules will use this namespace.
#8128 c2c71d90c Thanks @Princesseuh! - Update error message when Sharp couldn't be found (tends to happen on pnpm notably)
#8092 7177f7579 Thanks @natemoo-re! - Ensure dotfiles are cleaned during static builds
#8070 097a8e4e9 Thanks @lilnasy! - Fix a handful of edge cases with prerendered 404/500 pages
#8078 2540feedb Thanks @alexanderniebuhr! - Reimplement https://github.com/withastro/astro/pull/7509 to correctly emit pre-rendered pages now that build.split is deprecated and this configuration has been moved to functionPerRoute inside the adapter.
#8105 0e0fa605d Thanks @martrapp! - ViewTransition: bug fix for lost scroll position in browser history
#7778 d6b494376 Thanks @y-nk! - Added support for optimizing remote images from authorized sources when using astro:assets. This comes with two new parameters to specify which domains (image.domains) and host patterns (image.remotePatterns) are authorized for remote images.
For example, the following configuration will only allow remote images from astro.build to be optimized:
// astro.config.mjs
export default defineConfig({
image: {
domains: ['astro.build'],
},
});
The following configuration will only allow remote images from HTTPS hosts:
// astro.config.mjs
export default defineConfig({
image: {
remotePatterns: [{ protocol: 'https' }],
},
});
#8072 4477bb41c Thanks @matthewp! - Update Astro types to reflect that compress defaults to true
#8130 3e834293d Thanks @Princesseuh! - Add some polyfills for Stackblitz until they support Node 18. Running Astro on Node 16 is still not officially supported, however.
Updated dependencies [3e834293d]:
2aa6d8ace]:
#7952 3c3100851 Thanks @astrobot-houston! - Remove support for Astro.__renderMarkdown which is used by @astrojs/markdown-component.
The <Markdown /> component was deprecated in Astro v1 and is completely removed in v3. This integration must now be removed from your project.
As an alternative, you can use community packages that provide a similar component like https://github.com/natemoo-re/astro-remote instead.
#8019 34cb20021 Thanks @bluwy! - Remove backwards-compatible kebab-case transform for camelCase CSS variable names passed to the style attribute. If you were relying on the kebab-case transform in your styles, make sure to use the camelCase version to prevent missing styles. For example:
---
const myValue = 'red';
---
<!-- input -->
<div style={{ '--myValue': myValue }}></div>
<!-- output (before) -->
<div style="--my-value:var(--myValue);--myValue:red"></div>
<!-- output (after) -->
<div style="--myValue:red"></div>
<style>
div {
- color: var(--my-value);
+ color: var(--myValue);
}
</style>
#7893 7bd1b86f8 Thanks @ematipico! - Implements a new scope style strategy called "attribute". When enabled, styles are applied using data-* attributes.
The default value of scopedStyleStrategy is "attribute".
If you want to use the previous behaviour, you have to use the "where" option:
import { defineConfig } from 'astro/config';
export default defineConfig({
+ scopedStyleStrategy: 'where',
});
#7924 519a1c4e8 Thanks @matthewp! - Astro's JSX handling has been refactored with better support for each framework.
Previously, Astro automatically scanned your components to determine which framework-specific transformations should be used. In practice, supporting advanced features like Fast Refresh with this approach proved difficult.
Now, Astro determines which framework to use with include and exclude config options where you can specify files and folders on a per-framework basis. When using multiple JSX frameworks in the same project, users should manually control which files belong to each framework using the include and exclude options.
export default defineConfig({
// The `include` config is only needed in projects that use multiple JSX frameworks;
// if only using one no extra config is needed.
integrations: [
preact({
include: ['**/preact/*'],
}),
react({
include: ['**/react/*'],
}),
solid({
include: ['**/solid/*'],
}),
],
});
#7878 0f637c71e Thanks @bluwy! - The value of import.meta.env.BASE_URL, which is derived from the base option, will no longer have a trailing slash added by default or when trailingSlash: "ignore" is set. The existing behavior of base in combination with trailingSlash: "always" or trailingSlash: "never" is unchanged.
If your base already has a trailing slash, no change is needed.
If your base does not have a trailing slash, add one to preserve the previous behaviour:
// astro.config.mjs
- base: 'my-base',
+ base: 'my-base/',
866ed4098 Thanks @ematipico! - Add a new astro/errors module. Developers can import AstroUserError, and provide a message and an optional hint#7998 65c354969 Thanks @bluwy! - Call astro sync once before calling astro check
#7952 70f34f5a3 Thanks @astrobot-houston! - Remove StreamingCompatibleResponse polyfill
#8011 5b1e39ef6 Thanks @bluwy! - Move hoisted script analysis optimization behind the experimental.optimizeHoistedScript option
Updated dependencies [b675acb2a]:
1eae2e3f7 Thanks @Princesseuh! - Remove support for Node 16. The lowest supported version by Astro and all integrations is now v18.14.1. As a reminder, Node 16 will be deprecated on the 11th September 2023.
76ddef19c Thanks @Princesseuh! - Removed automatic flattening of getStaticPaths result. .flatMap and .flat should now be used to ensure that you're returning a flat array.
3fdf509b2 Thanks @ematipico! - The build.split and build.excludeMiddleware configuration options are deprecated and have been replaced by options in the adapter config.
If your config includes the build.excludeMiddleware option, replace it with edgeMiddleware in your adapter options:
import { defineConfig } from "astro/config";
import netlify from "@astrojs/netlify/functions";
export default defineConfig({
build: {
- excludeMiddleware: true
},
adapter: netlify({
+ edgeMiddleware: true
}),
});
If your config includes the build.split option, replace it with functionPerRoute in your adapter options:
import { defineConfig } from "astro/config";
import netlify from "@astrojs/netlify/functions";
export default defineConfig({
build: {
- split: true
},
adapter: netlify({
+ functionPerRoute: true
}),
});
2f951cd40 Thanks @Princesseuh! - Sharp is now the default image service used for astro:assets. If you would prefer to still use Squoosh, you can update your config with the following:
import { defineConfig, squooshImageService } from 'astro/config';
// https://astro.build/config
export default defineConfig({
image: {
service: squooshImageService(),
},
});
However, not only do we recommend using Sharp as it is faster and more reliable, it is also highly likely that the Squoosh service will be removed in a future release.
c022a4217 Thanks @Princesseuh! - When using an adapter that supports neither Squoosh or Sharp, Astro will now automatically use an image service that does not support processing, but still provides the other benefits of astro:assets such as enforcing alt, no CLS etc to users
67becaa58 Thanks @ematipico! - Removed support for old syntax of the API routes.
dfc2d93e3 Thanks @bluwy! - Remove MDX plugin re-ordering hack
3dc1ca2fa Thanks @Princesseuh! - Reduced the amount of polyfills provided by Astro. Astro will no longer provide (no-op) polyfills for several web apis such as HTMLElement, Image or Document. If you need access to those APIs on the server, we recommend using more proper polyfills available on npm.
1be84dfee Thanks @Princesseuh! - Update tsconfig.json presets with moduleResolution: 'bundler' and other new options from TypeScript 5.0. Astro now assumes that you use TypeScript 5.0 (March 2023), or that your editor includes it, ex: VS Code 1.77
35f01df79 Thanks @Princesseuh! - The astro check command now requires an external package @astrojs/check and an install of typescript in your project. This was done in order to make the main astro package smaller and give more flexibility to users in regard to the version of TypeScript they use.
3fdf509b2 Thanks @ematipico! - The build.split and build.excludeMiddleware configuration options are deprecated and have been replaced by options in the adapter config.
If your config includes the build.excludeMiddleware option, replace it with edgeMiddleware in your adapter options:
import { defineConfig } from "astro/config";
import vercel from "@astrojs/vercel/serverless";
export default defineConfig({
build: {
- excludeMiddleware: true
},
adapter: vercel({
+ edgeMiddleware: true
}),
});
If your config includes the build.split option, replace it with functionPerRoute in your adapter options:
import { defineConfig } from "astro/config";
import vercel from "@astrojs/vercel/serverless";
export default defineConfig({
build: {
- split: true
},
adapter: vercel({
+ functionPerRoute: true
}),
});
78de801f2 Thanks @ematipico! - Lowercase names for endpoint functions are now deprecated.
Rename functions to their uppercase equivalent:
- export function get() {
+ export function GET() {
return new Response(JSON.stringify({ "title": "Bob's blog" }));
}
- export function post() {
+ export function POST() {
return new Response(JSON.stringify({ "title": "Bob's blog" }));
}
- export function put() {
+ export function PUT() {
return new Response(JSON.stringify({ "title": "Bob's blog" }));
}
- export function all() {
+ export function ALL() {
return new Response(JSON.stringify({ "title": "Bob's blog" }));
}
// you can use the whole word "DELETE"
- export function del() {
+ export function DELETE() {
return new Response(JSON.stringify({ "title": "Bob's blog" }));
}
59d6e569f Thanks @matthewp! - Astro.cookies.get(key) returns undefined if cookie doesn't exist
With this change, Astro.cookies.get(key) no longer always returns a AstroCookie object. Instead it now returns undefined if the cookie does not exist.
You should update your code if you assume that all calls to get() return a value. When using with has() you still need to assert the value, like so:
---
if (Astro.cookies.has(id)) {
const id = Astro.cookies.get(id)!;
}
---
7723c4cc9 Thanks @ematipico! - The property compressHTML is now true by default. Setting this value to true is no longer required.
If you do not want to minify your HTML output, you must set this value to false in astro.config.mjs.
import {defineConfig} from "astro/config";
export default defineConfig({
+ compressHTML: false
})
fb5cd6b56 Thanks @ematipico! - Astro's default port when running the dev or preview server is now 4321.
This will reduce conflicts with ports used by other tools.
631b9c410 Thanks @bluwy! - Remove MDX special components export handling
9b4f70a62 Thanks @ematipico! - Introduced the concept of feature map. A feature map is a list of features that are built-in in Astro, and an Adapter
can tell Astro if it can support it.
import { AstroIntegration } from './astro';
function myIntegration(): AstroIntegration {
return {
name: 'astro-awesome-list',
// new feature map
supportedAstroFeatures: {
hybridOutput: 'experimental',
staticOutput: 'stable',
serverOutput: 'stable',
assets: {
supportKind: 'stable',
isSharpCompatible: false,
isSquooshCompatible: false,
},
},
};
}
bc37331d8 Thanks @ematipico! - Integrations can now log messages using Astro’s built-in logger.
The logger is available to all hooks as an additional parameter:
import { AstroIntegration } from './astro';
// integration.js
export function myIntegration(): AstroIntegration {
return {
name: 'my-integration',
hooks: {
'astro:config:done': ({ logger }) => {
logger.info('Configure integration...');
},
},
};
}
1eae2e3f7]: