Compare Versions - astro
npm / astro / Compare Versions
Patch Changes
-
#15978
6d182feThanks @seroperson! - Fixes a bug where Astro Actions didn't properly support nested object properties, causing problems when users used zod functions such assuperRefineordiscriminatedUnion. -
#16011
e752170Thanks @matthewp! - Fixes a dev server hang on the first request when using the Cloudflare adapter -
#15997
1fddff7Thanks @ematipico! - FixesAstro.rewrite()failing when the target path contains duplicate slashes (e.g.//about). The duplicate slashes are now collapsed before URL parsing, preventing them from being interpreted as a protocol-relative URL.
Patch Changes
-
#15950
acce5e8Thanks @matthewp! - Fixes a build regression in projects with multiple frontend integrations whereserver:deferserver islands could fail at runtime when all pages are prerendered. -
#15988
c93b4a0Thanks @ossaidqadri! - Fix styles from dynamically imported components not being injected on first dev server load. -
#15968
3e7a9d5Thanks @chasemccoy! - FixesrenderMarkdownin custom content loaders not resolving images in markdown content. Images referenced in markdown processed byrenderMarkdownare now correctly optimized, matching the behavior of the built-inglob()loader. -
#15990
1e6017fThanks @ematipico! - Fixes an issue whereAstro.currentLocalewould always be the default locale instead of the actual one when using a dynamic route like[locale].astroor[locale]/index.astro. It now resolves to the correct locale from the URL. -
#15990
1e6017fThanks @ematipico! - Fixes an issue where visiting an invalid locale URL (e.g./asdf/) would show the content of a dynamic[locale]page with a 404 status code, instead of showing your custom 404 page. Now, the correct 404 page is rendered when the locale in the URL doesn't match any configured locale. -
#15960
1d84020Thanks @matthewp! - Fixes Cloudflare dev server islands withprerenderEnvironment: 'node'by sharing the serialized manifest encryption key across dev environments and routing server island requests through the SSR runtime. -
#15735
9685e2dThanks @fa-sharp! - Fixes an EventEmitter memory leak when serving static pages from Node.js middleware.When using the middleware handler, requests that were being passed on to Express / Fastify (e.g. static files / pre-rendered pages / etc.) weren't cleaning up socket listeners before calling
next(), causing a memory leak warning. This fix makes sure to run the cleanup before callingnext().
Patch Changes
-
#15965
2dca307Thanks @matthewp! - Fixes client hydration for components imported through Node.js subpath imports (package.json#imports, e.g.#components/*), for example when using the Cloudflare adapter in development. -
#15770
6102ca2Thanks @jpc-ae! - Updates thecreate astrowelcome message to highlight the graceful dev/preview server quit command rather than the kill process shortcut -
#15953
7eddf22Thanks @Desel72! - fix(hmr): eagerly recompile on style-only change to prevent stale slots render -
#15916
5201ed4Thanks @trueberryless! - FixesInferLoaderSchematype inference for content collections defined with a loader that includes aschema -
#15864
d3c7de9Thanks @florian-lefebvre! - Removes temporary support for Node >=20.19.1 because Stackblitz now uses Node 22 by default -
#15944
a5e1acdThanks @fkatsuhiro! - Fixes SSR dynamic routes with.htmlextension (e.g.[slug].html.astro) not working -
#15937
d236245Thanks @ematipico! - Fixes an issue where HMR didn't correctly work on Windows when adding/changing/deleting routes inpages/. -
#15931
98dfb61Thanks @Strernd! - Fix skew protection query params not being applied to island hydrationcomponent-urlandrenderer-url, and ensure query params are appended safely for asset URLs with existing search/hash parts. -
Updated dependencies []:
- @astrojs/markdown-remark@7.0.1
Patch Changes
-
#15891
b889231Thanks @matthewp! - Fix dev routing forserver:deferislands when adapters opt into handling prerendered routes in Astro core. Server island requests are now treated as prerender-handler eligible so prerendered pages usingprerenderEnvironment: 'node'can load island content without400errors. -
#15890
765a887Thanks @matthewp! - Fixesastro:actionsvalidation to check resolved routes, so projects using default static output with at least oneprerender = falsepage or endpoint no longer fail during startup. -
#15884
dcd2c8eThanks @matthewp! - Avoid aMaxListenersExceededWarningduringastro devstartup by increasing the shared Vite watcher listener limit when attaching content server listeners. -
#15904
23d5244Thanks @jlukic! - Emit thebefore-hydrationscript chunk for theclientVite environment. The chunk was only emitted forprerenderandssrenvironments, causing a 404 when browsers tried to load it. This broke hydration for any integration usinginjectScript('before-hydration', ...), including Lit SSR. -
#15933
325901eThanks @ematipico! - Fixes an issue where<style>tags inside SVG components weren't correctly tracked when enabling CSP. -
#15875
c43ef8aThanks @matthewp! - Ensure custom prerenderers are always torn down during build, even whengetStaticPaths()throws. -
#15887
1861fedThanks @ematipico! - Fixes an issue where the build incorrectly leaked server entrypoint into the client environment, causing adapters to emit warnings during the build. -
#15888
925252eThanks @matthewp! - Fix a bug whereserver:defercould fail at runtime in prerendered pages for some adapters (including Cloudflare), causing errors likeserverIslandMap?.get is not a function. -
#15901
07c1002Thanks @delucis! - Fixes JSON schema generation for content collection schemas that have differences between their input and output shapes. -
#15882
759f946Thanks @matthewp! - FixAstro.url.pathnamefor the root page when usingbuild.format: "file"so it resolves to/index.htmlinstead of/.htmlduring builds.
Patch Changes
-
#15870
920f10bThanks @matthewp! - Prebundleastro/toolbarin dev when custom dev toolbar apps are registered, preventing re-optimization reloads that can hide or break the toolbar. -
#15876
f47ac53Thanks @ematipico! - FixesredirectToDefaultLocaleproducing a protocol-relative URL (//locale) instead of an absolute path (/locale) whenbaseis'/'. -
#15767
e0042f7Thanks @matthewp! - Fixes server islands (server:defer) not working when only used in prerendered pages withoutput: 'server'. -
#15873
35841edThanks @matthewp! - Fix a dev server bug where newly created pages could miss layout-imported CSS until restart. -
#15874
ce0669dThanks @ematipico! - Fixes a warning when usingprefetchAll -
#15754
58f1d63Thanks @rururux! - Fixes a bug where a directory at the project root sharing the same name as a page route would cause the dev server to return a 404 instead of serving the page. -
#15869
76b3a5eThanks @matthewp! - Update the unknown file extension error hint to recommendvite.resolve.noExternal, which is the correct Vite 7 config key.
Patch Changes
-
#15711
b2bd27bThanks @OliverSpeir! - Improves Astro core's dev environment handling for prerendered routes by ensuring route/CSS updates and prerender middleware behavior work correctly across both SSR and prerender environments.This enables integrations that use Astro's prerender dev environment (such as Cloudflare with
prerenderEnvironment: 'node') to get consistent route matching and HMR behavior during development. -
#15852
1cdaf9fThanks @ematipico! - Fixes a regression where the the routes emitted by theastro:build:donehook didn't have thedistURLarray correctly populated. -
#15765
ca76ff1Thanks @matthewp! - Hardens server island POST endpoint validation to use own-property checks for improved consistency
Patch Changes
- #15832
95e12a2Thanks @Princesseuh! - Fixesreturn;syntax not working in the frontmatter correctly in certain contexts
Major Changes
-
#14446
ece667aThanks @florian-lefebvre! - RemovesentryPointsonastro:build:ssrhook (Integration API) - (v6 upgrade guidance) -
#15535
dfe2e22Thanks @florian-lefebvre! - DeprecatesloadManifest()andloadApp()fromastro/app/node(Adapter API) - (v6 upgrade guidance) -
#15006
f361730Thanks @florian-lefebvre! - Removes sessiontestdriver - (v6 upgrade guidance) -
#15461
9f21b24Thanks @florian-lefebvre! - BREAKING CHANGE to the v6 beta Adapter API only: renamesentryTypetoentrypointResolutionand updates possible valuesAstro 6 introduced a way to let adapters have more control over the entrypoint by passing
entryType: 'self'tosetAdapter(). However during beta development, the name was unclear and confusing.entryTypeis now renamed toentrypointResolutionand its possible values are updated:legacy-dynamicbecomesexplicit.selfbecomesauto.
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
861b9ccThanks @florian-lefebvre! - Removes the deprecatedemitESMImage()function - (v6 upgrade guidance) -
#15006
f361730Thanks @florian-lefebvre! - Deprecates session driver string signature - (v6 upgrade guidance) -
#15180
8780ff2Thanks @Princesseuh! - Adds support for converting SVGs to raster images (PNGs, WebP, etc) to the default Sharp image service - (v6 upgrade guidance) -
#14446
ece667aThanks @florian-lefebvre! - Removesroutesonastro:build:donehook (Integration API) - (v6 upgrade guidance) -
#15424
33d6146Thanks @Princesseuh! - Throws an error whengetImage()fromastro:assetsis called on the client - (v6 upgrade guidance) -
#14462
9fdfd4cThanks @florian-lefebvre! - Removes the oldapp.render()signature (Adapter API) - (v6 upgrade guidance) -
#14956
0ff51dfThanks @matthewp! - Astro v6.0 upgrades to Zod v4 for schema validation - (v6 upgrade guidance) -
#14759
d7889f7Thanks @florian-lefebvre! - Updates how schema types are inferred for content loaders with schemas (Loader API) - (v6 upgrade guidance) -
#15192
ada2808Thanks @gameroman! - Removes support for CommonJS config files - (v6 upgrade guidance) -
#14462
9fdfd4cThanks @florian-lefebvre! - Removesprefetch()withoption - (v6 upgrade guidance) -
#14306
141c4a2Thanks @ematipico! - Removes support for routes with percent-encoded percent signs (e.g.%25) - (v6 upgrade guidance) -
#14432
b1d87ecThanks @florian-lefebvre! - DeprecatesAstroingetStaticPaths()- (v6 upgrade guidance) -
#14759
d7889f7Thanks @florian-lefebvre! - Removes the option to define dynamic schemas in content loaders as functions and adds a new equivalentcreateSchema()property (Loader API) - (v6 upgrade guidance) -
#14457
049da87Thanks @florian-lefebvre! - Updates trailing slash behavior of endpoint URLs - (v6 upgrade guidance) -
#14494
727b0a2Thanks @florian-lefebvre! - Updates Markdown heading ID generation - (v6 upgrade guidance) -
#14461
55a1a91Thanks @florian-lefebvre! - Deprecatesimport.meta.env.ASSETS_PREFIX- (v6 upgrade guidance) -
#14586
669ca5bThanks @ocavue! - Changes the values allowed inparamsreturned bygetStaticPaths()- (v6 upgrade guidance) -
#15668
1118ac4Thanks @florian-lefebvre! - Changes TypeScript configuration - (v6 upgrade guidance) -
#14421
df6d2d7Thanks @florian-lefebvre! - Removes the previously deprecatedAstro.glob()- (v6 upgrade guidance) -
#15049
beddfebThanks @Ntale3! - Removes the ability to render Astro components in Vitest client environments - (v6 upgrade guidance) -
#15461
9f21b24Thanks @florian-lefebvre! - DeprecatescreateExports()andstart()(Adapter API) - (v6 upgrade guidance) -
#15535
dfe2e22Thanks @florian-lefebvre! - DeprecatesNodeAppfromastro/app/node(Adapter API) - (v6 upgrade guidance) -
#14462
9fdfd4cThanks @florian-lefebvre! - Removes thehandleFormsprop for the<ClientRouter />component - (v6 upgrade guidance) -
#14427
e131261Thanks @florian-lefebvre! - Increases minimum Node.js version to 22.12.0 - (v6 upgrade guidance) -
#15332
7c55f80Thanks @matthewp! - Adds frontmatter parsing support torenderMarkdownin content loaders. When markdown content includes frontmatter, it is now extracted and available inmetadata.frontmatter, and excluded from the HTML output. This makesrenderMarkdownbehave consistently with theglobloader.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
c69c7deThanks @ellielok! - Removes the deprecated<ViewTransitions />component - (v6 upgrade guidance) -
#14306
141c4a2Thanks @ematipico! - RemovesRouteData.generatefrom the Integration API - (v6 upgrade guidance) -
#14406
4f11510Thanks @florian-lefebvre! - Changes the default routing configuration value ofi18n.routing.redirectToDefaultLocalefromtruetofalse- (v6 upgrade guidance) -
#14989
73e8232Thanks @florian-lefebvre! - Deprecates exposedastro:transitionsinternals - (v6 upgrade guidance) -
#15726
6f19eccThanks @ocavue! - Updates dependencyshikito v4Check Shiki's upgrade guide.
-
#14758
010f773Thanks @florian-lefebvre! - Removes thesetManifestDatamethod fromAppandNodeApp(Adapter API) - (v6 upgrade guidance) -
#14477
25fe093Thanks @florian-lefebvre! - Removesrewrite()from Actions context - (v6 upgrade guidance) -
#14826
170f64eThanks @florian-lefebvre! - Removes theexperimental.failOnPrerenderConflictflag and replaces it with a new configuration optionprerenderConflictBehavior- (v6 upgrade guidance) -
#14923
95a1969Thanks @florian-lefebvre! - Deprecatesastro:schemaandzfromastro:contentin favor ofastro/zod- (v6 upgrade guidance) -
#14844
8d43b1dThanks @trueberryless! - Removes exposedastro:actionsinternals - (v6 upgrade guidance) -
#14306
141c4a2Thanks @ematipico! - Changes the shape ofSSRManifestproperties and adds several new required properties in the Adapter API - (v6 upgrade guidance) -
#15266
f7c9365Thanks @florian-lefebvre! - AllowsAstro.cspandcontext.cspto be undefined instead of throwing errors whencsp: trueis not configuredWhen using the experimental Content Security Policy feature in Astro 5.x,
context.cspwas always defined but would throw ifexperimental.cspwas not enabled in the Astro config.For the stable version of this API in Astro 6,
context.cspcan now be undefined if CSP is not enabled and its methods will never throw.What should I do?
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
ecb0b98Thanks @florian-lefebvre! - Astro v6.0 upgrades to Vite v7.0 as the development server and production bundler - (v6 upgrade guidance) -
#15407
aedbbd8Thanks @ematipico! - Changes how styles of responsive images are emitted - (v6 upgrade guidance) -
#14306
141c4a2Thanks @ematipico! - Changes integration hooks and HMR access patterns in the Integration API - (v6 upgrade guidance) -
#14306
141c4a2Thanks @ematipico! - Removes the unusedastro:ssr-manifestvirtual module - (v6 upgrade guidance) -
#14485
6f67c6eThanks @florian-lefebvre! - Updatesimport.meta.envvalues to always be inlined - (v6 upgrade guidance) -
#14480
36a461bThanks @florian-lefebvre! - Updates<script>and<style>tags to render in the order they are defined - (v6 upgrade guidance) -
#14407
3bda3ceThanks @ascorbic! - Removes legacy content collection support - (v6 upgrade guidance)
Minor Changes
-
#14306
141c4a2Thanks @ematipico! - Adds new optional properties tosetAdapter()for adapter entrypoint handling in the Adapter APIChanges:
- New optional properties:
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.
- New optional properties:
-
#15700
4e7f3e8Thanks @ocavue! - Updates the internal logic during SSR by providing additional metadata for UI framework integrations. -
#15231
3928b87Thanks @rururux! - Adds a new optionalgetRemoteSize()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 extendsinferRemoteSize(), you can now override or extend how remote image metadata is retrieved.This enables use cases such as:
- Caching: Storing image dimensions in a database or local cache to avoid redundant network requests.
- Provider APIs: Using a specific image provider's API (like Cloudinary or Vercel) to get dimensions without downloading the file.
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
a164c77Thanks @matthewp! - Updates the Integration API to addsetPrerenderer()to theastro:build:starthook, allowing adapters to provide custom prerendering logic.The new API accepts either an
AstroPrerendererobject 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-pathsvirtual module, which exports aStaticPathsclass 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
840fbf9Thanks @matthewp! - Adds a newemitClientAssetfunction toastro/assets/utilsfor 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 hook const handle = emitClientAsset(this, { type: 'asset', name: 'my-image.png', source: imageBuffer, }); -
#15460
ee7e53fThanks @florian-lefebvre! - Updates the Adapter API to allow providing aserverEntrypointwhen usingentryType: 'self'Astro 6 introduced a new powerful yet simple Adapter API for defining custom server entrypoints. You can now call
setAdapter()with theentryType: 'self'option and specify your customserverEntrypoint: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
serverEntrypointand instead specify your custom server entrypoint withvite.build.rollupOptions.input. -
#15781
2de969dThanks @ematipico! - Adds a newclientAddressoption to thecreateContext()functionProviding this value gives adapter and middleware authors explicit control over the client IP address. When not provided, accessing
clientAddressthrows 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
d339a18Thanks @ematipico! - Stabilizes the adapter featureexperimentalStatiHeaders. 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
dfe2e22Thanks @florian-lefebvre! - Exports newcreateRequest()andwriteResponse()utilities fromastro/app/nodeTo replace the deprecated
NodeApp.createRequest()andNodeApp.writeResponse()methods, theastro/app/nodemodule now exposes newcreateRequest()andwriteResponse()utilities. These can be used to convert a NodeJSIncomingMessageinto a web-standardRequestand stream a web-standardResponseinto a NodeJSServerResponse: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
f9ee868Thanks @matthewp! - Adds a newsecurity.serverIslandBodySizeLimitconfiguration optionServer island POST endpoints now enforce a body size limit, similar to the existing
security.actionBodySizeLimitfor Actions. The new option defaults to1048576(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
a509941Thanks @florian-lefebvre! - Adds a new build-in font providernpmto access fonts installed as NPM packagesYou can now add web fonts specified in your
package.jsonthrough Astro's type-safe Fonts API. Thenpmfont provider allows you to add fonts either from locally installed packages innode_modulesor from a CDN.Set
fontProviders.npm()as your fonts provider along with the requirednameandcssVariablevalues, and addoptionsas 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
32b4302Thanks @ematipico! - Adds a new experimental flagqueuedRenderingto enable a queue-based rendering engineThe 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.
Queue-rendered based
The new engine can be enabled in your Astro config with
experimental.queuedRendering.enabledset totrue, and can be further customized with additional sub-features.// astro.config.mjs export default defineConfig({ experimental: { queuedRendering: { enabled: true, }, }, });Pooling
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.
// astro.config.mjs export default defineConfig({ experimental: { queuedRendering: { enabled: true, poolSize: 2000, // store up to 2k nodes to be reused across renderers }, }, });Content caching
The new engine additionally unlocks a new
contentCacheoption. 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.
// astro.config.mjs 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
4cd3fe4Thanks @OliverSpeir! - Updatesastro add cloudflareto better setup types, by adding./worker-configuration.d.tsto tsconfig includes and agenerate-typesscript to package.json -
#15646
0dd9d00Thanks @delucis! - Removes redundantfetchpriorityattributes from the output of Astro’s<Image>componentPreviously, Astro would always include
fetchpriority="auto"on images not using thepriorityattribute. However, this is the default value, so specifying it is redundant. This change omits the attribute by default. -
#15291
89b6cddThanks @florian-lefebvre! - Removes theexperimental.fontsflag and replaces it with a new configuration optionfonts- (v6 upgrade guidance) -
#15495
5b99e90Thanks @leekeh! - Adds a newmiddlewareModeadapter feature to replace the previousedgeMiddlewareoption.This feature only impacts adapter authors. If your adapter supports
edgeMiddleware, you should upgrade to the newmiddlewareModeoption to specify the middleware mode for your adapter as soon as possible. TheedgeMiddlewarefeature 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
66449c9Thanks @matthewp! - AddspreserveBuildClientDiroption to adapter featuresAdapters can now opt in to preserving the client/server directory structure for static builds by setting
preserveBuildClientDir: truein their adapter features. When enabled, static builds will output files tobuild.clientinstead of directly tooutDir.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.
// my-adapter/index.js export default function myAdapter() { return { name: 'my-adapter', hooks: { 'astro:config:done': ({ setAdapter }) => { setAdapter({ name: 'my-adapter', adapterFeatures: { buildOutput: 'static', preserveBuildClientDir: true, }, }); }, }, }; } -
#15332
7c55f80Thanks @matthewp! - Adds afileURLoption torenderMarkdownin 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 inmetadata.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
aedbbd8Thanks @ematipico! - Adds support for responsive images whensecurity.cspis 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=""anddata-*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
d43841dThanks @Princesseuh! - Adds a newexperimental.rustCompilerflag to opt into the experimental Rust-based Astro compilerThis 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-rspackage 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
a257c4cThanks @ascorbic! - Passes collection name to live content loadersLive 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
f361730Thanks @florian-lefebvre! - Adds new session driver object shapeFor 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
89b6cddThanks @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
fontswith 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 requiredcssVariableproperty in the head of your page, usually in a dedicatedHead.astrocomponent or in a layout component directly:--- // src/layouts/Layout.astro 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
cssVariableto apply your custom font.In the following example, the
<h1>heading will have the custom font applied, while the paragraph<p>will not.--- // src/pages/example.astro 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
9c282b5Thanks @ascorbic! - Adds support for live content collectionsLive 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.
Live collections vs build-time collections
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()andgetCollection(). 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.
How to use
To use live collections, create a new
src/live.config.tsfile (alongside yoursrc/content.config.tsif you have one) to define your live collections with a live content loader using the newdefineLiveCollection()function from theastro:contentmodule: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()andgetLiveEntry()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 products const { 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 object const { entry: productBySlug } = await getLiveEntry('products', { slug: Astro.params.slug }); const { Content } = await render(product); --- <h1>{product.data.title}</h1> <Content />Upgrading from experimental live collections
If you were using the experimental feature, you must remove the
experimental.liveContentCollectionsflag from yourastro.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
5b8f573Thanks @florian-lefebvre! - Adds a new optionalembeddedLangsprop to the<Code />component to support languages beyond the primarylangThis allows, for example, highlighting
.vuefiles 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
170f64eThanks @florian-lefebvre! - Adds an optionprerenderConflictBehaviorto configure the behavior of conflicting prerendered routesBy 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-1path. 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
prerenderConflictBehaviorconfiguration 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 occur
import { defineConfig } from 'astro/config'; export default defineConfig({ + prerenderConflictBehavior: 'error', }); -
#14946
95c40f7Thanks @ematipico! - Removes theexperimental.cspflag and replaces it with a new configuration optionsecurity.csp- (v6 upgrade guidance) -
#15579
08437d5Thanks @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.astropages) orcontext.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 usingexperimental.routeRules, without modifying route code.This feature requires on-demand rendering. Prerendered pages are already static and do not use route caching.
Getting started
Enable the feature by configuring
experimental.cachewith a cache provider in your Astro config:// astro.config.mjs 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(), }, }, });Using
Astro.cacheandcontext.cacheIn
.astropages, useAstro.cache.set()to control caching:--- // src/pages/index.astro 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:// src/pages/api/data.ts export function GET(context) { context.cache.set({ maxAge: 300, tags: ['api', 'data'], }); return Response.json({ ok: true }); }Cache options
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 multipleset()calls within a request.lastModified(Date): When multipleset()calls providelastModified, 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,lastModifieduses most-recent-wins, and tags accumulate.Invalidation
Purge cached entries by tag or path using
cache.invalidate():// Invalidate all entries tagged 'data' await context.cache.invalidate({ tags: ['data'] }); // Invalidate a specific path await context.cache.invalidate({ path: '/api/data' });Config-level route rules
Use
experimental.routeRulesto 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-routecache.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 providers
Cache behavior is determined by the configured cache provider. There are two types:
- CDN providers set response headers (e.g.
CDN-Cache-Control,Cache-Tag) and let the CDN handle caching. Astro strips these headers before sending the response to the client. - Runtime providers implement
onRequest()to intercept and cache responses in-process, adding anX-Astro-Cacheheader (HIT/MISS/STALE) for observability.
Built-in memory cache provider
Astro includes a built-in, in-memory LRU runtime cache provider. Import
memoryCachefromastro/configto configure it.Features:
- In-memory LRU cache with configurable max entries (default: 1000)
- Stale-while-revalidate support
- Tag-based and path-based invalidation
X-Astro-Cacheresponse header:HIT,MISS, orSTALE- Query parameter sorting for better hit rates (
?b=2&a=1and?a=1&b=2hit the same entry) - Common tracking parameters (
utm_*,fbclid,gclid, etc.) excluded from cache keys by default Varyheader support — responses that setVaryautomatically get separate cache entries per variant- Configurable query parameter filtering via
query.exclude(glob patterns) andquery.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
7be3308Thanks @florian-lefebvre! - Addsstreamingoption to thecreateApp()function in the Adapter API, mirroring the same functionality available when creating a newAppinstanceAn adapter's
createApp()function now acceptsstreaming(defaults totrue) 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: falsetocreateApp():import { createApp } from 'astro/app/entrypoint'; const app = createApp({ streaming: false });See more about the
createApp()function in the Adapter API reference.
Patch Changes
-
#15423
c5ea720Thanks @matthewp! - Improves error message when a dynamic redirect destination does not match any existing route.Previously, configuring a redirect like
/categories/[category]→/categories/[category]/1in 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
4fca170Thanks @HiDeoo! - Fixes an issue where CSS from unused components, when using content collections, could be incorrectly included between page navigations in development mode. -
#15565
30cd6dbThanks @ematipico! - Fixes an issue where the use of the Astro internal logger couldn't work with Cloudflare Vite plugin. -
#15508
2c6484aThanks @KTibow! - Fixes behavior when shortcuts are used before server is ready -
#15125
6feb0d7Thanks @florian-lefebvre! - Improves JSDoc annotations forAstroGlobal,AstroSharedContextandAPIContexttypes -
#15712
7ac43c7Thanks @florian-lefebvre! - Improvesastro infoby supporting more operating systems when copying the information to the clipboard. -
#15054
22db567Thanks @matthewp! - Improves zod union type error messages to show expected vs received types instead of generic "Invalid input" -
#15064
caf5621Thanks @ascorbic! - Fixes a bug that caused incorrect warnings of duplicate entries to be logged by the glob loader when editing a file -
#15801
01db4f3Thanks @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 modesAdds a
cache.enabledproperty toCacheLikeso libraries can check whether caching is active without try/catch. -
#15562
e14a51dThanks @florian-lefebvre! - Removes types for theastro:ssr-manifestmodule, which was removed -
#15542
9760404Thanks @rururux! - Improves rendering by preservinghidden="until-found"value in attributes -
#15044
7cac71bThanks @florian-lefebvre! - Removes an exposed internal API of the preview server -
#15573
d789452Thanks @matthewp! - Clear the route cache on content changes so slug pages reflect updated data during dev. -
#15308
89cbcfaThanks @matthewp! - Fixes styles missing in dev for prerendered pages when using Cloudflare adapter -
#15435
957b9feThanks @rururux! - Improves compatibility of the built-in image endpoint with runtimes that don't support CJS dependencies correctly -
#15640
4c1a801Thanks @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
cc3c46cThanks @ematipico! - Fixes an issue where CSP headers were incorrectly injected in the development server. -
#15412
c546563Thanks @florian-lefebvre! - Improves theAstroAdaptertype and how legacy adapters are handled -
#15322
18e0980Thanks @matthewp! - Prevents missing CSS when using both SSR and prerendered routes -
#15760
f49a27fThanks @ematipico! - Fixed an issue where queued rendering wasn't correctly re-using the saved nodes. -
#15277
cb99214Thanks @ematipico! - Fixes an issue where the functioncreateShikiHighlighterwould 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
5520f89Thanks @florian-lefebvre! - Fixes a case where using the Fonts API withnetlify devwouldn't work because of query parameters -
#15605
f6473fdThanks @ascorbic! - Improves.astrocomponent 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
e6e146cThanks @matthewp! - Fixes action route handling to return 404 for requests to prototype method names likeconstructorortoStringused as action paths -
#15497
a93c81dThanks @matthewp! - Fix dev reloads for content collection Markdown updates under Vite 7. -
#15780
e0ac125Thanks @ematipico! - Preventsvite.envPrefixmisconfiguration from exposingaccess: "secret"environment variables in client-side bundles. Astro now throws a clear error at startup if anyvite.envPrefixentry matches a variable declared withaccess: "secret"inenv.schema.For example, the following configuration will throw an error for
API_SECRETbecause it's defined assecretits name matches['PUBLIC_', 'API_']defined inenv.schema:// astro.config.mjs 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
999a7ddThanks @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-facedeclarations from the<Font>component were removed and re-inserted on every client-side navigation, causing the browser to re-evaluate them. -
#15560
170ed89Thanks @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
862d77bThanks @umutkeltek! - Fixes i18n fallback middleware intercepting non-404 responsesThe 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
7150a2eThanks @ematipico! - Fixes a build error when generating projects with 100k+ static routes. -
#15580
a92333cThanks @ematipico! - Fixes a build error when generating projects with a large number of static routes -
#15176
9265546Thanks @matthewp! - Fixes hydration for framework components inside MDX when usingAstro.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
074901fThanks @ascorbic! - Fixes a race condition where concurrent requests to dynamic routes in the dev server could produce incorrect params. -
#15444
10b0422Thanks @AhmadYasser1! - FixesAstro.rewritereturning 404 when rewriting to a URL with non-ASCII charactersWhen rewriting to a path containing non-ASCII characters (e.g.,
/redirected/héllo), the route lookup compared encodeddistURLhrefs against decoded pathnames, causing the comparison to always fail and resulting in a 404. This fix compares against the encoded pathname instead. -
#15728
12ca621Thanks @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
8983f17Thanks @ematipico! - Fixes an issue where the dev server would serve files like/README.mdfrom the project root when they shouldn't be accessible. A new route guard middleware now blocks direct URL access to files that exist outside ofsrcDirandpublicDir, returning a 404 instead. -
#15703
829182bThanks @matthewp! - Fixes server islands returning a 500 error in dev mode for adapters that do not setadapterFeatures.buildOutput(e.g.@astrojs/netlify) -
#15749
573d188Thanks @ascorbic! - Fixes a bug that causedsession.regenerate()to silently lose session dataPreviously, regenerated session data was not saved under the new session ID unless
set()was also called. -
#15549
be1c87eThanks @0xRozier! - Fixes an issue where original (unoptimized) images from prerendered pages could be kept in the build output during SSR builds. -
#15454
b47a4e1Thanks @Fryuni! - Fixes a race condition in the content layer which could result in dropped content collection entries. -
#15685
1a323e5Thanks @jcayzac! - Fix regression where SVG images in content collectionimage()fields could not be rendered as inline components. This behavior is now restored while preserving the TLA deadlock fix. -
#15603
5bc2b2cThanks @0xRozier! - Fixes a deadlock that occurred when using SVG images in content collections -
#15385
9e16d63Thanks @matthewp! - Fixes content layer loaders that use dynamic importsContent collection loaders can now use
await import()andimport.meta.glob()to dynamically import modules during build. Previously, these would fail with "Vite module runner has been closed." -
#15565
30cd6dbThanks @ematipico! - Fixes an issue where the use of theCodecomponent would result in an unexpected error. -
#15125
6feb0d7Thanks @florian-lefebvre! - Fixes remote imagesEtagheader handling by disabling internal cache -
#15317
7e1e35aThanks @matthewp! - Fixes?rawimports failing when used in both SSR and prerendered routes -
#15809
94b4a46Thanks @Princesseuh! - Fixesfitdefaults not being applied unlesslayoutwas also specified -
#15563
e959698Thanks @ematipico! - Fixes an issue where warnings would be logged during the build using one of the official adapters -
#15121
06261e0Thanks @ematipico! - Fixes a bug where the Astro, with the Cloudflare integration, couldn't correctly serve certain routes in the development server. -
#15585
98ea30cThanks @matthewp! - Add a default body size limit for server actions to prevent oversized requests from exhausting memory. -
#15264
11efb05Thanks @florian-lefebvre! - Lower the Node version requirement to allow running on Stackblitz until it supports v22 -
#15778
4ebc1e3Thanks @ematipico! - Fixes an issue where the computedclientAddresswas incorrect in cases of a Request header with multiple values. TheclientAddressis now also validated to contain only characters valid in IP addresses, rejecting injection payloads. -
#15565
30cd6dbThanks @ematipico! - Fixes an issue where the new Astro v6 development server didn't log anything when navigating the pages. -
#15024
22c48baThanks @florian-lefebvre! - Fixes a case where JSON schema generation would fail for unrepresentable types -
#15669
d5a888bThanks @florian-lefebvre! - Removes thecssescdependencyThis CommonJS dependency could sometimes cause errors because Astro is ESM-only. It is now replaced with a built-in ESM-friendly implementation.
-
#15740
c5016fcThanks @matthewp! - Removes an escape hatch that skipped attribute escaping for URL values containing&, ensuring all dynamic attribute values are consistently escaped -
#15756
b6c64d1Thanks @matthewp! - Hardens the dev server by validating Sec-Fetch metadata headers to restrict cross-origin subresource requests -
#15744
fabb710Thanks @matthewp! - Fixes cookie handling during error page rendering to ensure cookies set by middleware are consistently included in the response -
#15776
e9a9cc6Thanks @matthewp! - Hardens error page response merging to ensure framing headers from the original response are not carried over to the rendered error page -
#15759
39ff2a5Thanks @matthewp! - Adds a newbodySizeLimitoption to the@astrojs/nodeadapterYou 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
0to 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
02e24d9Thanks @matthewp! - Fixes CSRF origin check mismatch by passing the actual server listening port tocreateRequest, ensuring the constructed URL origin includes the correct port (e.g.,http://localhost:4321instead ofhttp://localhost). Also restrictsX-Forwarded-Prototo only be trusted whenallowedDomainsis configured. -
#15742
9d9699cThanks @matthewp! - HardensclientAddressresolution to respectsecurity.allowedDomainsforX-Forwarded-For, consistent with the existing handling ofX-Forwarded-Host,X-Forwarded-Proto, andX-Forwarded-Port. TheX-Forwarded-Forheader is now only used to determineAstro.clientAddresswhen the request's host has been validated against anallowedDomainsentry. Without a matching domain,clientAddressfalls back to the socket's remote address. -
#15768
6328f1aThanks @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
6feb0d7Thanks @florian-lefebvre! - Fixes images not working in development when using setups with port forwarding -
#15811
2ba0db5Thanks @ematipico! - Fixes integration-injected scripts (e.g. Alpine.js viainjectScript()) not being loaded in the dev server when using non-runnable environment adapters like@astrojs/cloudflare. -
#15208
8dbdd8eThanks @matthewp! - Makessession.driveroptional in config schema, allowing adapters to provide default driversAdapters like Cloudflare, Netlify, and Node provide default session drivers, so users can now configure session options (like
ttl) without explicitly specifying a driver. -
#15260
abca1ebThanks @ematipico! - Fixes an issue where adding new pages weren't correctly shown when using the development server. -
#15591
1ed07bfThanks @renovate! - Upgradesdevalueto v5.6.3 -
#15137
2f70bf1Thanks @matthewp! - Addslegacy.collectionsBackwardsCompatflag that restores v5 backwards compatibility behavior for legacy content collections - (v6 upgrade guidance)When enabled, this flag allows:
- Collections defined without loaders (automatically get glob loader)
- Collections with
type: 'content'ortype: 'data' - Config files located at
src/content/config.ts(legacy location) - Legacy entry API:
entry.slugandentry.render()methods - Path-based entry IDs instead of slug-based IDs
// astro.config.mjs export 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
58df907Thanks @florian-lefebvre! - Improves the JSDoc annotations for theAstroAdaptertype -
#15696
a9fd221Thanks @Princesseuh! - Fixes images not working in MDX when using the Cloudflare adapter in certain cases -
#15386
a0234a3Thanks @OliverSpeir! - Updatesastro add cloudflareto use the latest validcompatibility_datein the wrangler config, if available -
#15036
f125a73Thanks @florian-lefebvre! - Fixes certain aliases not working when using images in JSON files with the content layer -
#15693
4db2089Thanks @ArmandPhilippot! - Fixes the links to Astro Docs to match the v6 structure. -
#15093
8d5f783Thanks @matthewp! - Reduces build memory by filtering routes per environment so each only builds the pages it needs -
#15268
54e5cc4Thanks @rururux! - fix: avoid creating unused images during build in Picture component -
#15757
631aaedThanks @matthewp! - Hardens URL pathname normalization to consistently handle backslash characters after decoding, ensuring middleware and router see the same canonical pathname -
#15337
7ff7b11Thanks @ematipico! - Fixes a bug where the development server couldn't serve newly created new pages while the development server is running. -
#15535
dfe2e22Thanks @florian-lefebvre! - Fixes the types ofcreateApp()exported fromastro/app/entrypoint -
#15073
2a39c32Thanks @ascorbic! - Don't log an error when there is no content config -
#15717
4000aaaThanks @matthewp! - Ensures that URLs with multiple leading slashes (e.g.//admin) are normalized to a single slash before reaching middleware, so that pathname checks likecontext.url.pathname.startsWith('/admin')work consistently regardless of the request URL format -
#15450
50c9129Thanks @florian-lefebvre! - Fixes a case wherebuild.serverEntrywould not be respected when using the new Adapter API -
#15331
4592be5Thanks @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
faedcc4Thanks @sapphi-red! - Fixes a bug where some requests to the dev server didn't start with the leading/. -
#15419
a18d727Thanks @ematipico! - Fixes an issue where theaddcommand could accept any arbitrary value, leading the possible command injections. Nowaddand--addaccepts values that are only acceptable npmjs.org names. -
#15507
07f6610Thanks @matthewp! - Avoid bundling SSR renderers when only API endpoints are dynamic -
#15125
6feb0d7Thanks @florian-lefebvre! - Reduces Astro’s install size by around 8 MB -
#15752
918d394Thanks @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
3b4252aThanks @matthewp! - Hardens config-based redirects with catch-all parameters to prevent producing protocol-relative URLs (e.g.//example.com) in theLocationheader -
#15761
8939751Thanks @ematipico! - Fixes an issue where it wasn't possible to setexperimental.queuedRendering.poolSizeto0. -
#15633
9d293c2Thanks @jwoyo! - Fixes a case where<script>tags from components passed as slots to server islands were not included in the response -
#15491
6c60b05Thanks @matthewp! - Fixes a case where settingvite.server.allowedHosts: truewas turned into an invalid array -
#15459
a4406b4Thanks @florian-lefebvre! - Fixes a case wherecontext.cspwas logging warnings in development that should be logged in production only -
#15125
6feb0d7Thanks @florian-lefebvre! - Enables the ClientRouter to preserve the original hash part of the target URL during server side redirects. -
#15133
53b125bThanks @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
dbf71c0Thanks @jcayzac! - FixesinferSizebeing kept in the HTML attributes of the emitted<img>when that option is used with an image that is not remote. -
#15421
bf62b6fThanks @Princesseuh! - Removes unintended logging -
#15732
2ce9e74Thanks @florian-lefebvre! - Updates docs links to point to the stable release -
#15718
14f37b8Thanks @florian-lefebvre! - Fixes a case where internal headers may leak when rendering error pages -
#15214
6bab8c9Thanks @ematipico! - Fixes an issue where the internal performance timers weren't correctly updated to reflect new build pipeline. -
#15112
5751d2bThanks @HiDeoo! - Fixes a Windows-specific build issue when importing an Astro component with a<script>tag using an import alias. -
#15345
840fbf9Thanks @matthewp! - Fixes an issue where.sqlfiles (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
ssrMoveAssetsfunction 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
8670a69Thanks @ematipico! - Fixes an issue where styles weren't correctly reloaded when using the@astrojs/cloudflareadapter. -
#15473
d653b86Thanks @matthewp! - Improves Host header handling for SSR deployments behind proxies -
#15047
5580372Thanks @matthewp! - Fixes wrangler config template inastro add cloudflareto use correct entrypoint and compatibility date -
#15586
35bc814Thanks @matthewp! - Fixes an issue where allowlists were not being enforced when handling remote images -
#15422
68770efThanks @matthewp! - Upgrade to @astrojs/compiler@3.0.0-beta -
#15205
12adc55Thanks @martrapp! - Fixes an issue where theastro:page-loadevent did not fire on initial page loads. -
#15125
6feb0d7Thanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API onlyChanges the font format downloaded by default when using the experimental Fonts API. Additionally, adds a new
formatsconfiguration option to specify which font formats to download.Previously, Astro was opinionated about which font sources would be kept for usage, mainly keeping
woff2andwofffiles.You can now specify what font formats should be downloaded (if available). Only
woff2files are downloaded by default.What should I do?
If you were previously relying on Astro downloading the
woffformat, you will now need to specify this explicitly with the newformatsconfiguration option. Additionally, you may also specify any additional file formats to download if available:// astro.config.mjs import { defineConfig, fontProviders } from 'astro/config' export default defineConfig({ experimental: { fonts: [{ name: 'Roboto', cssVariable: '--font-roboto', provider: fontProviders.google(), + formats: ['woff2', 'woff', 'otf'] }] } }) -
#15179
8c8aee6Thanks @HiDeoo! - Fixes an issue when importing using an import alias a file with a name matching a directory name. -
#15036
f125a73Thanks @florian-lefebvre! - Fixes a vite warning log during builds when using npm -
#15269
6f82aaeThanks @ematipico! - Fixes a regression wherebuild.serverEntrystopped working as expected. -
#15053
674b63fThanks @matthewp! - Excludesastro:*andvirtual:astro:*from client optimizeDeps in core. Needed for prefetch users since virtual modules are now in the dependency graph. -
#15764
44daecfThanks @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
a91da9fThanks @florian-lefebvre! - Reverts changes made to TSConfig templates -
#15657
cb625b6Thanks @qzio! - Adds a newsecurity.actionBodySizeLimitoption 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.
// astro.config.mjs export default defineConfig({ security: { actionBodySizeLimit: 10 * 1024 * 1024, // set to 10 MB }, }); -
#15176
9265546Thanks @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]:- @astrojs/markdown-remark@7.0.0
- @astrojs/internal-helpers@0.8.0
Major Changes
- #15424
33d6146Thanks @Princesseuh! - Throws an error whengetImage()fromastro:assetsis called on the client - (v6 upgrade guidance)
Minor Changes
-
#15700
4e7f3e8Thanks @ocavue! - Updates the internal logic during SSR by providing additional metadata for UI framework integrations. -
#15781
2de969dThanks @ematipico! - Adds a newclientAddressoption to thecreateContext()functionProviding this value gives adapter and middleware authors explicit control over the client IP address. When not provided, accessing
clientAddressthrows 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
f9ee868Thanks @matthewp! - Adds a newsecurity.serverIslandBodySizeLimitconfiguration optionServer island POST endpoints now enforce a body size limit, similar to the existing
security.actionBodySizeLimitfor Actions. The new option defaults to1048576(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 }, });
Patch Changes
-
#15712
7ac43c7Thanks @florian-lefebvre! - Improvesastro infoby supporting more operating systems when copying the information to the clipboard. -
#15780
e0ac125Thanks @ematipico! - Preventsvite.envPrefixmisconfiguration from exposingaccess: "secret"environment variables in client-side bundles. Astro now throws a clear error at startup if anyvite.envPrefixentry matches a variable declared withaccess: "secret"inenv.schema.For example, the following configuration will throw an error for
API_SECRETbecause it's defined assecretits name matches['PUBLIC_', 'API_']defined inenv.schema:// astro.config.mjs 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
4ebc1e3Thanks @ematipico! - Fixes an issue where the computedclientAddresswas incorrect in cases of a Request header with multiple values. TheclientAddressis now also validated to contain only characters valid in IP addresses, rejecting injection payloads. -
#15776
e9a9cc6Thanks @matthewp! - Hardens error page response merging to ensure framing headers from the original response are not carried over to the rendered error page -
#15759
39ff2a5Thanks @matthewp! - Adds a newbodySizeLimitoption to the@astrojs/nodeadapterYou 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
0to 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
02e24d9Thanks @matthewp! - Fixes CSRF origin check mismatch by passing the actual server listening port tocreateRequest, ensuring the constructed URL origin includes the correct port (e.g.,http://localhost:4321instead ofhttp://localhost). Also restrictsX-Forwarded-Prototo only be trusted whenallowedDomainsis configured. -
#15768
6328f1aThanks @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
631aaedThanks @matthewp! - Hardens URL pathname normalization to consistently handle backslash characters after decoding, ensuring middleware and router see the same canonical pathname -
#15761
8939751Thanks @ematipico! - Fixes an issue where it wasn't possible to setexperimental.queuedRendering.poolSizeto0. -
#15764
44daecfThanks @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
a91da9fThanks @florian-lefebvre! - Reverts changes made to TSConfig templates -
Updated dependencies [
4ebc1e3,4e7f3e8]:- @astrojs/internal-helpers@0.8.0-beta.3
- @astrojs/markdown-remark@7.0.0-beta.11
Patch Changes
-
#15760
f49a27fThanks @ematipico! - Fixed an issue where queued rendering wasn't correctly re-using the saved nodes. -
#15728
12ca621Thanks @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
b6c64d1Thanks @matthewp! - Hardens the dev server by validating Sec-Fetch metadata headers to restrict cross-origin subresource requests -
#15414
faedcc4Thanks @sapphi-red! - Fixes a bug where some requests to the dev server didn't start with the leading/. -
Updated dependencies [
745e632]:- @astrojs/internal-helpers@0.8.0-beta.2
- @astrojs/markdown-remark@7.0.0-beta.10
Major Changes
-
#15668
1118ac4Thanks @florian-lefebvre! - Changes TypeScript configuration - (v6 upgrade guidance) -
#15726
6f19eccThanks @ocavue! - Updates dependencyshikito v4Check Shiki's upgrade guide.
Minor Changes
-
#15694
66449c9Thanks @matthewp! - AddspreserveBuildClientDiroption to adapter featuresAdapters can now opt in to preserving the client/server directory structure for static builds by setting
preserveBuildClientDir: truein their adapter features. When enabled, static builds will output files tobuild.clientinstead of directly tooutDir.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.
// my-adapter/index.js export default function myAdapter() { return { name: 'my-adapter', hooks: { 'astro:config:done': ({ setAdapter }) => { setAdapter({ name: 'my-adapter', adapterFeatures: { buildOutput: 'static', preserveBuildClientDir: true, }, }); }, }, }; } -
#15579
08437d5Thanks @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.astropages) orcontext.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 usingexperimental.routeRules, without modifying route code.This feature requires on-demand rendering. Prerendered pages are already static and do not use route caching.
Getting started
Enable the feature by configuring
experimental.cachewith a cache provider in your Astro config:// astro.config.mjs 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(), }, }, });Using
Astro.cacheandcontext.cacheIn
.astropages, useAstro.cache.set()to control caching:--- // src/pages/index.astro 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:// src/pages/api/data.ts export function GET(context) { context.cache.set({ maxAge: 300, tags: ['api', 'data'], }); return Response.json({ ok: true }); }Cache options
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 multipleset()calls within a request.lastModified(Date): When multipleset()calls providelastModified, 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,lastModifieduses most-recent-wins, and tags accumulate.Invalidation
Purge cached entries by tag or path using
cache.invalidate():// Invalidate all entries tagged 'data' await context.cache.invalidate({ tags: ['data'] }); // Invalidate a specific path await context.cache.invalidate({ path: '/api/data' });Config-level route rules
Use
experimental.routeRulesto 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-routecache.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 providers
Cache behavior is determined by the configured cache provider. There are two types:
- CDN providers set response headers (e.g.
CDN-Cache-Control,Cache-Tag) and let the CDN handle caching. Astro strips these headers before sending the response to the client. - Runtime providers implement
onRequest()to intercept and cache responses in-process, adding anX-Astro-Cacheheader (HIT/MISS/STALE) for observability.
Built-in memory cache provider
Astro includes a built-in, in-memory LRU runtime cache provider. Import
memoryCachefromastro/configto configure it.Features:
- In-memory LRU cache with configurable max entries (default: 1000)
- Stale-while-revalidate support
- Tag-based and path-based invalidation
X-Astro-Cacheresponse header:HIT,MISS, orSTALE- Query parameter sorting for better hit rates (
?b=2&a=1and?a=1&b=2hit the same entry) - Common tracking parameters (
utm_*,fbclid,gclid, etc.) excluded from cache keys by default Varyheader support — responses that setVaryautomatically get separate cache entries per variant- Configurable query parameter filtering via
query.exclude(glob patterns) andquery.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.
Patch Changes
-
#15721
e6e146cThanks @matthewp! - Fixes action route handling to return 404 for requests to prototype method names likeconstructorortoStringused as action paths -
#15704
862d77bThanks @umutkeltek! - Fixes i18n fallback middleware intercepting non-404 responsesThe 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
829182bThanks @matthewp! - Fixes server islands returning a 500 error in dev mode for adapters that do not setadapterFeatures.buildOutput(e.g.@astrojs/netlify) -
#15749
573d188Thanks @ascorbic! - Fixes a bug that causedsession.regenerate()to silently lose session dataPreviously, regenerated session data was not saved under the new session ID unless
set()was also called. -
#15685
1a323e5Thanks @jcayzac! - Fix regression where SVG images in content collectionimage()fields could not be rendered as inline components. This behavior is now restored while preserving the TLA deadlock fix. -
#15740
c5016fcThanks @matthewp! - Removes an escape hatch that skipped attribute escaping for URL values containing&, ensuring all dynamic attribute values are consistently escaped -
#15744
fabb710Thanks @matthewp! - Fixes cookie handling during error page rendering to ensure cookies set by middleware are consistently included in the response -
#15742
9d9699cThanks @matthewp! - HardensclientAddressresolution to respectsecurity.allowedDomainsforX-Forwarded-For, consistent with the existing handling ofX-Forwarded-Host,X-Forwarded-Proto, andX-Forwarded-Port. TheX-Forwarded-Forheader is now only used to determineAstro.clientAddresswhen the request's host has been validated against anallowedDomainsentry. Without a matching domain,clientAddressfalls back to the socket's remote address. -
#15696
a9fd221Thanks @Princesseuh! - Fixes images not working in MDX when using the Cloudflare adapter in certain cases -
#15693
4db2089Thanks @ArmandPhilippot! - Fixes the links to Astro Docs to match the v6 structure. -
#15717
4000aaaThanks @matthewp! - Ensures that URLs with multiple leading slashes (e.g.//admin) are normalized to a single slash before reaching middleware, so that pathname checks likecontext.url.pathname.startsWith('/admin')work consistently regardless of the request URL format -
#15752
918d394Thanks @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
3b4252aThanks @matthewp! - Hardens config-based redirects with catch-all parameters to prevent producing protocol-relative URLs (e.g.//example.com) in theLocationheader -
#15718
14f37b8Thanks @florian-lefebvre! - Fixes a case where internal headers may leak when rendering error pages -
Updated dependencies [
6f19ecc,f94d3c5]:- @astrojs/markdown-remark@7.0.0-beta.9
Minor Changes
-
#15495
5b99e90Thanks @leekeh! - Adds a newmiddlewareModeadapter feature to replace the previousedgeMiddlewareoption.This feature only impacts adapter authors. If your adapter supports
edgeMiddleware, you should upgrade to the newmiddlewareModeoption to specify the middleware mode for your adapter as soon as possible. TheedgeMiddlewarefeature 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' } }); }, }, }; }
Patch Changes
-
#15657
cb625b6Thanks @qzio! - Adds a newsecurity.actionBodySizeLimitoption 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.
// astro.config.mjs export default defineConfig({ security: { actionBodySizeLimit: 10 * 1024 * 1024, // set to 10 MB }, }); -
Updated dependencies [
1fa4177]:- @astrojs/markdown-remark@7.0.0-beta.8
Minor Changes
-
#15646
0dd9d00Thanks @delucis! - Removes redundantfetchpriorityattributes from the output of Astro’s<Image>componentPreviously, Astro would always include
fetchpriority="auto"on images not using thepriorityattribute. However, this is the default value, so specifying it is redundant. This change omits the attribute by default.
Patch Changes
-
#15661
7150a2eThanks @ematipico! - Fixes a build error when generating projects with 100k+ static routes. -
#15603
5bc2b2cThanks @0xRozier! - Fixes a deadlock that occurred when using SVG images in content collections -
#15669
d5a888bThanks @florian-lefebvre! - Removes thecssescdependencyThis CommonJS dependency could sometimes cause errors because Astro is ESM-only. It is now replaced with a built-in ESM-friendly implementation.
Minor Changes
-
#15471
32b4302Thanks @ematipico! - Adds a new experimental flagqueuedRenderingto enable a queue-based rendering engineThe 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.
Queue-rendered based
The new engine can be enabled in your Astro config with
experimental.queuedRendering.enabledset totrue, and can be further customized with additional sub-features.// astro.config.mjs export default defineConfig({ experimental: { queuedRendering: { enabled: true, }, }, });Pooling
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.
// astro.config.mjs export default defineConfig({ experimental: { queuedRendering: { enabled: true, poolSize: 2000, // store up to 2k nodes to be reused across renderers }, }, });Content caching
The new engine additionally unlocks a new
contentCacheoption. 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.
// astro.config.mjs 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
d43841dThanks @Princesseuh! - Adds a newexperimental.rustCompilerflag to opt into the experimental Rust-based Astro compilerThis 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-rspackage 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.
Patch Changes
-
#15565
30cd6dbThanks @ematipico! - Fixes an issue where the use of the Astro internal logger couldn't work with Cloudflare Vite plugin. -
#15562
e14a51dThanks @florian-lefebvre! - Removes types for theastro:ssr-manifestmodule, which was removed -
#15435
957b9feThanks @rururux! - Improves compatibility of the built-in image endpoint with runtimes that don't support CJS dependencies correctly -
#15640
4c1a801Thanks @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
f6473fdThanks @ascorbic! - Improves.astrocomponent 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
999a7ddThanks @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-facedeclarations from the<Font>component were removed and re-inserted on every client-side navigation, causing the browser to re-evaluate them. -
#15580
a92333cThanks @ematipico! - Fixes a build error when generating projects with a large number of static routes -
#15549
be1c87eThanks @0xRozier! - Fixes an issue where original (unoptimized) images from prerendered pages could be kept in the build output during SSR builds. -
#15565
30cd6dbThanks @ematipico! - Fixes an issue where the use of theCodecomponent would result in an unexpected error. -
#15585
98ea30cThanks @matthewp! - Add a default body size limit for server actions to prevent oversized requests from exhausting memory. -
#15565
30cd6dbThanks @ematipico! - Fixes an issue where the new Astro v6 development server didn't log anything when navigating the pages. -
#15591
1ed07bfThanks @renovate! - Upgradesdevalueto v5.6.3 -
#15633
9d293c2Thanks @jwoyo! - Fixes a case where<script>tags from components passed as slots to server islands were not included in the response -
#15586
35bc814Thanks @matthewp! - Fixes an issue where allowlists were not being enforced when handling remote images
Patch Changes
-
#15573
d789452Thanks @matthewp! - Clear the route cache on content changes so slug pages reflect updated data during dev. -
#15560
170ed89Thanks @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
e959698Thanks @ematipico! - Fixes an issue where warnings would be logged during the build using one of the official adapters
Major Changes
- #15451
84d6efdThanks @ematipico! - Changes how styles applied to code blocks are emitted to support CSP - (v6 upgrade guidance)
Minor Changes
-
#15529
a509941Thanks @florian-lefebvre! - Adds a new build-in font providernpmto access fonts installed as NPM packagesYou can now add web fonts specified in your
package.jsonthrough Astro's type-safe Fonts API. Thenpmfont provider allows you to add fonts either from locally installed packages innode_modulesor from a CDN.Set
fontProviders.npm()as your fonts provider along with the requirednameandcssVariablevalues, and addoptionsas 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
5b8f573Thanks @florian-lefebvre! - Adds a new optionalembeddedLangsprop to the<Code />component to support languages beyond the primarylangThis allows, for example, highlighting
.vuefiles 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
7be3308Thanks @florian-lefebvre! - Addsstreamingoption to thecreateApp()function in the Adapter API, mirroring the same functionality available when creating a newAppinstanceAn adapter's
createApp()function now acceptsstreaming(defaults totrue) 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: falsetocreateApp():import { createApp } from 'astro/app/entrypoint'; const app = createApp({ streaming: false });See more about the
createApp()function in the Adapter API reference.
Patch Changes
-
#15542
9760404Thanks @rururux! - Improves rendering by preservinghidden="until-found"value in attribues -
#15550
58df907Thanks @florian-lefebvre! - Improves the JSDoc annotations for theAstroAdaptertype -
#15507
07f6610Thanks @matthewp! - Avoid bundling SSR renderers when only API endpoints are dynamic -
#15459
a4406b4Thanks @florian-lefebvre! - Fixes a case wherecontext.cspwas logging warnings in development that should be logged in production only -
Updated dependencies [
84d6efd]:- @astrojs/markdown-remark@7.0.0-beta.7
Major Changes
-
#15535
dfe2e22Thanks @florian-lefebvre! - DeprecatesloadManifest()andloadApp()fromastro/app/node(Adapter API) - (v6 upgrade guidance) -
#15461
9f21b24Thanks @florian-lefebvre! - BREAKING CHANGE to the v6 beta Adapter API only: renamesentryTypetoentrypointResolutionand updates possible valuesAstro 6 introduced a way to let adapters have more control over the entrypoint by passing
entryType: 'self'tosetAdapter(). However during beta development, the name was unclear and confusing.entryTypeis now renamed toentrypointResolutionand its possible values are updated:legacy-dynamicbecomesexplicit.selfbecomesauto.
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
9f21b24Thanks @florian-lefebvre! - DeprecatescreateExports()andstart()(Adapter API) - (v6 upgrade guidance) -
#15535
dfe2e22Thanks @florian-lefebvre! - DeprecatesNodeAppfromastro/app/node(Adapter API) - (v6 upgrade guidance) -
#15407
aedbbd8Thanks @ematipico! - Changes how styles of responsive images are emitted - (v6 upgrade guidance)
Minor Changes
-
#15535
dfe2e22Thanks @florian-lefebvre! - Exports newcreateRequest()andwriteResponse()utilities fromastro/app/nodeTo replace the deprecated
NodeApp.createRequest()andNodeApp.writeResponse()methods, theastro/app/nodemodule now exposes newcreateRequest()andwriteResponse()utilities. These can be used to convert a NodeJSIncomingMessageinto a web-standardRequestand stream a web-standardResponseinto a NodeJSServerResponse: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
aedbbd8Thanks @ematipico! - Adds support for responsive images whensecurity.cspis 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=""anddata-*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.
Patch Changes
-
#15508
2c6484aThanks @KTibow! - Fixes behavior when shortcuts are used before server is ready -
#15497
a93c81dThanks @matthewp! - Fix dev reloads for content collection Markdown updates under Vite 7. -
#15535
dfe2e22Thanks @florian-lefebvre! - Fixes the types ofcreateApp()exported fromastro/app/entrypoint -
#15491
6c60b05Thanks @matthewp! - Fixes a case where settingvite.server.allowedHosts: truewas turned into an invalid array
Major Changes
- #15180
8780ff2Thanks @Princesseuh! - Adds support for converting SVGs to raster images (PNGs, WebP, etc) to the default Sharp image service - (v6 upgrade guidance)
Minor Changes
-
#15460
ee7e53fThanks @florian-lefebvre! - Updates the Adapter API to allow providing aserverEntrypointwhen usingentryType: 'self'Astro 6 introduced a new powerful yet simple Adapter API for defining custom server entrypoints. You can now call
setAdapter()with theentryType: 'self'option and specify your customserverEntrypoint: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
serverEntrypointand instead specify your custom server entrypoint withvite.build.rollupOptions.input.
Patch Changes
-
#15454
b47a4e1Thanks @Fryuni! - Fixes a race condition in the content layer which could result in dropped content collection entries. -
#15450
50c9129Thanks @florian-lefebvre! - Fixes a case wherebuild.serverEntrywould not be respected when using the new Adapter API -
#15473
d653b86Thanks @matthewp! - Improves Host header handling for SSR deployments behind proxies
Minor Changes
-
#15231
3928b87Thanks @rururux! - Adds a new optionalgetRemoteSize()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 extendsinferRemoteSize(), you can now override or extend how remote image metadata is retrieved.This enables use cases such as:
- Caching: Storing image dimensions in a database or local cache to avoid redundant network requests.
- Provider APIs: Using a specific image provider's API (like Cloudinary or Vercel) to get dimensions without downloading the file.
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
a164c77Thanks @matthewp! - Updates the Integration API to addsetPrerenderer()to theastro:build:starthook, allowing adapters to provide custom prerendering logic.The new API accepts either an
AstroPrerendererobject 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-pathsvirtual module, which exports aStaticPathsclass 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
840fbf9Thanks @matthewp! - Adds a newemitClientAssetfunction toastro/assets/utilsfor 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 hook const handle = emitClientAsset(this, { type: 'asset', name: 'my-image.png', source: imageBuffer, });
Patch Changes
-
#15423
c5ea720Thanks @matthewp! - Improves error message when a dynamic redirect destination does not match any existing route.Previously, configuring a redirect like
/categories/[category]→/categories/[category]/1in 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
10b0422Thanks @AhmadYasser1! - FixesAstro.rewritereturning 404 when rewriting to a URL with non-ASCII charactersWhen rewriting to a path containing non-ASCII characters (e.g.,
/redirected/héllo), the route lookup compared encodeddistURLhrefs against decoded pathnames, causing the comparison to always fail and resulting in a 404. This fix compares against the encoded pathname instead. -
#15419
a18d727Thanks @ematipico! - Fixes an issue where theaddcommand could accept any arbitrary value, leading the possible command injections. Nowaddand--addaccepts values that are only acceptable npmjs.org names. -
#15345
840fbf9Thanks @matthewp! - Fixes an issue where.sqlfiles (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
ssrMoveAssetsfunction 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
68770efThanks @matthewp! - Upgrade to @astrojs/compiler@3.0.0-beta -
Updated dependencies [
a164c77,a18d727]:- @astrojs/internal-helpers@0.8.0-beta.1
- @astrojs/markdown-remark@7.0.0-beta.6
Patch Changes
-
#15415
cc3c46cThanks @ematipico! - Fixes an issue where CSP headers were incorrectly injected in the development server. -
#15412
c546563Thanks @florian-lefebvre! - Improves theAstroAdaptertype and how legacy adapters are handled -
#15421
bf62b6fThanks @Princesseuh! - Removes unintended logging
Minor Changes
-
#15258
d339a18Thanks @ematipico! - Stabilizes the adapter featureexperimentalStatiHeaders. 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 }) })
Patch Changes
-
#15167
4fca170Thanks @HiDeoo! - Fixes an issue where CSS from unused components, when using content collections, could be incorrectly included between page navigations in development mode. -
#15268
54e5cc4Thanks @rururux! - fix: avoid creating unused images during build in Picture component -
#15133
53b125bThanks @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]:- @astrojs/markdown-remark@7.0.0-beta.5
Minor Changes
-
#14888
4cd3fe4Thanks @OliverSpeir! - Updatesastro add cloudflareto better setup types, by adding./worker-configuration.d.tsto tsconfig includes and agenerate-typesscript to package.json -
#15349
a257c4cThanks @ascorbic! - Passes collection name to live content loadersLive 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 }) => { // ... }, }; }
Patch Changes
-
#15394
5520f89Thanks @florian-lefebvre! - Fixes a case where using the Fonts API withnetlify devwouldn't work because of query parameters -
#15385
9e16d63Thanks @matthewp! - Fixes content layer loaders that use dynamic importsContent collection loaders can now use
await import()andimport.meta.glob()to dynamically import modules during build. Previously, these would fail with "Vite module runner has been closed." -
#15386
a0234a3Thanks @OliverSpeir! - Updatesastro add cloudflareto use the latest validcompatibility_datein the wrangler config, if available -
#15362
dbf71c0Thanks @jcayzac! - FixesinferSizebeing kept in the HTML attributes of the emitted<img>when that option is used with an image that is not remote. -
Updated dependencies [
240c317]:- @astrojs/internal-helpers@0.8.0-beta.0
- @astrojs/markdown-remark@7.0.0-beta.4
Major Changes
-
#15332
7c55f80Thanks @matthewp! - Adds frontmatter parsing support torenderMarkdownin content loaders. When markdown content includes frontmatter, it is now extracted and available inmetadata.frontmatter, and excluded from the HTML output. This makesrenderMarkdownbehave consistently with theglobloader.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 }, };
Minor Changes
-
#15291
89b6cddThanks @florian-lefebvre! - Removes theexperimental.fontsflag and replaces it with a new configuration optionfonts- (v6 upgrade guidance) -
#15332
7c55f80Thanks @matthewp! - Adds afileURLoption torenderMarkdownin 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 inmetadata.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
89b6cddThanks @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
fontswith 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 requiredcssVariableproperty in the head of your page, usually in a dedicatedHead.astrocomponent or in a layout component directly:--- // src/layouts/Layout.astro 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
cssVariableto apply your custom font.In the following example, the
<h1>heading will have the custom font applied, while the paragraph<p>will not.--- // src/pages/example.astro 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.
Patch Changes
-
#15337
7ff7b11Thanks @ematipico! - Fixes a bug where the development server couldn't serve newly created new pages while the development server is running. -
#15331
4592be5Thanks @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]:- @astrojs/markdown-remark@7.0.0-beta.3
Patch Changes
-
#15308
89cbcfaThanks @matthewp! - Fixes styles missing in dev for prerendered pages when using Cloudflare adapter -
#15279
8983f17Thanks @ematipico! - Fixes an issue where the dev server would serve files like/README.mdfrom the project root when they shouldn't be accessible. A new route guard middleware now blocks direct URL access to files that exist outside ofsrcDirandpublicDir, returning a 404 instead.
Patch Changes
-
#15277
cb99214Thanks @ematipico! - Fixes an issue where the functioncreateShikiHighlighterwould 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
11efb05Thanks @florian-lefebvre! - Lower the Node version requirement to allow running on Stackblitz until it supports v22 -
Updated dependencies [
cb99214]:- @astrojs/markdown-remark@7.0.0-beta.2
Major Changes
-
#15192
ada2808Thanks @gameroman! - Removes support for CommonJS config files - (v6 upgrade guidance) -
#15266
f7c9365Thanks @florian-lefebvre! - AllowsAstro.cspandcontext.cspto be undefined instead of throwing errors whencsp: trueis not configuredWhen using the experimental Content Security Policy feature in Astro 5.x,
context.cspwas always defined but would throw ifexperimental.cspwas not enabled in the Astro config.For the stable version of this API in Astro 6,
context.cspcan now be undefined if CSP is not enabled and its methods will never throw.What should I do?
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'");
Patch Changes
-
#15208
8dbdd8eThanks @matthewp! - Makessession.driveroptional in config schema, allowing adapters to provide default driversAdapters like Cloudflare, Netlify, and Node provide default session drivers, so users can now configure session options (like
ttl) without explicitly specifying a driver. -
#15260
abca1ebThanks @ematipico! - Fixes an issue where adding new pages weren't correctly shown when using the development server. -
#15214
6bab8c9Thanks @ematipico! - Fixes an issue where the internal perfomance timers weren't correctly updated to reflect new build pipeline. -
#15259
8670a69Thanks @ematipico! - Fixes an issue where styles weren't correctly reloaded when using the@astrojs/cloudflareadapter. -
#15205
12adc55Thanks @martrapp! - Fixes an issue where theastro:page-loadevent did not fire on initial page loads. -
#15269
6f82aaeThanks @ematipico! - Fixes a regression wherebuild.serverEntrystopped working as expected.
Patch Changes
- Updated dependencies [
bbb5811]:- @astrojs/markdown-remark@7.0.0-beta.1
Patch Changes
-
#15125
6feb0d7Thanks @florian-lefebvre! - Improves JSDoc annotations forAstroGlobal,AstroSharedContextandAPIContexttypes -
#15176
9265546Thanks @matthewp! - Fixes hydration for framework components inside MDX when usingAstro.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
6feb0d7Thanks @florian-lefebvre! - Fixes remote imagesEtagheader handling by disabling internal cache -
#15121
06261e0Thanks @ematipico! - Fixes a bug where the Astro, with the Cloudlfare integration, couldn't correctly serve certain routes in the development server. -
#15125
6feb0d7Thanks @florian-lefebvre! - Fixes images not working in development when using setups with port forwarding -
#15137
2f70bf1Thanks @matthewp! - Addslegacy.collectionsBackwardsCompatflag that restores v5 backwards compatibility behavior for legacy content collections - (v6 upgrade guidance)When enabled, this flag allows:
- Collections defined without loaders (automatically get glob loader)
- Collections with
type: 'content'ortype: 'data' - Config files located at
src/content/config.ts(legacy location) - Legacy entry API:
entry.slugandentry.render()methods - Path-based entry IDs instead of slug-based IDs
// astro.config.mjs export 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
6feb0d7Thanks @florian-lefebvre! - Reduces Astro’s install size by around 8 MB -
#15125
6feb0d7Thanks @florian-lefebvre! - Enables the ClientRouter to preserve the original hash part of the target URL during server side redirects. -
#15125
6feb0d7Thanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API onlyChanges the font format downloaded by default when using the experimental Fonts API. Additionally, adds a new
formatsconfiguration option to specify which font formats to download.Previously, Astro was opinionated about which font sources would be kept for usage, mainly keeping
woff2andwofffiles.You can now specify what font formats should be downloaded (if available). Only
woff2files are downloaded by default.What should I do?
If you were previously relying on Astro downloading the
woffformat, you will now need to specify this explicitly with the newformatsconfiguration option. Additionally, you may also specify any additional file formats to download if available:// astro.config.mjs import { defineConfig, fontProviders } from 'astro/config' export default defineConfig({ experimental: { fonts: [{ name: 'Roboto', cssVariable: '--font-roboto', provider: fontProviders.google(), + formats: ['woff2', 'woff', 'otf'] }] } }) -
#15179
8c8aee6Thanks @HiDeoo! - Fixes an issue when importing using an import alias a file with a name matching a directory name. -
#15176
9265546Thanks @matthewp! - Fixes scripts in components not rendering when a sibling<Fragment slot="...">exists but is unused
Patch Changes
-
#15064
caf5621Thanks @ascorbic! - Fixes a bug that caused incorrect warnings of duplicate entries to be logged by the glob loader when editing a file -
#15093
8d5f783Thanks @matthewp! - Reduces build memory by filtering routes per environment so each only builds the pages it needs -
#15073
2a39c32Thanks @ascorbic! - Don't log an error when there is no content config -
#15112
5751d2bThanks @HiDeoo! - Fixes a Windows-specific build issue when importing an Astro component with a<script>tag using an import alias.
Major Changes
- #15049
beddfebThanks @Ntale3! - Removes the ability to render Astro components in Vitest client environments - (v6 upgrade guidance)
Patch Changes
Major Changes
-
#15006
f361730Thanks @florian-lefebvre! - Removes sessiontestdriver - (v6 upgrade guidance) -
#15006
f361730Thanks @florian-lefebvre! - Deprecates session driver string signature - (v6 upgrade guidance)
Minor Changes
-
#15006
f361730Thanks @florian-lefebvre! - Adds new session driver object shapeFor 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.
Patch Changes
-
#15044
7cac71bThanks @florian-lefebvre! - Removes an exposed internal API of the preview server -
#15047
5580372Thanks @matthewp! - Fixes wrangler config template inastro add cloudflareto use correct entrypoint and compatibility date -
#15053
674b63fThanks @matthewp! - Excludesastro:*andvirtual:astro:*from client optimizeDeps in core. Needed for prefetch users since virtual modules are now in the dependency graph.
Patch Changes
-
#15024
22c48baThanks @florian-lefebvre! - Fixes a case where JSON schema generation would fail for unrepresentable types -
#15036
f125a73Thanks @florian-lefebvre! - Fixes certain aliases not working when using images in JSON files with the content layer -
#15036
f125a73Thanks @florian-lefebvre! - Fixes a vite warning log during builds when using npm
Major Changes
-
#14956
0ff51dfThanks @matthewp! - Astro v6.0 upgrades to Zod v4 for schema validation - (v6 upgrade guidance) -
#14759
d7889f7Thanks @florian-lefebvre! - Updates how schema types are inferred for content loaders with schemas (Loader API) - (v6 upgrade guidance) -
#14306
141c4a2Thanks @ematipico! - Removes support for routes with percent-encoded percent signs (e.g.%25) - (v6 upgrade guidance) -
#14759
d7889f7Thanks @florian-lefebvre! - Removes the option to define dynamic schemas in content loaders as functions and adds a new equivalentcreateSchema()property (Loader API) - (v6 upgrade guidance) -
#14306
141c4a2Thanks @ematipico! - RemovesRouteData.generatefrom the Integration API - (v6 upgrade guidance) -
#14989
73e8232Thanks @florian-lefebvre! - Deprecates exposedastro:transitionsinternals - (v6 upgrade guidance) -
#14758
010f773Thanks @florian-lefebvre! - Removes thesetManifestDatamethod fromAppandNodeApp(Adapter API) - (v6 upgrade guidance) -
#14826
170f64eThanks @florian-lefebvre! - Removes theexperimental.failOnPrerenderConflictflag and replaces it with a new configuration optionprerenderConflictBehavior- (v6 upgrade guidance) -
#14923
95a1969Thanks @florian-lefebvre! - Deprecatesastro:schemaandzfromastro:contentin favor ofastro/zod- (v6 upgrade guidance) -
#14844
8d43b1dThanks @trueberryless! - Removes exposedastro:actionsinternals - (v6 upgrade guidance) -
#14306
141c4a2Thanks @ematipico! - Changes the shape ofSSRManifestproperties and adds several new required properties in the Adapter API - (v6 upgrade guidance) -
#14306
141c4a2Thanks @ematipico! - Changes integration hooks and HMR access patterns in the Integration API - (v6 upgrade guidance) -
#14306
141c4a2Thanks @ematipico! - Removes the unusedastro:ssr-manifestvirtual module - (v6 upgrade guidance)
Minor Changes
-
#14306
141c4a2Thanks @ematipico! - Adds new optional properties tosetAdapter()for adapter entrypoint handling in the Adapter APIChanges:
- New optional properties:
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.
- New optional properties:
-
#14826
170f64eThanks @florian-lefebvre! - Adds an optionprerenderConflictBehaviorto configure the behavior of conflicting prerendered routesBy 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-1path. 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
prerenderConflictBehaviorconfiguration 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 occur
import { defineConfig } from 'astro/config'; export default defineConfig({ + prerenderConflictBehavior: 'error', }); -
#14946
95c40f7Thanks @ematipico! - Removes theexperimental.cspflag and replaces it with a new configuration optionsecurity.csp- (v6 upgrade guidance)
Patch Changes
- #14982
6849e38Thanks @Princesseuh! - Fixes images outside the project directory not working when using astro:assets in development mode
Patch Changes
- Updated dependencies [
c2cd371]:- @astrojs/internal-helpers@0.7.6
- @astrojs/markdown-remark@6.3.11
Minor Changes
-
#15589
b7dd447Thanks @qzio! - Adds a newsecurity.actionBodySizeLimitoption 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.
// astro.config.mjs export default defineConfig({ security: { actionBodySizeLimit: 10 * 1024 * 1024, // set to 10 MB }, });
Patch Changes
Patch Changes
-
#15334
d715f1fThanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API onlyRemoves the
getFontBuffer()helper function exported fromastro:assetswhen using the experimental Fonts APIThis 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:
- On prerendered routes, read the file using
node:fs - On server rendered routes, fetch files using URLs from
fontDataandcontext.url
- On prerendered routes, read the file using
Minor Changes
-
#14932
b19d816Thanks @patrickarlt! - Adds support for returning a Promise from theparser()option of thefile()loaderThis 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
f220726Thanks @mark-ignacio! - Adds a new, optionalkernelconfiguration option to select a resize algorithm in the Sharp image serviceBy default, Sharp resizes images with the
lanczos3kernel. 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
08e0fd7Thanks @jmortlock! - Adds a newpartitionedoption 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: truewhen setting a cookie. Note that partitioned cookies must also be set withsecure: true:Astro.cookies.set('my-cookie', 'value', { partitioned: true, secure: true, });For more information, see the
AstroCookieSetOptionsAPI reference. -
#15022
f1fce0eThanks @ascorbic! - Adds a newretainBodyoption to theglob()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
retainBodyoption defaults totrue, but you can set it tofalseto 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.htmlproperty for markdown files, and theentry.filePathproperty 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
retainBodyisfalse,entry.bodywill beundefinedinstead of containing the raw file contents. -
#15153
928529fThanks @jcayzac! - Adds a newbackgroundproperty 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 forbackgroundon an<Image />component, or passing it to thegetImage()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
54f6006Thanks @tony! - Adds optionalplacementconfig option for the dev toolbar.You can now configure the default toolbar position (
'bottom-left','bottom-center', or'bottom-right') viadevToolbar.placementin 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):
// astro.config.mjs 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.
Patch Changes
-
#15281
a1b80c6Thanks @matthewp! - Ensures server island requests carry an encrypted component export identifier so they do not accidentally resolve to the wrong component. -
#15304
02ee3c7Thanks @cameronapak! - Fix: Remove await from getActionResult example -
#15324
ab41c3eThanks @Princesseuh! - Fixes an issue where certain unauthorized links could be rendered as clickable in the error overlay
Patch Changes
- #15286
0aafc83Thanks @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
Patch Changes
-
#15213
c775fceThanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API onlyUpdates 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
c775fceThanks @florian-lefebvre! - ExposesrootonFontProviderinit()contextWhen building a custom
FontProviderfor the experimental Fonts API, theinit()method receives acontext. This context now exposes arootURL, useful for resolving local files:import type { FontProvider } from "astro"; export function registryFontProvider(): FontProvider { return { // ... - init: async ({ storage }) => { + init: async ({ storage, root }) => { // ... }, }; } -
#15185
edabeaaThanks @EricGrill! - Add.vercelto.gitignorewhen adding the Vercel adapter viaastro add vercel
Patch Changes
-
#15182
cb60ee1Thanks @florian-lefebvre! - Adds a newgetFontBuffer()method to retrieve font file buffers when using the experimental Fonts APIThe
getFontData()helper function fromastro:assetswas 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 fromastro:assetsto retrieve font file buffers from URL returned bygetFontData(). For example, when using satori to generate OpenGraph images:// src/pages/og.png.ts 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.
Patch Changes
-
#15175
47ae148Thanks @florian-lefebvre! - Allows experimental Font providers to specify family optionsPreviously, an Astro
FontProvidercould 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:// font-provider.ts 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:
// astro.config.ts 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
47ae148Thanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API onlyUpdates 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
optionsproperty 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
c0595b3Thanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API onlyRemoves
getFontData()exported fromastro:assetswithfontDatawhen using the experimental Fonts APIAccessing 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 givencssVariable. That was however limiting for programmatic usages that need to access all font data.The
getFontData()helper function is removed and replaced by a newfontDataobject:-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
8d84b30Thanks @lamalex! - Fixes CSSassetsPrefixwith remote URLs incorrectly prepending a forward slashWhen using
build.assetsPrefixwith 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
731f52dThanks @kedarvartak! - Fixes an issue where stopping the dev server withq+enterincorrectly created adistfolder and copied font files when using the experimental Fonts API -
#15230
3da6272Thanks @rahuld109! - Fixes greedy regex in error message markdown rendering that caused link syntax examples to capture extra characters -
#15253
2a6315aThanks @matthewp! - Fixes hydration for React components nested inside HTML elements in MDX files -
#15227
9a609f4Thanks @matthewp! - Fixes styles not being included for conditionally rendered Svelte 5 components in production builds -
#14607
ee52160Thanks @simensfo! - Reintroduces css deduplication for hydrated client components. Ensures assets already added to a client chunk are not flagged as orphaned
Patch Changes
-
2fa19c4- Improved error handling in the rendering phaseAdded 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
d8e64efThanks @ArmandPhilippot! - Fixes the links to Astro Docs so that they match the current docs structure. -
#15169
b803d8bThanks @rururux! - fix: fix image 500 error when moving dist directory in standalone Node -
#14622
9b35c62Thanks @aprici7y! - Fixes CSS url() references to public assets returning 404 in dev mode when base path is configured -
#15219
43df4ceThanks @matthewp! - Upgrades thediffpackage to v8
Patch Changes
-
#15174
37ab65aThanks @florian-lefebvre! - Adds Google Icons to built-in font providersTo 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
a77c4f4Thanks @matthewp! - Fixes hydration for framework components inside MDX when usingAstro.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
9b726c4Thanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API onlyChanges how font providers are implemented with updates to the
FontProvidertypeThis is an implementation detail that changes how font providers are created. This process allows Astro to take more control rather than relying directly on
unifonttypes. 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 onunifonttypes will require an update to your project code.Previously, an Astro
FontProviderwas made of a config and a runtime part. It relied directly onunifonttypes, 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).
What should I do?
If you were using a 3rd-party
unifontfont provider, you will now need to write an AstroFontProviderusing it under the hood. For example:// astro.config.ts 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
9cd5b87Thanks @matthewp! - Fixes scripts in components not rendering when a sibling<Fragment slot="...">exists but is unused
Patch Changes
-
#15124
81db3c0Thanks @leonace924! - Fixes an issue where requests with query parameters to thebasepath would return a 404 if trailingSlash was not'ignore'in development -
#15152
39ee41fThanks @rururux! - Fixes a case wherecontext.cookies.set()would be overriden when setting cookies via response headers in development -
#15140
6f6f8f8Thanks @cameronraysmith! - Fixes esbuild warning due to dead code in assets virtual module -
#15127
2cff904Thanks @Princesseuh! - Updates "Unsupported page types found" error to only appear in more realistic cases -
#15149
34f84c2Thanks @rahuld109! - Skips "Use the Image component" audit warning for images inside framework components (React, Vue, Svelte, etc.)
Patch Changes
-
#15122
b137946Thanks @florian-lefebvre! - Improves JSDoc annotations forAstroGlobal,AstroSharedContextandAPIContexttypes -
#15123
3f58fa2Thanks @43081j! - Improves rendering performance by grouping render chunks when emitting from async iterables to avoid encoding costs -
#14954
7bec4bdThanks @volpeon! - Fixes remote imagesEtagheader handling by disabling internal cache -
#15052
b2bcd5aThanks @Princesseuh! - Fixes images not working in development when using setups with port forwarding -
#15028
87b19b8Thanks @Princesseuh! - Fixes certain aliases not working when using images in JSON files with the content layer -
#15118
cfa382bThanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API onlyRemoves the
defineAstroFontProvider()type helper.If you are building a custom font provider, remove any occurrence of
defineAstroFontProvider()and use theFontProvidertype 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
4e28db8Thanks @delucis! - Reduces Astro’s install size by around 8 MB -
#15088
a19140fThanks @martrapp! - Enables the ClientRouter to preserve the original hash part of the target URL during server side redirects. -
#15117
b1e8e32Thanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API onlyChanges the font format downloaded by default when using the experimental Fonts API. Additionally, adds a new
formatsconfiguration option to specify which font formats to download.Previously, Astro was opinionated about which font sources would be kept for usage, mainly keeping
woff2andwofffiles.You can now specify what font formats should be downloaded (if available). Only
woff2files are downloaded by default.What should I do?
If you were previously relying on Astro downloading the
woffformat, you will now need to specify this explicitly with the newformatsconfiguration option. Additionally, you may also specify any additional file formats to download if available:// astro.config.mjs import { defineConfig, fontProviders } from 'astro/config' export default defineConfig({ experimental: { fonts: [{ name: 'Roboto', cssVariable: '--font-roboto', provider: fontProviders.google(), + formats: ['woff2', 'woff', 'otf'] }] } }) -
#15034
8115752Thanks @florian-lefebvre! - Fixes a vite warning log during builds when using npm
Patch Changes
-
#14982
6849e38Thanks @Princesseuh! - Fixes images outside the project directory not working when using astro:assets in development mode -
#14987
9dd9fcaThanks @Princesseuh! - Fixes SVGs not working in dev mode when using the passthrough image service -
#15014
a178422Thanks @delucis! - Adds support for extending the type of the props accepted by Astro’s<Image>component,<Picture>component, andgetImage()API.
Patch Changes
-
#14985
c016f10Thanks @florian-lefebvre! - Fixes a case where JSDoc annotations wouldn't show for fonts related APIs in the Astro config -
#14973
ed7cc2fThanks @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 ingenerateLookupMap. -
#14958
70eb542Thanks @ascorbic! - Gives a helpful error message if a user setsoutput: "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 thanoutput: "server". This change adds a helpful error message to guide humans and robots. -
#14901
ef53716Thanks @Darknab! - Updates theglob()loader to log a warning when duplicated IDs are detected -
Updated dependencies [
d8305f8]:- @astrojs/markdown-remark@6.3.10
Patch Changes
-
#14940
2cf79c2Thanks @ematipico! - Fixes a bug where Astro didn't properly combine CSP resources from thecspconfiguration with those added using the runtime API (Astro.csp.insertDirective()) to form grammatically correct CSP headersNow 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.
Patch Changes
-
#14889
4bceeb0Thanks @florian-lefebvre! - Fixes actions types when using specific TypeScript configurations -
#14929
e0f277dThanks @matthewp! - Fixes authentication bypass via double URL encoding in middlewarePrevents attackers from bypassing path-based authentication checks using multi-level URL encoding (e.g.,
/%2561dmininstead of/%61dmin). Pathnames are now validated after decoding to ensure no additional encoding remains.
Patch Changes
-
#14876
b43dc7fThanks @florian-lefebvre! - Fixes a vite warning log during builds when using npm -
#14884
10273e0Thanks @florian-lefebvre! - Fixes a case where setting the status of a page to404in ssr would show an empty page (or404.astropage if provided) instead of using the current page
Patch Changes
-
#14769
b43ee71Thanks @adriandlam! - Fixes an unhandled rejection issue when using Astro with Vercel Workflow DevKit -
#14761
345eb22Thanks @ooga! - Updatesbuttonattributes types to allowcommandandcommandfor -
#14866
65e214bThanks @GameRoMan! - FixesAstro.globto be correctly marked as deprecated -
#14894
1ad9a5bThanks @delucis! - Fixes support for Astro component rendering in Vitest test suites using a “client” environment such ashappy-domorjsdom -
#14782
abed929Thanks @florian-lefebvre! - Improves syncing
Minor Changes
-
#13880
1a2ed01Thanks @azat-io! - Adds experimental SVGO optimization support for SVG assetsAstro 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
2e845feThanks @ascorbic! - Adds a hint for code agents to use the--yesflag to skip prompts when runningastro add -
#14698
f42ff9bThanks @mauriciabad! - Adds theActionInputSchemautility type to automatically infer the TypeScript type of an action's input based on its Zod schemaFor 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
4356485Thanks @jacobdalamb! - Adds new CLI shortcuts available when runningastro preview:o+enter: open the site in your browserq+enter: quit the previewh+enter: print all available shortcuts
Patch Changes
-
#14813
e1dd377Thanks @ematipico! - Removespicocolorsas dependency in favor of the forkpiccolore. -
#14609
d774306Thanks @florian-lefebvre! - Improvesastro info -
#14796
c29a785Thanks @florian-lefebvre! - BREAKING CHANGE to the experimental Fonts API onlyUpdates the default
subsetsto["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"] }] } })
Patch Changes
-
#14786
758a891Thanks @mef! - Add handling of invalid encrypted props and slots in server islands. -
#14783
504958fThanks @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
9e9c528Thanks @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.mjsfile to include the following configuration:// astro.config.mjs import { defineConfig } from 'astro/config'; export default defineConfig({ images: { remotePatterns: [ { protocol: 'data', }, ], }, }); -
#14787
0f75f6bThanks @matthewp! - Fixes wildcard hostname pattern matching to correctly reject hostnames without dotsPreviously, hostnames like
localhostor 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
3537876Thanks @ktym4a! - Fixes the behavior ofpassthroughImageServiceso it does not generate webp. -
Updated dependencies [
9e9c528,0f75f6b]:- @astrojs/internal-helpers@0.7.5
- @astrojs/markdown-remark@6.3.9
Patch Changes
-
#14772
00c579aThanks @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
6f80081Thanks @matthewp! - Fix middleware pathname matching by normalizing URL-encoded pathsMiddleware now receives normalized pathname values, ensuring that encoded paths like
/%61dminare properly decoded to/adminbefore middleware checks. This prevents potential security issues where middleware checks might be bypassed through URL encoding.
Patch Changes
-
#14765
03fb47cThanks @florian-lefebvre! - Fixes a case whereprocess.envwouldn't be properly populated during the build -
#14690
ae7197dThanks @fredriknorlin! - Fixes a bug where Astro's i18n fallback system withfallbackType: 'rewrite'would not generate fallback files for pages whose filename started with a locale key.
Patch Changes
-
#14751
18c55e1Thanks @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
35122c2Thanks @florian-lefebvre! - Updates the experimental Fonts API to log a warning if families with a conflictingcssVariableare provided -
#14737
74c8852Thanks @Arecsu! - Fixes an error when usingtransition:persistwith 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
35122c2Thanks @florian-lefebvre! - Updates the experimental Fonts API to allow for more granular configuration of remote font familiesA font family is defined by a combination of properties such as weights and styles (e.g.
weights: [500, 600]andstyles: ["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, andproviderproperties) multiple times with different combinations. Astro will merge the results and download only the required files. For example, it is possible to download normal500and600while downloading only italic500:// astro.config.mjs 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'], }, ], }, });
Patch Changes
-
#14712
91780cfThanks @florian-lefebvre! - Fixes a case where build'sprocess.envwould be inlined in the server output -
#14713
666d5a7Thanks @florian-lefebvre! - Improves fallbacks generation when using the experimental Fonts API -
#14743
dafbb1bThanks @matthewp! - ImprovesX-Forwardedheader validation to prevent cache poisoning and header injection attacks. Now properly validatesX-Forwarded-Proto,X-Forwarded-Host, andX-Forwarded-Portheaders against configuredallowedDomainspatterns, rejecting malformed or suspicious values. This is especially important when running behind a reverse proxy or load balancer.
Patch Changes
-
#14703
970ac0fThanks @ArmandPhilippot! - Adds missing documentation for some public utilities exported fromastro:i18n. -
#14715
3d55c5dThanks @ascorbic! - Adds support for client hydration ingetContainerRenderer()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 callcontainer.addClientRenderer()with the appropriate client renderer entrypoint.See the
container-with-vitestdemo for a usage example, and the Container API documentation for more information on using framework components with the experimental Container API. -
#14711
a4d284dThanks @deining! - Fixes typos in documenting our error messages and public APIs. -
#14701
9be54c7Thanks @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
Patch Changes
-
#14627
b368de0Thanks @matthewp! - Fixes skew protection support for images and font URLsAdapter-level query parameters (
assetQueryParams) are now applied to all image and font asset URLs, including:- Dynamic optimized images via
/_imageendpoint - Static optimized image files
- Font preload tags and font requests when using the experimental Fonts API
- Dynamic optimized images via
-
#14631
3ad33f9Thanks @KurtGokhan! - Adds theastro/jsx-dev-runtimeexport as an alias forastro/jsx-runtime
Patch Changes
-
#14623
c5fe295Thanks @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
e3175d9Thanks @GameRoMan! - Updatesviteversion to fix CVE
Patch Changes
- #14612
18552c7Thanks @ematipico! - Fixes a regression introduced in Astro v5.14.7 that caused?urlimports to not work correctly. This release reverts #14142.
Minor Changes
-
#14543
9b3241dThanks @matthewp! - Adds two new adapter configuration optionsassetQueryParamsandinternalFetchHeadersto the Adapter API.Official and community-built adapters can now use
client.assetQueryParamsto 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.internalFetchHeadersto 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
add4277Thanks @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
5e7cebbThanks @florian-lefebvre! - Updatesastro add cloudflareto scaffold more configuration filesRunning
astro add cloudflarewill now emitwrangler.jsoncandpublic/.assetsignore, allowing your Astro project to work out of the box as a worker.
Patch Changes
-
#14591
3e887ecThanks @matthewp! - Adds TypeScript support for thecomponentsprop on MDXContentcomponent when usingawait render(). Developers now get proper IntelliSense and type checking when passing custom components to override default MDX element rendering. -
#14598
7b45c65Thanks @delucis! - Reduces terminal text styling dependency size by switching fromkleurtopicocolors -
#13826
8079482Thanks @florian-lefebvre! - Adds the option to specify in thepreloaddirective 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 900will be included when400is specified in apreloadobject.
Patch Changes
- #14590
577d051Thanks @matthewp! - Fixes image path resolution in content layer collections to support bare filenames. Theimage()helper now normalizes bare filenames like"cover.jpg"to relative paths"./cover.jpg"for consistent resolution behavior between markdown frontmatter and JSON content collections.
Patch Changes
-
#14582
7958c6bThanks @florian-lefebvre! - Fixes a regression that caused Actions to throw errors while loading -
#14567
94500bbThanks @matthewp! - Fixes the actions endpoint to return 404 for non-existent actions instead of throwing an unhandled error -
#14566
946fe68Thanks @matthewp! - Fixes handling malformed cookies gracefully by returning the unparsed value instead of throwingWhen 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 underlyingcookiepackage and prevents crashes when manually-set or corrupted cookies are encountered. -
#14142
73c5de9Thanks @P4tt4te! - Updates handling of CSS for hydrated client components to prevent duplicates -
#14576
2af62c6Thanks @aprici7y! - Fixes a regression that causedAstro.siteto always beundefinedingetStaticPaths()
Patch Changes
-
#14562
722bba0Thanks @erbierc! - Fixes a bug where the behavior of the "muted" HTML attribute was inconsistent with that of other attributes. -
#14538
51ebe6aThanks @florian-lefebvre! - Improves how Actions are implemented -
#14548
6cdade4Thanks @ascorbic! - Removes support for themaxAgeproperty incacheHintobjects returned by live loaders.:warning: Breaking change for experimental live content collections only
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
cacheHintobject now only supportstagsandlastModifiedproperties. 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
6cdade4Thanks @ascorbic! - Adds missingrenderedproperty to experimental live collections entry typeLive collections support a
renderedproperty 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
renderedproperty as before, and it will no longer produce TypeScript errors.
Patch Changes
-
#14525
4f55781Thanks @penx! - FixesdefineLiveCollection()types -
#14441
62ec8eaThanks @upsuper! - Updates redirect handling to be consistent acrossstaticandserveroutput, aligning with the behavior of other adapters.Previously, the Node.js adapter used default HTML files with meta refresh tags when in
staticoutput. 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
staticoutput. 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
ec3cbe1Thanks @abdo-spices! - Updates the<Font />component so that preload links are generated after the style tag, as recommended by capo.js
Patch Changes
- #14509
7e04cafThanks @ArmandPhilippot! - Fixes an error in the docs that specified an incorrect version for thesecurity.allowedDomainsrelease.
Patch Changes
Patch Changes
- #14440
a3e16abThanks @florian-lefebvre! - Fixes a case where the URLs generated by the experimental Fonts API would be incorrect in dev
Minor Changes
-
#13520
a31edb8Thanks @openscript! - Adds a new propertyroutePatternavailable toGetStaticPathsOptionsThis 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 ofgetStaticPaths(). This can be useful to calculate theparamsandpropsfor each page route.For example, you can now localize your route segments and return an array of static paths by passing
routePatternto a customgetLocalizedData()helper function. Theparamsobject will be set with explicit values for each route segment (e.g.locale,files, andslug). Then, these values will be used to generate the routes and can be used in your page template viaAstro.params.// src/pages/[...locale]/[files]/[slug].astro 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 static paths 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
dcfbd8cThanks @ADTC! - Adds a newSvgComponenttypeYou can now more easily enforce type safety for your
.svgassets by directly importingSVGComponentfromastro/types:--- // src/components/Logo.astro 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
16a23e2Thanks @Fryuni! - Warn on prerendered routes collision.Previously, when two dynamic routes
/[foo]and/[bar]returned values on theirgetStaticPathsthat 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
failOnPrerenderConflictcan be used to fail the build when such a collision occurs.
Patch Changes
-
#13811
69572c0Thanks @florian-lefebvre! - Adds a newgetFontData()method to retrieve lower-level font family data programmatically when using the experimental Fonts APIThe
getFontData()helper function fromastro:assetsprovides 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:// src/pages/og.png.ts 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.
Patch Changes
-
#14409
250a595Thanks @louisescher! - Fixes an issue whereastro infowould log errors to console in certain cases. -
#14398
a7df80dThanks @idawnlight! - Fixes an unsatisfiable type definition when callingaddServerRendereron an experimental container instance -
#13747
120866fThanks @jp-knj! - Adds automatic request signal abortion when the underlying socket closes in the Node.js adapterThe Node.js adapter now automatically aborts the
request.signalwhen the client connection is terminated. This enables better resource management and allows applications to properly handle client disconnections through the standardAbortSignalAPI. -
#14428
32a8acbThanks @drfuzzyness! - Force sharpService to return a Uint8Array if Sharp returns a SharedArrayBuffer -
#14411
a601186Thanks @GameRoMan! - Fixes relative links to docs that could not be opened in the editor.
Patch Changes
- Updated dependencies [
1e2499e]:- @astrojs/internal-helpers@0.7.3
- @astrojs/markdown-remark@6.3.7
Patch Changes
- #14402
54dcd04Thanks @FredKSchott! - Removes warning that caused unexpected console spam when using Bun
Patch Changes
-
#14300
bd4a70bThanks @louisescher! - Adds Vite version & integration versions to output ofastro info -
#14341
f75fd99Thanks @delucis! - Fixes support for declarative Shadow DOM when using the<ClientRouter>component -
#14350
f59581fThanks @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 incontent.config.tsrather thanlive.config.ts. -
#14343
13f7d36Thanks @florian-lefebvre! - Fixes a regression in non node runtimes
Patch Changes
-
#14294
e005855Thanks @martrapp! - Restores the ability to use Google AnalyticsHistory change triggerwith the<ClientRouter />. -
#14326
c24a8f4Thanks @jsparkdev! - Updatesviteversion to fix CVE -
#14108
218e070Thanks @JusticeMatthew! - Updates dynamic route split regex to avoid infinite retries/exponential complexity -
#14327
c1033beThanks @ascorbic! - Pins simple-swizzle to avoid compromised version
Patch Changes
-
#14286
09c5db3Thanks @ematipico! - BREAKING CHANGES only to the experimental CSP featureThe following runtime APIs of the
Astroglobal have been renamed:Astro.insertDirectivetoAstro.csp.insertDirectiveAstro.insertStyleResourcetoAstro.csp.insertStyleResourceAstro.insertStyleHashtoAstro.csp.insertStyleHashAstro.insertScriptResourcetoAstro.csp.insertScriptResourceAstro.insertScriptHashtoAstro.csp.insertScriptHash
The following runtime APIs of the
APIContexthave been renamed:ctx.insertDirectivetoctx.csp.insertDirectivectx.insertStyleResourcetoctx.csp.insertStyleResourcectx.insertStyleHashtoctx.csp.insertStyleHashctx.insertScriptResourcetoctx.csp.insertScriptResourcectx.insertScriptHashtoctx.csp.insertScriptHash
-
#14283
3224637Thanks @ematipico! - Fixes an issue where CSP headers were incorrectly injected in the development server. -
#14275
3e2f20dThanks @florian-lefebvre! - Adds support for experimental CSP when using experimental fontsExperimental fonts now integrate well with experimental CSP by injecting hashes for the styles it generates, as well as
font-srcdirectives.No action is required to benefit from it.
-
#14280
4b9fb73Thanks @ascorbic! - Fixes a bug that caused cookies to not be correctly set when using middleware sequences -
#14276
77281c4Thanks @ArmandPhilippot! - Adds a missing export forresolveSrc, a documented image services utility.
Patch Changes
-
#14260
86a1e40Thanks @jp-knj! - FixesAstro.url.pathnameto respecttrailingSlash: 'never'configuration when using a base path. Previously, the root path with a base would incorrectly return/base/instead of/basewhentrailingSlashwas set to 'never'. -
#14248
e81c4bdThanks @julesyoungberg! - Fixes a bug where actions named 'apply' do not work due to being a function prototype method.
Patch Changes
-
#14239
d7d93e1Thanks @wtchnm! - Fixes a bug where the types for the live content collections were not being generated correctly in dev mode -
#14221
eadc9ddThanks @delucis! - Fixes JSON schema support for content collections using thefile()loader -
#14229
1a9107aThanks @jonmichaeldarby! - EnsuresAstro.currentLocalereturns the correct locale during SSG for pages that use a locale param (such as[locale].astroor[locale]/index.astro, which produce[locale].html)
Patch Changes
-
4d16de7Thanks @ematipico! - Improves the detection of remote paths in the_imageendpoint. Nowhrefparameters that start with//are considered remote paths. -
Updated dependencies [
4d16de7]:- @astrojs/internal-helpers@0.7.2
- @astrojs/markdown-remark@6.3.6
Minor Changes
-
#14173
39911b8Thanks @florian-lefebvre! - Adds an experimental flagstaticImportMetaEnvto disable the replacement ofimport.meta.envvalues withprocess.envcalls and their coercion of environment variable values. This supersedes therawEnvValuesexperimental flag, which is now removed.Astro allows you to configure a type-safe schema for your environment variables, and converts variables imported via
astro:envinto 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.envandimport.meta.envdirectly when needed. This was the only way to use environment variables in Astro beforeastro:envwas added in Astro 5.0, and Astro's default handling ofimport.meta.envincludes some logic that was only needed for earlier versions of Astro.The
experimental.staticImportMetaEnvflag updates the behavior ofimport.meta.envto 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.envenvironment variables are replaced by a reference toprocess.env. Additionally, Astro may also convert the value type of your environment variables used throughimport.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.staticImportMetaEnvflag simplifies Astro's default behavior, making it easier to understand and use. Astro will no longer replace anyimport.meta.envenvironment variables with aprocess.envcall, nor will it coerce values.To enable this feature, add the experimental flag in your Astro config and remove
rawEnvValuesif it was enabled:// astro.config.mjs import { defineConfig } from "astro/config"; export default defineConfig({ + experimental: { + staticImportMetaEnv: true - rawEnvValues: false + } });Updating your project
If you were relying on Astro's default coercion, you may need to update your project code to apply it manually:
// src/components/MyComponent.astro - const enabled: boolean = import.meta.env.ENABLED; + const enabled: boolean = import.meta.env.ENABLED === "true";If you were relying on the transformation into
process.envcalls, you may need to update your project code to apply it manually:// src/components/MyComponent.astro - const enabled: boolean = import.meta.env.DB_PASSWORD; + const enabled: boolean = process.env.DB_PASSWORD;You may also need to update types:
// src/env.d.ts 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.envdocumentation for more information about this feature. You can learn more about using environment variables in Astro, includingastro:env, in the environment variables documentation. -
#14122
41ed3acThanks @ascorbic! - Adds experimental support for automatic Chrome DevTools workspace foldersThis 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
chromeDevtoolsWorkspaceto your Astro config:// astro.config.mjs import { defineConfig } from 'astro/config'; export default defineConfig({ experimental: { chromeDevtoolsWorkspace: true, }, });See the experimental Chrome DevTools workspace feature documentation for more information.
Patch Changes
-
#14020
9518975Thanks @jp-knj and @asieradzk! - Prevent double-prefixed redirect paths when using fallback and redirectToDefaultLocale togetherFixes an issue where i18n fallback routes would generate double-prefixed paths (e.g.,
/es/es/test/item1/) whenfallbackandredirectToDefaultLocaleconfigurations were used together. The fix adds proper checks to prevent double prefixing in route generation. -
#14199
3e4cb8eThanks @ascorbic! - Fixes a bug that prevented HMR from working with inline styles
Patch Changes
-
0567fb7Thanks @ascorbic! - Adds//to list of internal path prefixes that do not have automated trailing slash handling -
#13894
b36e72fThanks @florian-lefebvre! - Removes Astro Studio commands from the CLI help -
Updated dependencies [
0567fb7]:- @astrojs/internal-helpers@0.7.1
- @astrojs/markdown-remark@6.3.5
Patch Changes
-
#14169
f4e8889Thanks @ascorbic! - Skips trailing slash handling for paths that start with/.. -
#14170
34e6b3aThanks @ematipico! - Fixes an issue where static redirects couldn't correctly generate a redirect when the destination is a prerendered route, and theoutputis set to"server". -
#14169
f4e8889Thanks @ascorbic! - Fixes a bug that prevented images from being displayed in dev when using the Netlify adapter withtrailingSlashset toalways -
Updated dependencies [
f4e8889]:- @astrojs/internal-helpers@0.7.0
- @astrojs/markdown-remark@6.3.4
Patch Changes
-
#14153
29e9283Thanks @jp-knj! - Fixes a regression introduced by a recent optimisation of how SVG images are emitted during the build. -
#14156
592f08dThanks @TheOtterlord! - Fix the client router not submitting forms if the active URL contained a hash -
#14160
d2e25c6Thanks @ascorbic! - Fixes a bug that meant some remote image URLs could cause invalid filenames to be used for processed images -
#14167
62bd071Thanks @ascorbic! - Fixes a bug that prevented destroyed sessions from being deleted from storage unless the session had been loaded
Patch Changes
-
#14059
19f53ebThanks @benosmac! - Fixes a bug in i18n implementation, where Astro didn't emit the correct pages whenfallbackis enabled, and a locale uses a catch-all route, e.g.src/pages/es/[...catchAll].astro -
#14155
31822c3Thanks @ascorbic! - Fixes a bug that caused an error "serverEntrypointModule[_start] is not a function" in some adapters
Patch Changes
-
#14031
e9206c1Thanks @jp-knj! - Optimized the build pipeline for SVG images. Now, Astro doesn't reprocess images that have already been processed. -
#14132
976879aThanks @ematipico! - Fixes a bug where the propertyAstro.routePattern/context.routePatternwasn't updated when using a rewrite via middleware. -
#14131
aafc4d7Thanks @florian-lefebvre! - Fixes a case where an error occurring in a middleware would show the dev overlay instead of the custom500.astropage -
#14127
2309adaThanks @florian-lefebvre! - Upgrades zod -
#14134
186c201Thanks @ascorbic! - Throws a more helpful error in dev if trying to use a server island without an adapter -
#14129
3572d85Thanks @ematipico! - Fixes a bug where the CSP headers was incorrectly added to a page when using an adapter.
Patch Changes
-
#14119
14807a4Thanks @ascorbic! - Fixes a bug that caused builds to fail if a client directive was mistakenly added to an Astro component -
#14001
4b03d9cThanks @dnek! - Fixes an issue wheregetImage()assigned the resized base URL to the srcset URL ofImageTransform, which matched the width, height, and format of the original image.
Patch Changes
-
#14071
d2cb35dThanks @Grisoly! - Exposes theCodecomponentlangprop type:import type { CodeLanguage } from 'astro'; -
#14111
5452ee6Thanks @ascorbic! - Fixes a bug that prevented "key" from being used as a prop for Astro components in MDX -
#14106
b5b39e4Thanks @ascorbic! - Exits with non-zero exit code when config has an error -
#14112
37458b3Thanks @ascorbic! - Fixes a bug that meant that SVG components could no longer be serialized withJSON.stringify -
#14061
c7a7dd5Thanks @jonasgeiler! - Add module declaration for?no-inlineasset imports -
#14109
5a08fa2Thanks @ascorbic! - Throw a more helpful error if defineLiveCollection is used outside of a live.config file -
#14110
e7dd4e1Thanks @ascorbic! - Warn if duplicate IDs are found by file loader
Patch Changes
-
#14094
22e9087Thanks @ascorbic! - Correct types to allowpriorityon all images -
#14091
26c6b6dThanks @ascorbic! - Fixes a bug that caused a type error when defining session options without a driver -
#14082
93322cbThanks @louisescher! - Fixes an issue where Astro's default 404 route would incorrectly match routes containing "/404" in dev -
#14089
687d253Thanks @florian-lefebvre! - Fixes a case whereastro:envwould not load the right environments variables in dev -
#14092
6692c71Thanks @ascorbic! - Improves error handling in live collections -
#14074
144a950Thanks @abcfy2! - Fixes a bug that caused some image service builds to fail -
#14092
6692c71Thanks @ascorbic! - Fixes a case where zod could not be imported fromastro:contentvirtual module in live collection config
Minor Changes
-
#13971
fe35ee2Thanks @adamhl8! - Adds an experimental flagrawEnvValuesto disable coercion ofimport.meta.envvalues (e.g. converting strings to other data types) that are populated fromprocess.envAstro allows you to configure a type-safe schema for your environment variables, and converts variables imported via
astro:envinto the expected type.However, Astro also converts your environment variables used through
import.meta.envin 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.rawEnvValuesflag disables coercion ofimport.meta.envvalues that are populated fromprocess.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
6bd5f75Thanks @aditsachde! - Adds support for TOML files to Astro's built-inglob()andfile()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 thefile()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:// src/content.config.ts 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 theidfield of the entry object.See Astro's content collections guide for more information on using the built-in content loaders.
Patch Changes
- Updated dependencies [
6bd5f75]:- @astrojs/markdown-remark@6.3.3
Patch Changes
-
#14045
3276b79Thanks @ghubo! - Fixes a problem where importing animated.aviffiles returns aNoImageMetadataerror. -
#14041
0c4d5f8Thanks @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 preventedevent.viewTransition?.skipTransition()from skipping the page exit animation when used in anastro:before-swapevent hook.
Minor Changes
-
#13972
db8f8beThanks @ematipico! - Updates theNodeApp.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 givenRequest. If there is a prerendered route, the function returnsundefined, 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).
Patch Changes
-
#14029
42562f9Thanks @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
8d238bcThanks @dmgawel! - Fixes a bug where i18n fallback rewrites didn't work in dynamic pages.
Patch Changes
-
#14000
3cbedaeThanks @feelixe! - Fix routePattern JSDoc examples to show correct return values -
#13990
de6cfd6Thanks @isVivek99! - Fixes a case whereastro:config/clientandastro:config/servervirtual modules would not contain config passed to integrationsupdateConfig()during the build -
#14019
a160d1eThanks @ascorbic! - Removes the requirement to settype: 'live'when defining experimental live content collectionsPreviously, live collections required a
typeandloaderconfigured. Now, Astro can determine that your collection is alivecollection without defining it explicitly.This means it is now safe to remove
type: 'live'from your collections defined insrc/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
598da21Thanks @msamoylov! - Fixes a broken link on the default 404 page in development
Patch Changes
-
#13988
609044cThanks @ascorbic! - Fixes a bug in live collections that caused it to incorrectly complain about the collection being defined in the wrong file -
#13909
b258d86Thanks @isVivek99! - Fixes rendering of special boolean attributes for custom elements -
#13983
e718375Thanks @florian-lefebvre! - Fixes a case where the toolbar audit would incorrectly flag images processed by Astro in content collections documents -
#13999
f077b68Thanks @ascorbic! - AddslastModifiedfield to experimental live collection cache hintsLive loaders can now set a
lastModifiedfield in the cache hints for entries and collections to indicate when the data was last modified. This is then available in thecacheHintfield returned bygetCollectionandgetEntry. -
#13987
08f34b1Thanks @ematipico! - Adds an informative message in dev mode when the CSP feature is enabled. -
#14005
82aad62Thanks @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
0b4c641Thanks @jsparkdev! - Updates wrong link
Minor Changes
-
#13917
e615216Thanks @ascorbic! - Adds a newpriorityattribute for Astro's image components.This change introduces a new
priorityoption for the<Image />and<Picture />components, which automatically sets theloading,decoding, andfetchpriorityattributes 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
priorityas 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 settingloading="lazy"anddecoding="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
priorityattribute 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.
Usage
<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
e615216Thanks @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.responsiveStylesoption in your Astro config. Then, set alayoutattribute on anyor
component, or configure a default image.layout, for instantly responsive images with automatically generatedsrcsetandsizesattributes 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.
Migration from Experimental Responsive Images
The
experimental.responsiveImagesflag 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:
Remove the experimental flag
export default defineConfig({ experimental: { - responsiveImages: true, }, });Update image configuration options
During the experimental phase, default styles were applied automatically to responsive images. Now, you need to explicitly set the
responsiveStylesoption totrueif 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 }, });Component usage remains the same
The
layout,fit, andpositionprops 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
3c04c1fThanks @ascorbic! - Adds experimental support for live content collectionsLive 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.
Live collections vs build-time collections
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()andgetCollection(). 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.
How to use
To enable live collections add the
experimental.liveContentCollectionsflag to yourastro.config.mjsfile:{ experimental: { liveContentCollections: true, }, }Then create a new
src/live.config.tsfile (alongside yoursrc/content.config.tsif you have one) to define your live collections with a live loader and optionally a schema using the newdefineLiveCollection()function from theastro:contentmodule.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()andgetLiveEntry()functions to access your live data:--- import { getLiveCollection, getLiveEntry, render } from 'astro:content'; // Get all products const { 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 object const { 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.
Patch Changes
-
#13957
304df34Thanks @ematipico! - Fixes an issue wherereport-uriwasn't available inexperimental.csp.directives, causing a typing error and a runtime validation error. -
#13957
304df34Thanks @ematipico! - Fixes a type error for the CSP directivesupgrade-insecure-requests,sandbox, andtrusted-type. -
#13862
fe8f61aThanks @florian-lefebvre! - Fixes a case where the dev toolbar would crash if it could not retrieve some essential data -
#13976
0a31d99Thanks @florian-lefebvre! - Fixes a case where Astro Actions types would be broken when using atsconfig.jsonwith"moduleResolution": "nodenext"
Patch Changes
-
#13923
a9ac5edThanks @ematipico! - BREAKING CHANGE to the experimental Content Security Policy (CSP) onlyChanges the behavior of experimental Content Security Policy (CSP) to now serve hashes differently depending on whether or not a page is prerendered:
- Via the
<meta>element for static pages. - Via the
Responseheadercontent-security-policyfor 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.
- Via the
-
#13926
953a249Thanks @ematipico! - Adds a new Astro Adapter Feature calledexperimentalStaticHeadersto allow your adapter to receive theHeadersfor 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
experimentalRouteToHeaderswill contain a map ofMap<IntegrationResolvedRoute, Headers>where theHeaderstype contains the headers emitted by the rendered static route.To enable support for this experimental Astro Adapter Feature, add it to your
adapterFeaturesin your adapter config:// my-adapter.mjs 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
af83b85Thanks @benosmac! - Fixes issues with fallback route pattern matching wheni18n.routing.fallbackTypeisrewrite.- Adds conditions for route matching in
generatePathwhen building fallback routes and checking for existing translated pages
Now for a route to be matched it needs to be inside a named
[locale]folder. This fixes an issue whereroute.pattern.test()incorrectly matched dynamic routes, causing the page to be skipped.- Adds conditions for route matching in
findRouteToRewrite
Now the requested pathname must exist in
route.distURLfor a dynamic route to match. This fixes an issue whereroute.pattern.test()incorrectly matched dynamic routes, causing the build to fail. - Adds conditions for route matching in
-
#13924
1cd8c3bThanks @qw-in! - Fixes an edge case whereisPrerenderedwas incorrectly set tofalsefor static redirects. -
#13926
953a249Thanks @ematipico! - Fixes an issue where the experimental CSPmetaelement wasn't placed in the<head>element as early as possible, causing these policies to not apply to styles and scripts that came before themetaelement.
Patch Changes
-
#13919
423fe60Thanks @ematipico! - Fixes a bug where Astro added quotes to the CSP resources.Only certain resources require quotes (e.g.
'self'but nothttps://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
76c5480Thanks @ematipico! - BREAKING CHANGE to the experimental Content Security Policy feature onlyRemoves 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.
Patch Changes
-
#13899
7a1303dThanks @reknih! - Fix bug where error pages would return invalid bodies if the upstream response was compressed -
#13902
051bc30Thanks @arHSM! - Fixes a bug where vite virtual module ids were incorrectly added in the dev server -
#13905
81f71caThanks @jsparkdev! - Fixes wrong contents in CSP meta tag. -
#13907
8246bccThanks @martrapp! - Fixes a bug that caused view transition names to be lost. -
#13901
37fa0a2Thanks @ansg191! - fix fallback not being removed when server island is rendered
Minor Changes
-
#13802
0eafe14Thanks @ematipico! - Adds experimental Content Security Policy (CSP) supportCSP 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:
// astro.config.mjs 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
1766d22Thanks @ascorbic! - Provides a Markdown renderer to content loadersWhen creating a content loader, you will now have access to a
renderMarkdownfunction 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
renderMarkdownis an object with two properties:htmlandmetadata. These match therenderedproperty 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
62f0668Thanks @yanthomasdev! - Adds an option for integration authors to suppress adapter warning/errors insupportedAstroFeatures. 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) orsuppress: "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.
Patch Changes
-
#13877
5a7797fThanks @yuhang-dong! - Fixes a bug that causedAstro.rewriteto fail when used insequenced middleware -
#13872
442b841Thanks @isVivek99! - Fixes rendering of thedownloadattribute when it has a boolean value
Patch Changes
-
#13037
de2fc9bThanks @nanarino! - Fixes rendering of thepopoverattribute when it has a boolean value -
#13851
45ae95aThanks @ascorbic! - Allows disabling default styles for responsive imagesThis change adds a new
image.experimentalDefaultStylesoption 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.experimentalDefaultStylesis a boolean option that defaults totrue, so you can change it in your Astro config file like this:export default { image: { experimentalDefaultStyles: false, }, experimental: { responsiveImages: true, }, }; -
#13858
cb1a168Thanks @florian-lefebvre! - Fixes the warning shown when client directives are used on Astro components -
#12574
da266d0Thanks @apatel369! - Allows using server islands in mdx files -
#13843
fbcfa68Thanks @z1haze! - Export typeAstroSessionto allow use in explicitly typed safe code.
Minor Changes
-
#13809
3c3b492Thanks @ascorbic! - Increases minimum Node.js version to 18.20.8Node.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.
Patch Changes
- Updated dependencies [
3c3b492]:- @astrojs/telemetry@3.3.0
- @astrojs/markdown-remark@6.3.2
Patch Changes
-
#13773
3aa5337Thanks @sijad! - Ignores lightningcss unsupported pseudo-class warning. -
#13833
5a6d2aeThanks @ascorbic! - Fixes an issue where session modules would fail to resolve in Node.js < 20.6 -
#13383
f7f712cThanks @Haberkamp! - Stop toolbar settings from overflowing -
#13794
85b19d8Thanks @alexcarpenter! - Exclude pre tags froma11y-no-noninteractive-tabindexaudit check. -
#13373
50ef568Thanks @jpwienekus! - Fixes a bug where highlights and tooltips render over the audit list window. -
#13769
e9fc456Thanks @romanstetsyk! - Expand ActionError codes to include all IANA-registered HTTP error codes. -
#13668
866285aThanks @sapphi-red! - Replaces internal CSS chunking behavior for Astro components' scoped styles to use Vite'scssScopeTofeature. The feature is a port of Astro's implementation so this should not change the behavior.
Patch Changes
-
#13761
a2e8463Thanks @jp-knj! - Adds new content collections errors -
#13788
7d0b7acThanks @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
d7a1889Thanks @florian-lefebvre! - Fixes the experimental fonts API to correctly takeconfig.base,config.build.assetsandconfig.build.assetsPrefixinto account -
#13777
a56b8eaThanks @L4Ph! - Fixed an issue where looping GIF animation would stop when converted to WebP -
#13566
0489d8fThanks @TheOtterlord! - Fix build errors being ignored when build.concurrency > 1
Patch Changes
-
#13752
a079c21Thanks @florian-lefebvre! - Improves handling of font URLs not ending with a file extension when using the experimental fonts API -
#13750
7d3127dThanks @martrapp! - Allows the ClientRouter to open new tabs or windows when submitting forms by clicking while holding the Cmd, Ctrl, or Shift key. -
#13765
d874fe0Thanks @florian-lefebvre! - Fixes a case where font sources with relative protocol URLs would fail when using the experimental fonts API -
#13640
5e582e7Thanks @florian-lefebvre! - Allows inferringweightandstylewhen using the local provider of the experimental fonts APIIf 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 }
Patch Changes
-
#13734
30aec73Thanks @ascorbic! - Loosen content layer schema types -
#13751
5816b8aThanks @florian-lefebvre! - Updatesunifontto support subsets when using thegoogleprovider with the experimental fonts API -
#13756
d4547baThanks @florian-lefebvre! - Adds a terminal warning when a remote provider returns no data for a family when using the experimental fonts API -
#13742
f599463Thanks @florian-lefebvre! - Fixes optimized fallback css generation to properly add asrcwhen using the experimental fonts API -
#13740
6935540Thanks @vixalien! - Fix cookies set after middleware did a rewrite withnext(url)not being applied -
#13759
4a56d0aThanks @jp-knj! - Improved the error handling of certain error cases.
Patch Changes
- #13731
c3e80c2Thanks @jsparkdev! - update vite to latest version for fixing CVE
Patch Changes
- #13715
b32dffaThanks @florian-lefebvre! - Updatesunifontto fix a case where aunicodeRangerelated error would be thrown when using the experimental fonts API
Patch Changes
-
#13705
28f8716Thanks @florian-lefebvre! - Updates unifont to latest and adds support forfetchoptions from remote providers when using the experimental fonts API -
#13692
60d5be4Thanks @Le0Developer! - Fixes a bug where Astro couldn't probably useinferSizefor images that contain apostrophe'in their name. -
#13698
ab98f88Thanks @sarah11918! - Improves the configuration reference docs for theadapterentry with more relevant text and links. -
#13706
b4929aeThanks @ascorbic! - Fixes typechecking for content config schema -
#13653
a7b2dc6Thanks @florian-lefebvre! - Reduces the amount of preloaded files for the local provider when using the experimental fonts API -
#13653
a7b2dc6Thanks @florian-lefebvre! - Fixes a case where invalid CSS was emitted when using an experimental fonts API family name containing a space
Patch Changes
-
#13703
659904bThanks @florian-lefebvre! - Fixes a bug where empty fallbacks could not be provided when using the experimental fonts API -
#13680
18e1b97Thanks @florian-lefebvre! - Improves theUnsupportedExternalRedirecterror message to include more details such as the concerned destination -
#13703
659904bThanks @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-fitandobject-positionfor all images, and setsmax-width: 100%for constrained images andwidth: 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 onimg.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
!importantclasses. Do check if this is needed though: there may be a layout that is more appropriate for your use case. -
#13703
659904bThanks @ascorbic! - Adds warnings about using local font files in thepublicDirwhen the experimental fonts API is enabled. -
#13703
659904bThanks @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
responsivelayout 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 thewidthprop if provided.It became clear from user feedback that many people (understandably) thought that they needed to set
layouttoresponsiveif 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 usingfull-widthlayout. Renaming the layout toconstrainedshould 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.Upgrading
If you set a default
image.experimentalLayoutin yourastro.config.mjs, or set it on a per-image basis using thelayoutprop, you will need to change all occurences toconstrained:// astro.config.mjs export default { image: { - experimentalLayout: 'responsive', + experimentalLayout: 'constrained', }, }// src/pages/index.astro --- 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.
Patch Changes
-
#13660
620d15dThanks @mingjunlu! - Addsserver.allowedHostsdocs comment toAstroUserConfig -
#13591
5dd2d3fThanks @florian-lefebvre! - Removes unused code -
#13669
73f24d4Thanks @ematipico! - Fixes an issue whereAstro.originPathnamewasn't returning the correct value when using rewrites. -
#13674
42388b2Thanks @florian-lefebvre! - Fixes a case where an experimental fonts API error would be thrown when using anotherastro:assetsAPI -
#13654
4931457Thanks @florian-lefebvre! - FixesfontProviders.google()so it can forward options to the unifont provider, when using the experimental fonts API -
Updated dependencies [
5dd2d3f]:- @astrojs/telemetry@3.2.1
Patch Changes
-
#13647
ffbe8f2Thanks @ascorbic! - Fixes a bug that caused a session error to be logged when using actions without sessions -
#13646
6744842Thanks @florian-lefebvre! - Fixes a case where extra font sources were removed when using the experimental fonts API -
#13635
d75cac4Thanks @florian-lefebvre! - The experimental fonts API now generates optimized fallbacks for every weight and style
Patch Changes
-
#13643
67b7493Thanks @tanishqmanuja! - Fixes a case where the font facesrcformat would be invalid when using the experimental fonts API -
#13639
23410c6Thanks @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
Patch Changes
-
#13632
cb05cfbThanks @florian-lefebvre! - Improves the optimized fallback name generated by the experimental Fonts API -
#13630
3e7db4fThanks @florian-lefebvre! - Fixes a case where fonts using a local provider would not work because of an invalid generatedsrc -
#13634
516de7dThanks @ematipico! - Fixes a regression where usingnext('/')didn't correctly return the requested route. -
#13632
cb05cfbThanks @florian-lefebvre! - Improves the quality of optimized fallbacks generated by the experimental Fonts API -
#13616
d475afcThanks @lfilho! - Fixes a regression where relative static redirects didn't work as expected.
Patch Changes
-
#13594
dc4a015Thanks @florian-lefebvre! - Reduces the number of font files downloaded -
#13627
7f1a624Thanks @florian-lefebvre! - Fixes a case where using the<Font />component would throw a Rollup error during the build -
#13626
3838efeThanks @florian-lefebvre! - Updates fallback font generation to always read font files returned by font providers -
#13625
f1311d2Thanks @florian-lefebvre! - Updates the<Font />component so that preload links are generated before the style tag ifpreloadis passed -
#13622
a70d32aThanks @ascorbic! - Improve autocomplete for session keys
Minor Changes
-
#13527
2fd6a6bThanks @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' output const cart = await Astro.session.get('cart'); --- <a href="/checkout">🛒 {cart?.length ?? 0} items</a>Configuring session storage
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
sessionconfiguration option:import { defineConfig } from 'astro/config'; import vercel from '@astrojs/vercel'; export default defineConfig({ adapter: vercel(), session: { driver: 'upstash', }, });Using sessions
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
undefinedand 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 ---Upgrading from Experimental to Stable
If you were previously using the experimental API, please remove the
experimental.sessionflag 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
b1fe521Thanks @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.fontsobject 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
AstroFontProviderif 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
df3fd54Thanks @ematipico! - The virtual moduleastro:configintroduced 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:
// src/utils.js 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:
// astro.config.mjs 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:configreference for more about this feature. -
#13578
406501aThanks @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.
Patch Changes
-
#13602
3213450Thanks @natemoo-re! - Updates the Audit dev toolbar app to automatically stripdata-astro-source-fileanddata-astro-source-locattributes in dev mode. -
#13598
f5de51eThanks @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
d038030Thanks @sarah11918! - Adds the minimal starter template to the list ofcreate astrooptionsGood 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 runningcreate astro@latestand starting a new project!
Patch Changes
-
#13606
793ecd9Thanks @natemoo-re! - Fixes a regression that allowed prerendered code to leak into the server bundle. -
#13576
1c60ec3Thanks @ascorbic! - Reduces duplicate code in server islands scripts by extracting shared logic into a helper function. -
#13588
57e59beThanks @natemoo-re! - Fixes a memory leak when using SVG assets. -
#13589
5a0563dThanks @ematipico! - Deprecates the asset utility functionemitESMImage()and adds a newemitImageMetadata()to be used insteadThe 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 function
emitImageMetadata()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:
_watchModeandexperimentalSvgEnabled. Since it was possible to access these with the old function, you may need to verify that your code still works as intended withemitImageMetadata(). -
#13596
3752519Thanks @jsparkdev! - update vite to latest version to fix CVE -
#13547
360cb91Thanks @jsparkdev! - Updates vite to the latest version -
#13548
e588527Thanks @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 isdeno add react, which doesn't work. So, we change the package names to have an npm prefix if you are using Deno. -
#13587
a0774b3Thanks @robertoms99! - Fixes an issue with the client router where some attributes of the root element were not updated during swap, including the transition scope.
Patch Changes
-
#13519
3323f5cThanks @florian-lefebvre! - Refactors some internals to improve Rolldown compatibility -
#13545
a7aff41Thanks @stramel! - Prevent empty attributes from appearing in the SVG output -
#13552
9cd0fd4Thanks @ematipico! - Fixes an issue where Astro validated the i18n configuration incorrectly, causing false positives in downstream libraries.
Minor Changes
-
#13403
dcb9526Thanks @yurynix! - Adds a new optionalprerenderedErrorPageFetchoption 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 whenfetch()is unavailable or when you cannot call the server from itself.The following example provides a custom fetch for
500.htmland404.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
ff257dfThanks @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:setuphook has run. This meansupdateConfig()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
21e7e80Thanks @Marocco2! - Adds a neweagernessoption forprefetch()when usingexperimental.clientPrerenderWith the experimental
clientPrerenderflag enabled, you can use theeagernessoption onprefetch()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). Seteagerness: '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
ff257dfThanks @florian-lefebvre! - Improves integrations error handlingIf an error is thrown from an integration hook, an error log will now provide information about the concerned integration and hook
Patch Changes
-
#13539
c43bf8cThanks @ascorbic! - Adds a newsession.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.// src/pages/api/cart.ts 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
d777420Thanks @stramel! - BREAKING CHANGE to the experimental SVG Component API onlyRemoves 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
titleprop has been removed until we can settle on the correct balance between developer experience and accessibility. Please replace anytitleprops on your components witharia-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
modeoptions, and all SVGs will be inline. All instances ofmodemust 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
roleis no longer applied due to developer feedback. Please add the appropriateroleon each component individually as needed:- <Logo /> + <Logo role="img" /> // To keep the role that was previously applied by default -
The
sizeprop has been removed to better work in combination withviewBoxand additional styles/attributes. Please replacesizewith explicitwidthandheightattributes:- <Logo size={64} /> + <Logo width={64} height={64} />
-
Patch Changes
-
#13429
06de673Thanks @ematipico! - TheActionAPIContext.rewritemethod is deprecated and will be removed in a future major version of Astro -
#13524
82cd583Thanks @ematipico! - Fixes a bug where the functionsAstro.preferredLocaleandAstro.preferredLocaleListwould return the incorrect locales when the Astro configuration specifies a list ofcodes. Before, the functions would return thepath, instead now the functions return a list built fromcodes. -
#13526
ff9d69eThanks @jsparkdev! - updateviteto the latest version
Patch Changes
-
#13510
5b14d33Thanks @florian-lefebvre! - Fixes a case whereastro:envsecrets used in actions would not be available -
#13485
018fbe9Thanks @ascorbic! - Fixes a bug that caused cookies to ignore custom decode function if has() had been called before -
#13505
a98ae5bThanks @ematipico! - Updates the dependencyviteto the latest. -
#13483
fc2dcb8Thanks @ematipico! - Fixes a bug where an Astro adapter couldn't call the middleware when there isn't a route that matches the incoming request.
Patch Changes
-
#13457
968e713Thanks @ascorbic! - Sets correct response status text for custom error pages -
#13447
d80ba2bThanks @ematipico! - Fixes an issue wheresitewas added to the generated redirects. -
#13481
e9e9245Thanks @martrapp! - Makes server island work with the client router again. -
#13484
8b5e4dcThanks @ascorbic! - Display useful errors when config loading fails because of Node addons being disabled on Stackblitz
Patch Changes
-
#13437
013fa87Thanks @Vardhaman619! - Handle server.allowedHosts when the value is true without attempting to push it into an array. -
#13324
ea74336Thanks @ematipico! - Upgrade to shiki v3 -
#13372
7783dbfThanks @ascorbic! - Fixes a bug that caused some very large data stores to save incomplete data. -
#13358
8c21663Thanks @ematipico! - Adds a new function calledinsertPageRouteto 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/postand 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
565583bThanks @ascorbic! - Fixes a bug that caused theastro addcommand to ignore the--yesflag for third-party integrations -
#13428
9cac9f3Thanks @matthewp! - Prevent bad value in x-forwarded-host from crashing request -
#13432
defad33Thanks @P4tt4te! - Fix an issue in the Container API, where therenderToStringfunction doesn't render adequately nested slots when they are components. -
Updated dependencies [
ea74336]:- @astrojs/markdown-remark@6.3.1
Patch Changes
-
#13415
be866a1Thanks @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
2f039b9Thanks @ematipico! - It fixes an issue that caused some regressions in how styles are bundled.
Minor Changes
-
#13402
3e7b498Thanks @ematipico! - Adds a new experimental flag calledexperimental.preserveScriptOrderthat 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
preserveScriptOrderflag 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 thebodytag:<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
yellowappears first, and thenred. Ultimately, theredbackground is applied:body { background: #ff0; } body { background: red; }When
experimental.preserveScriptOrderis set totrue, the order of the two styles is kept as it is, and in the style generatedredappears first, and thenyellow: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
cb886dcThanks @delucis! - Adds support for a newexperimental.headingIdCompatflagBy 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:
// astro.config.mjs 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
rehypeHeadingIdsplugin directly, you can also pass this new option:// astro.config.mjs 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
a3327ffThanks @chrisirhc! - Adds a new configuration option for Markdown syntax highlightingexcludeLangsThis 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
mermaidandmathcode 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.
Patch Changes
-
#13404
4e78b4dThanks @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
d59eb22Thanks @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
6b8fdb8Thanks @renovate! - Updatesprimsjsto version 1.30.0, which adds support for more languages and fixes a security advisory which does not affect Astro. -
#13374
7b75bc5Thanks @ArmandPhilippot! - Fixes the documentation of the i18n configuration wheremanualwas presented as a key ofroutinginstead of an available value. -
#13380
9bfa6e6Thanks @martrapp! - Fixes an issue where astro:page-load fires before all scripts are executed -
#13407
0efdc22Thanks @ascorbic! - Displays correct error message when sharp isn't installed -
Updated dependencies [
cb886dc,a3327ff]:- @astrojs/markdown-remark@6.3.0
Patch Changes
-
#13381
249d52aThanks @martrapp! - Adds thetypesproperty to the viewTransition object when the ClientRouter simulates parts of the View Transition API on browsers w/o native support. -
#13367
3ce4ad9Thanks @ematipico! - Adds documentation to various utility functions used for remote image services -
#13347
d83f92aThanks @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
afadc70Thanks @ematipico! - Fixes a bug whereastro:config/serverandastro:config/clienthad incorrect types. -
#13355
042d1deThanks @ematipico! - Adds documentation to the assets utilities for remote service images. -
#13395
6d1c63fThanks @bluwy! - Usespackage-manager-detectorto detect the package manager used in the project -
#13363
a793636Thanks @ematipico! - Fixes an issue where the internal functionmakeSvgComponentwas incorrectly exposed as a public API. -
Updated dependencies [
042d1de]:- @astrojs/internal-helpers@0.6.1
- @astrojs/markdown-remark@6.2.1
Patch Changes
-
#12985
84e94ccThanks @matthewp! - Prevent re-executing scripts in client router -
#13349
50e2e0bThanks @ascorbic! - Correctly escapes attributes in Markdown images -
#13262
0025df3Thanks @ematipico! - Refactor Astro Actions to not use a middleware. Doing so should avoid unexpected issues when using the Astro middleware at the edge.
Patch Changes
-
#13336
8f632efThanks @ematipico! - Fixes a regression where some asset utilities were move across monorepo, and not re-exported anymore. -
#13320
b5dabe9Thanks @{! - Adds support for typing experimental session dataYou can add optional types to your session data by creating a
src/env.d.tsfile in your project that extends the globalApp.SessionDatainterface. 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.sessionin 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
5e7646eThanks @ematipico! - Fixes an issue with the conditional rendering of scripts.This change updates a v5.0 breaking change when
experimental.directRenderScriptbecame 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.
Minor Changes
-
#12052
5be12b2Thanks @Fryuni! - Exposes extra APIs for scripting and testing.Config helpers
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 ofupdateConfig()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.
Programmatic build
The
buildAPI now receives a second optionalBuildOptionsargument where users can specify:devOutput(defaultfalse): output a development-based build similar to code transformed inastro dev.teardownCompiler(defaulttrue): 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
4a43c4bThanks @ematipico! - Adds a new configuration optionserver.allowedHostsand 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.
allowedHostschecks 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.com// astro.config.mjs import { 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.allowHostsconfiguration. -
#13254
1e11f5eThanks @p0lyw0lf! - Adds the ability to process and optimize remote images in Markdown filesPreviously, 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 yourpublic/folder are still never processed.
Patch Changes
-
#13256
509fa67Thanks @p0lyw0lf! - Adds experimental responsive image support in MarkdownPreviously, the
experimental.responsiveImagesfeature 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.responsiveImagesto true in yourastro.config.mjsfile:{ 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
80926faThanks @ematipico! - Updatesesbuildandviteto the latest to avoid false positives audits warnings caused byesbuild. -
#13313
9e7c71dThanks @martrapp! - Fixes an issue where a form field named "attributes" shadows the form.attributes property. -
#12052
5be12b2Thanks @Fryuni! - Fixes incorrect config update when callingupdateConfigfromastro:build:setuphook.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
5f72a58Thanks @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]:- @astrojs/internal-helpers@0.6.0
- @astrojs/markdown-remark@6.2.0
Patch Changes
-
#13233
32fafebThanks @joshmkennedy! - Ensures consistent behaviour ofAstro.rewrite/ctx.rewritewhen usingbaseandtrailingSlashoptions. -
#13003
ea79054Thanks @chaegumi! - Fixes a bug that caused thevite.basevalue to be ignored when runningastro dev -
#13299
2e1321eThanks @bluwy! - Usestinyglobbyfor globbing files -
#13233
32fafebThanks @joshmkennedy! - Ensures thatAstro.url/ctx.urlis correctly updated with thebasepath after rewrites.This change fixes an issue where
Astro.url/ctx.urldid 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.rewritefailed to append the base path toAstro.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.
Minor Changes
-
#13210
344e9bcThanks @VitaliyR! - HandleHEADrequests to an endpoint when a handler is not defined.If an endpoint defines a handler for
GET, but does not define a handler forHEAD, Astro will call theGEThandler and return the headers and status but an empty body. -
#13195
3b66955Thanks @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
8d4e566Thanks @ascorbic! - Adds support for adapters auto-configuring experimental session storage drivers.Adapters can now configure a default session storage driver when the
experimental.sessionflag 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.
Patch Changes
-
#13145
8d4e566Thanks @ascorbic! - :warning: BREAKING CHANGE FOR EXPERIMENTAL SESSIONS ONLY :warning:Changes the
experimental.sessionoption 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 theexperimental.sessionflag, and then configure the session driver using the top-levelsessionkey 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
sessionconfig option. For more information, see the experimental session docs. -
#13101
2ed67d5Thanks @corneliusroemer! - Fixes a bug whereHEADandOPTIONSrequests for non-prerendered pages were incorrectly rejected with 403 FORBIDDEN
Patch Changes
-
#13188
7bc8256Thanks @ematipico! - Fixes the wording of the an error message -
#13205
9d56602Thanks @ematipico! - Fixes and issue where a server island component returns 404 whenbaseis configured in i18n project. -
#13212
fb38840Thanks @joshmkennedy! - An additional has been added during the build command to add clarity around output and buildOutput. -
#13213
6bac644Thanks @joshmkennedy! - Allows readonly arrays to be passed to thepaginate()function
Patch Changes
-
#13133
e76aa83Thanks @ematipico! - Fixes a bug where Astro was failing to build an external redirect when the middleware was triggered -
#13119
ac43580Thanks @Hacksore! - Adds extra guidance in the terminal when using theastro add tailwindCLI commandNow, 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.
Patch Changes
-
#13113
3a26e45Thanks @unprintable123! - Fixes the bug that rewrite will pass encoded url to the dynamic routing and cause params mismatch. -
#13111
23978ddThanks @ascorbic! - Fixes a bug that caused injected endpoint routes to return not found when trailingSlash was set to always -
#13112
0fa5c82Thanks @ematipico! - Fixes a bug where the i18n middleware was blocking a server island request when theprefixDefaultLocaleoption is set totrue
Minor Changes
-
#12994
5361755Thanks @ascorbic! - Redirects trailing slashes for on-demand pagesWhen the
trailingSlashoption is set toalwaysornever, 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
e621712Thanks @ematipico! - Adds support for redirecting to external sites with theredirectsconfiguration option.Now, you can redirect routes either internally to another path or externally by providing a URL beginning with
httporhttps:// astro.config.mjs import { defineConfig } from 'astro/config'; export default defineConfig({ redirects: { '/blog': 'https://example.com/blog', '/news': { status: 302, destination: 'https://example.com/news', }, }, }); -
#13084
0f3be31Thanks @ematipico! - Adds a new experimental virtual moduleastro:configthat exposes a type-safe subset of yourastro.config.mjsconfigurationThe 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.serializeManifestfeature flag to your Astro config:// astro.config.mjs 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:
// src/utils.js 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.
Patch Changes
-
#13049
2ed4bd9Thanks @florian-lefebvre! - Updatesastro add tailwindto add the@tailwindcss/viteplugin instead of the@astrojs/tailwindintegration -
#12994
5361755Thanks @ascorbic! - Returns a more helpful 404 page in dev if there is a trailing slash mismatch between the route requested and thetrailingSlashconfiguration -
#12666
037495dThanks @Thodor12! - Added additional generated typings for the content layer -
Updated dependencies [
5361755,db252e0]:- @astrojs/internal-helpers@0.5.0
- @astrojs/markdown-remark@6.1.0
Patch Changes
-
#13058
1a14b53Thanks @ascorbic! - Fixes broken type declaration -
#13059
e36837fThanks @ascorbic! - Fixes a bug that caused tsconfig path aliases to break if there was more than one wildcard pattern -
#13045
c7f1366Thanks @mtwilliams-code! - Fixes a bug where the some utility functions of theastro:i18nvirtual module would return an incorrect result whentrailingSlashis set tonever
Patch Changes
-
#12986
8911bdaThanks @wetheredge! - Updates types and dev toolbar for ARIA 1.2 attributes and roles -
#12892
8f520f1Thanks @louisescher! - Adds a more descriptive error when a content collection entry has an invalid ID. -
#13031
f576519Thanks @florian-lefebvre! - Updates the server islands encoding logic to only escape the script end tag open delimiter and opening HTML comment syntax -
#13026
1d272f6Thanks @ascorbic! - Fixes a regression that prevented the import of Markdown files as raw text or URLs.
Patch Changes
-
#12998
9ce0038Thanks @Kynson! - Fixes the issue that audit incorrectly flag images as above the fold when the scrolling container is not body -
#12990
2e12f1dThanks @ascorbic! - Fixes a bug that caused references to be incorrectly reported as invalid -
#12984
2d259cfThanks @ascorbic! - Fixes a bug in dev where files would stop being watched if the Astro config file was edited -
#12984
2d259cfThanks @ascorbic! - Fixes a bug where the content layer would use an outdated version of the Astro config if it was edited in dev -
#12982
429aa75Thanks @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
78fd73aThanks @florian-lefebvre! - Fixes a case whereastro:actionstypes would not work when usingsrc/actions.ts -
#12733
bbf1d88Thanks @ascorbic! - Fixes a bug that caused the dev server to return an error if requesting "//" -
#13001
627aec3Thanks @ascorbic! - Fixes a bug that caused Astro to attempt to inject environment variables into non-source files, causing performance problems and broken builds
Patch Changes
-
#12361
3d89e62Thanks @LunaticMuch! - Upgrades theesbuildversion to matchvite -
#12980
1a026afThanks @florian-lefebvre! - Fixes a case where setting the status of a page to404in development would show the default 404 page (or custom one if provided) instead of using the current page -
#12182
c30070bThanks @braden-w! - Improves matching of 404 and 500 routes -
Updated dependencies [
3d89e62]:- @astrojs/markdown-remark@6.0.2
Patch Changes
-
#12956
3aff68aThanks @kaytwo! - Removes encryption of empty props to allow server island cacheability -
#12977
80067c0Thanks @florian-lefebvre! - Fixes a case where accessingastro:envAPIs orimport.meta.envinside the content config file would not work -
#12839
57be349Thanks @mtwilliams-code! - Fix Astro.currentLocale returning the incorrect locale when using fallback rewrites in SSR mode -
#12962
4b7a2ceThanks @ascorbic! - Skips updating content layer files if content is unchanged -
#12942
f00c2ddThanks @liruifengv! - Improves the session error messages -
#12966
d864e09Thanks @ascorbic! - Ensures old content collection entry is deleted if a markdown frontmatter slug is changed in dev
Patch Changes
-
#12934
673a518Thanks @ematipico! - Fixes a regression where the Astro Container didn't work during the build, usingpnpm -
#12955
db447f2Thanks @martrapp! - Lets TypeScript know about the "blocking" and "disabled" attributes of the<link>element. -
#12922
faf74afThanks @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
3c2292fThanks @ascorbic! - Fixes a bug that caused empty content collections when running dev with NODE_ENV set
Patch Changes
-
#12927
ad2a752Thanks @ematipico! - Fixes a bug where Astro attempted to decode a request URL multiple times, resulting in an unexpected behaviour when decoding the character% -
#12912
0c0c66bThanks @florian-lefebvre! - Improves the config error for invalid combinations ofcontextandaccessproperties underenv.schema -
#12935
3d47e6bThanks @AirBorne04! - Fixes an issue whereAstro.localscoming from an adapter weren't available in the404.astro, when using theastro devcommand, -
#12925
44841fcThanks @ascorbic! - Ensures image styles are not imported unless experimental responsive images are enabled -
#12926
8e64bb7Thanks @oliverlynch! - Improves remote image cache efficiency by separating image data and metadata into a binary and sidecar JSON file. -
#12920
8b9d530Thanks @bluwy! - Processes markdown with empty body as remark and rehype plugins may add additional content or frontmatter -
#12918
fd12a26Thanks @lameuler! - Fixes a bug where the logged output path does not match the actual output path when usingbuild.format: 'preserve' -
#12676
2ffc0fcThanks @koyopro! - Allows configuring Astro modules TypeScript compilation with thevite.esbuildconfig -
#12938
dbb04f3Thanks @ascorbic! - Fixes a bug where content collections would sometimes appear empty when first running astro dev -
#12937
30edb6dThanks @ematipico! - Fixes a bug where users could useAstro.request.headersduring a rewrite inside prerendered routes. This an invalid behaviour, and now Astro will show a warning if this happens. -
#12937
30edb6dThanks @ematipico! - Fixes an issue where the use ofAstro.rewritewould trigger the invalid use ofAstro.request.headers
Patch Changes
-
#12877
73a0788Thanks @bluwy! - Fixes sourcemap warning generated by theastro:server-islandsVite plugin -
#12906
2d89492Thanks @ascorbic! - Fixes a bug that caused pages that return an empty array from getStaticPath to match every path -
011fa0fThanks @florian-lefebvre! - Fixes a case whereastro:contenttypes would be erased when restarting the dev server -
#12907
dbf1275Thanks @florian-lefebvre! - Fixes a regression around the server islands route, which was not passed to the adaptersastro:build:donehook -
#12818
579bd93Thanks @ascorbic! - Fixes race condition where dev server would attempt to load collections before the content had loaded -
#12883
fbac92fThanks @kaytwo! - Fixes a bug where responses can be returned before session data is saved -
#12815
3acc654Thanks @ericswpark! - Some non-index files that were incorrectly being treated as index files are now excluded -
#12884
d7e97a7Thanks @ascorbic! - Addsrender()to stub content types -
#12883
fbac92fThanks @kaytwo! - Fixes a bug where session data could be corrupted if it is changed after calling .set() -
#12827
7b5dc6fThanks @sinskiy! - Fixes an issue when crawlers try to index Server Islands thinking that Server Islands are pages
Patch Changes
-
#12798
7b0cb85Thanks @ascorbic! - Improves warning logs for invalid content collection configuration -
#12781
96c4b92Thanks @ascorbic! - Fixes a regression that causeddefault()to not work withreference() -
#12820
892dd9fThanks @ascorbic! - Fixes a bug that caused cookies to not be deleted when destroying a session -
#12864
440d8a5Thanks @kaytwo! - Fixes a bug where the session ID wasn't correctly regenerated -
#12768
524c855Thanks @ematipico! - Fixes an issue where Astro didn't print error logs when Astro Islands were used in incorrect cases. -
#12814
f12f111Thanks @ematipico! - Fixes an issue where Astro didn't log anything in case a file isn't created during the build. -
#12875
e109002Thanks @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
524c855Thanks @ematipico! - Fixes an issue where Astro was printing the incorrect output format when running theastro buildcommand -
#12810
70a9f0bThanks @louisescher! - Fixes server islands failing to check content-type header under certain circumstancesSometimes 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
7fb2184Thanks @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.
Minor Changes
-
#12441
b4fec3cThanks @ascorbic! - Adds experimental session supportSessions 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' mode const 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
fsdriver to store session data on the filesystem:// astro.config.mjs { 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, orcloudflare-kv-bindingand 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
3dc02c5Thanks @oliverlynch! - Improves asset caching of remote imagesAstro 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
c9d5110Thanks @florian-lefebvre! - Adds a newgetActionPath()helper available fromastro:actionsAstro 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 afetch()request with custom headers, or use your action with an API such asnavigator.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
likeaction passing theAuthorizationheader and thekeepaliveoption:<script> // src/components/my-component.astro 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
likeaction using thesendBeaconAPI:<script> // src/components/my-component.astro import { actions, getActionPath } from 'astro:actions'; navigator.sendBeacon( getActionPath(actions.like), new Blob([JSON.stringify({ id: 'YOUR_ID' })], { type: 'application/json', }), ); </script>
Patch Changes
-
#12786
e56af4aThanks @ematipico! - Fixes an issue where Astro i18n didn't properly show the 404 page when using fallback and the optionprefixDefaultLocaleset totrue. -
#12758
483da89Thanks @delucis! - Adds types for?url&inlineand?url&no-inlineimport queries added in Vite 6 -
#12763
8da2318Thanks @rbsummers! - Fixed changes to vite configuration made in the astro:build:setup integration hook having no effect when target is "client" -
#12767
36c1e06Thanks @ascorbic! - Clears the content layer cache when the Astro config is changed
Patch Changes
-
#12597
564ac6cThanks @florian-lefebvre! - Fixes an issue where image and server islands routes would not be passed to theastro:routes:resolvedhook during builds -
#12718
ccc5ad1Thanks @ematipico! - Fixes an issue where Astro couldn't correctly handle i18n fallback when using the i18n middleware -
#12728
ee66a45Thanks @argyleink! - Adds type support for theclosedbyattribute for<dialog>elements -
#12709
e3bfd93Thanks @mtwilliams-code! - Fixes a bug where Astro couldn't correctly parseparamsandpropswhen receiving i18n fallback URLs -
#12657
14dffccThanks @darkmaga! - Trailing slash support for actions -
#12715
029661dThanks @ascorbic! - Fixes a bug that caused errors in dev when editing sites with large numbers of MDX pages -
#12729
8b1cecdThanks @JoeMorgan! - "Addedinertto htmlBooleanAttributes" -
#12726
7c7398cThanks @florian-lefebvre! - Fixes a case where failing content entries inastro checkwould not be surfaced
Patch Changes
-
#12705
0d1eab5Thanks @ascorbic! - Fixes a bug where MDX files with certain characters in the name would cause builds to fail -
#12707
2aaed2dThanks @ematipico! - Fixes a bug where the middleware was incorrectly imported during the build -
#12697
1c4a032Thanks @ascorbic! - Fix a bug that caused builds to fail if an image had a quote mark in its name -
#12694
495f46bThanks @ematipico! - Fixes a bug where the experimental featureexperimental.svgwas incorrectly used when generating ESM images -
#12658
3169593Thanks @jurajkapsz! - Fixes astro info copy to clipboard process not returning to prompt in certain cases. -
#12712
b01c74aThanks @ascorbic! - Fixes a bug which misidentified pages as markdown if a query string ended in a markdown extension
Patch Changes
-
#12653
e21c7e6Thanks @sarah11918! - Updates a reference in an error message -
#12585
a9373c0Thanks @florian-lefebvre! - Fixes a case whereprocess.envwould be frozen despite changes made to environment variables in development -
#12695
a203d5dThanks @ascorbic! - Throws a more helpful error when images are missing -
Updated dependencies [
f13417b,87231b1,a71e9b9]:- @astrojs/markdown-remark@6.0.1
Patch Changes
-
#12645
8704c54Thanks @sarah11918! - Updates some reference links in error messages for new v5 docs. -
#12641
48ca399Thanks @ascorbic! - Fixes a bug whereastro info --copywasn't working correctly onmacOSsystems. -
#12461
62939adThanks @kyr0! - Removes the misleading log message telling that a custom renderer is not recognized while it clearly is and works. -
#12642
ff18b9cThanks @ematipico! - Provides more information when logging a warning for accessingAstro.request.headersin prerendered pages -
#12634
03958d9Thanks @delucis! - Improves error message formatting for user config and content collection frontmatter -
#12547
6b6e18dThanks @mtwilliams-code! - Fixes a bug where URL search parameters weren't passed when using the i18nfallbackfeature. -
#12449
e6b8017Thanks @apatel369! - Fixes an issue where the customassetFileNamesconfiguration 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
e216250Thanks @ematipico! - Fixes an issue where SSR error pages would return duplicated custom headers. -
#12625
74bfad0Thanks @ematipico! - Fixes an issue where theexperimental.svghad incorrect type, resulting in some errors in the editors. -
#12631
dec0305Thanks @ascorbic! - Fixes a bug where the class attribute was rendered twice on the image component -
#12623
0e4fecbThanks @ascorbic! - Correctly handles images in content collections with uppercase file extensions -
#12633
8a551c1Thanks @bluwy! - Cleans up content layer sync during builds and programmaticsync()calls -
#12640
22e405aThanks @ascorbic! - Fixes a bug that caused content collections to be returned empty when run in a test environment -
#12613
306c9f9Thanks @matthewp! - Fix use of cloned requests in middleware with clientAddressWhen using
context.clientAddressorAstro.clientAddressAstro 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.
Major Changes
-
#11798
e9e2139Thanks @matthewp! - Unflag globalRoutePriorityThe previously experimental feature
globalRoutePriorityis 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
ee38b3aThanks @ematipico! - ### [changed]:entryPointtype inside the hookastro:build:ssrIn Astro v4.x, theentryPointtype wasRouteData.Astro v5.0 the
entryPointtype isIntegrationRouteData, which contains a subset of theRouteDatatype. The fieldsisIndexandfallbackRouteswere removed.What should I do?
Update your adapter to change the type of
entryPointfromRouteDatatoIntegrationRouteData.-import type {RouteData} from 'astro'; +import type {IntegrationRouteData} from "astro" -function useRoute(route: RouteData) { +function useRoute(route: IntegrationRouteData) { } -
#12524
9f44019Thanks @bluwy! - Bumps Vite to ^6.0.1 and handles its breaking changes -
#10742
b6fbdaaThanks @ematipico! - The lowest version of Node supported by Astro is now Node v18.17.1 and higher. -
#11916
46ea29fThanks @bluwy! - Updates how thebuild.clientandbuild.serveroption values get resolved to match existing documentation. With this fix, the option values will now correctly resolve relative to theoutDiroption. So ifoutDiris set to./dist/nested/, then by default:build.clientwill resolve to<root>/dist/nested/client/build.serverwill resolve to<root>/dist/nested/server/
Previously the values were incorrectly resolved:
build.clientwas resolved to<root>/dist/nested/dist/client/build.serverwas 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
d84e444Thanks @Princesseuh! - Adds a default exclude and include value to the tsconfig presets.{projectDir}/distis now excluded by default, and{projectDir}/.astro/types.d.tsand{projectDir}/**/*are included by default.Both of these options can be overridden by setting your own values to the corresponding settings in your
tsconfig.jsonfile. -
#11861
3ab3b4eThanks @bluwy! - Cleans up Astro-specfic metadata attached tovfile.datain 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.imagePaths
The types of
imagePathshas also been updated fromSet<string>tostring[]. Thevfile.data.astro.frontmattermetadata 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
bf90a53Thanks @florian-lefebvre! - Thelocalsobject can no longer be overriddenMiddleware, API endpoints, and pages can no longer override the
localsobject 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
518433eThanks @Princesseuh! - Theimage.endpointconfig 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/_imageconflicts 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
5608338Thanks @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
ea71b90Thanks @florian-lefebvre! - Theastro:envfeature 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 usingastro: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
envoption 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 entireenvconfiguration 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
/clientor/servermodule:--- 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
f7f2338Thanks @Princesseuh! - Removes theassetsproperty onsupportedAstroFeaturesfor adapters, as it did not reflect reality properly in many cases.Now, relating to assets, only a single
sharpImageServiceproperty is available, determining if the adapter is compatible with the built-in sharp image service. -
#11864
ee38b3aThanks @ematipico! - ### [changed]:routestype inside the hookastro:build:doneIn Astro v4.x, theroutestype wasRouteData.Astro v5.0 the
routestype isIntegrationRouteData, which contains a subset of theRouteDatatype. The fieldsisIndexandfallbackRouteswere removed.What should I do?
Update your adapter to change the type of
routesfromRouteDatatoIntegrationRouteData.-import type {RouteData} from 'astro'; +import type {IntegrationRouteData} from "astro" -function useRoute(route: RouteData) { +function useRoute(route: IntegrationRouteData) { } -
#11941
b6a5f39Thanks @Princesseuh! - Merges theoutput: 'hybrid'andoutput: 'static'configurations into one single configuration (now called'static') that works the same way as the previoushybridoption.It is no longer necessary to specify
output: 'hybrid'in your Astro config to use server-rendered pages. The newoutput: '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 youroutputconfiguration required. Any page route or endpoint can includeexport const prerender = falseto 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
7c0ccfcThanks @ematipico! - Updates the default value ofsecurity.checkOrigintotrue, 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
560ef15Thanks @bluwy! - Updates internal Shiki rehype plugin to highlight code blocks as hast (using Shiki'scodeToHast()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 thepostprocesshook as it no longer runs on code blocks in.mdand.mdxfiles. (See the Shiki documentation on transformer hooks for more information).Code blocks in
.mdocfiles and<Code />component do not use the internal Shiki rehype plugin and are unaffected. -
#11826
7315050Thanks @matthewp! - Deprecate Astro.globThe
Astro.globfunction has been deprecated in favor of Content Collections andimport.meta.glob.- If you want to query for markdown and MDX in your project, use Content Collections.
- If you want to query source files in your project, use
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.globlike so:- const posts = Astro.glob('./posts/*.md'); + const posts = Object.values(import.meta.glob('./posts/*.md', { eager: true })); -
#12268
4e9a3acThanks @ematipico! - The commandastro add vercelnow updates the configuration file differently, and adds@astrojs/vercelas module to import.This is a breaking change because it requires the version
8.*of@astrojs/vercel. -
#11741
6617491Thanks @bluwy! - Removes internal JSX handling and moves the responsibility to the@astrojs/mdxpackage 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.js
If your project includes
.mdxfiles, you must upgrade@astrojs/mdxto the latest version so that it doesn't rely on these entrypoints to handle your JSX. -
#11782
9a2aaa0Thanks @Princesseuh! - Makes thecompiledContentproperty 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
2bdde80Thanks @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 fromnode_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
a83e362Thanks @matthewp! - Prevent usage ofastro:contentin the clientUsage of
astro:contentin 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
423dfc1Thanks @bluwy! - Bumpsvitedependency 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
3804711Thanks @florian-lefebvre! - Changes the defaulttsconfig.jsonwith better defaults, and makessrc/env.d.tsoptionalAstro's default
tsconfig.jsonin starter examples has been updated to include generated types and exclude your build output. This means thatsrc/env.d.tsis only necessary if you have added custom type declarations or if you're not using atsconfig.jsonfile.Additionally, running
astro syncno longer creates, nor updates,src/env.d.tsas it is not required for type-checking standard Astro projects.To update your project to Astro's recommended TypeScript settings, please add the following
includeandexcludeproperties totsconfig.json:{ "extends": "astro/tsconfigs/base", + "include": [".astro/types.d.ts", "**/*"], + "exclude": ["dist"] } -
#11715
d74617cThanks @Princesseuh! - Refactor the exported types from theastromodule. 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
abf9a89Thanks @ematipico! - Refactors legacycontentanddatacollections to use the Content Layer APIglob()loader for better performance and to support backwards compatibility. Also introduces thelegacy.collectionsflag 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 (
contentordata) and do not define aloaderare now implemented under the hood using the Content Layer API's built-inglob()loader, with extra backward-compatibility handling.In order to achieve backwards compatibility with existing
contentcollections, the following have been implemented:- a
globloader collection is defined, with patterns that match the previous handling (matchessrc/content/<collection name>/**/*.mdand other content extensions depending on installed integrations, with underscore-prefixed files and folders ignored) - When used in the runtime, the entries have an ID based on the filename in the same format as legacy collections
- A
slugfield is added with the same format as before - A
render()method is added to the entry, so they can be called usingentry.render() getEntryBySlugis supported
In order to achieve backwards compatibility with existing
datacollections, the following have been implemented:- a
globloader collection is defined, with patterns that match the previous handling (matchessrc/content/<collection name>/**/*{.json,.yaml}and other data extensions, with underscore-prefixed files and folders ignored) - Entries have an ID that is not slugified
getDataEntryByIdis supported
While 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:
- In previous versions of Astro, collections would be generated for all folders in
src/content/, even if they were not defined insrc/content/config.ts. This behavior is now deprecated, and collections should always be defined insrc/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. - The special
layoutfield is not supported in Markdown collection entries. This property is intended only for standalone page files located insrc/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. - Sort order of generated collections is non-deterministic and platform-dependent. This means that if you are calling
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.- the
keyargument ofgetEntry(collection, key)is typed asstring, rather than having types for every entry.
A new legacy configuration flag
legacy.collectionsis 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:// astro.config.mjs 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. - a
-
#11660
e90f559Thanks @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
.astroexamples, onlyallowfullscreenis 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
cfa6a47Thanks @Princesseuh! - Removed support for the Squoosh image service. As the underlying librarylibsquooshis 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
90ae100Thanks @bluwy! - Updates the automaticcharset=utf-8behavior for Markdown pages, where instead of responding withcharset=utf-8in theContent-Typeheader, Astro will now automatically add the<meta charset="utf-8">tag instead.This behaviour only applies to Markdown pages (
.mdor similar Markdown files located withinsrc/pages/) that do not use Astro's speciallayoutfrontmatter 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
layoutfrontmatter 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-8to 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
8a53517Thanks @matthewp! - Remove support for functionPerRouteThis change removes support for the
functionPerRouteoption 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
ee38b3aThanks @ematipico! - ### [changed]:RouteData.distURLis now an array In Astro v4.x,RouteData.distURLwasundefinedor aURLAstro v5.0,
RouteData.distURLisundefinedor an array ofURL. This was a bug, because a route can generate multiple files on disk, especially when using dynamic routes such as[slug]or[...slug].What should I do?
Update your code to handle
RouteData.distURLas 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
4e5cc5aThanks @kevinzunigacuellar! - Changes the data returned forpage.url.current,page.url.next,page.url.prev,page.url.firstandpage.url.lastto include the value set forbasein your Astro config.Previously, you had to manually prepend your configured value for
baseto the URL path. Now, Astro automatically includes yourbasevalue innextandprevURLs.If you are using the
paginate()function for "previous" and "next" URLs, remove any existingbasevalue 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
7febf1fThanks @ematipico! -paramspassed ingetStaticPathsare no longer automatically decoded.[changed]:
paramsaren't decoded anymore.In Astro v4.x,
paramsin were automatically decoded usingdecodeURIComponent.Astro v5.0 doesn't automatically decode
paramsingetStaticPathsanymore, so you'll need to manually decode them yourself if neededWhat should I do?
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 forgetStaticPathsbecause 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; ---
Minor Changes
-
#11941
b6a5f39Thanks @Princesseuh! - Adapters can now specify the build output type they're intended for using theadapterFeatures.buildOutputproperty. 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 aserveroutput, as a server is required to serve the server-rendered pages. -
#12067
c48916cThanks @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.svgtotruein 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
sizeattribute to set equalheightandwidthproperties:--- 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
51d13e2Thanks @ematipico! - The following renderer fields and integration fields now acceptURLas a type:Renderers:
AstroRenderer.clientEntrpointAstroRenderer.serverEntrypoint
Integrations:
InjectedRoute.entrypointAstroIntegrationMiddleware.entrypointDevToolbarAppEntry.entrypoint
-
#12323
c280655Thanks @bluwy! - Updates to Vite 6.0.0-beta.6 -
#12243
eb41d13Thanks @florian-lefebvre! - ImprovesdefineConfigtype 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 fori18n.defaultLocaleis not one of the supported locales specified ini18n.locales. -
#12329
8309c61Thanks @florian-lefebvre! - Adds a newastro:routes:resolvedhook to the Integration API. Also update theastro:build:donehook by deprecatingroutesand adding a newassetsmap.When building an integration, you can now get access to routes inside the
astro:routes:resolvedhook: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
routesarray fromastro:build:doneis now deprecated, and exposed properties are now available onastro:routes:resolved, except fordistURL. For this, you can use the newly exposedassetsmap: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
c3dce83Thanks @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.contentLayerflag from your Astro config:// astro.config.mjs import { defineConfig } from 'astro' export default defineConfig({ - experimental: { - contentLayer: true - } })Loading your content
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()andfile()loaders to handle your local Markdown, MDX, Markdoc, and JSON files:// src/content/config.ts 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 />Creating a loader
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:
// src/content/config.ts 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.
Sharing your loaders
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:
// src/content/config.ts 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
a604a0cThanks @matthewp! - ViewTransitions component renamed to ClientRouterThe
<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
a8a3d2cThanks @florian-lefebvre! - Adds a new propertyisPrerenderedto the globalsAstroandAPIContext. This boolean value represents whether or not the current page is prerendered:--- // src/pages/index.astro export const prerender = true; ---// src/middleware.js export const onRequest = (ctx, next) => { console.log(ctx.isPrerendered); // it will log true return next(); }; -
#12047
21b5e80Thanks @rgodha24! - Adds a new optionalparserproperty to the built-infile()loader for content collections to support additional file types such astomlandcsv.The
file()loader now accepts a second argument that defines aparserfunction. This allows you to specify a custom parser (e.g.toml.parseorcsv-parse) to create a collection from a file's contents. Thefile()loader will automatically detect and parse JSON and YAML files (based on their file extension) with no need for aparser.This works with any type of custom file formats including
csvandtoml. The following example defines a content collectiondogsusing a.tomlfile.[[dogs]] id = "..." age = "..." [[dogs]] id = "..." age = "..."After importing TOML's parser, you can load the
dogscollection into your project by passing both a file path andparserto thefile()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
parserargument 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
parserto thefile()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
idtodatabubbles: breed: 'Goldfish' age: 2 finn: breed: 'Betta' age: 1const fish = defineCollection({ loader: file('src/data/fish.yaml'), schema: z.object({ breed: z.string(), age: z.number() }), }); -
#11698
05139efThanks @ematipico! - Adds a new property to the globalsAstroandAPIContextcalledroutePattern. TheroutePatternrepresents the current route (component) that is being rendered by Astro. It's usually a path pattern will look like this:blog/[slug]:--- // src/pages/blog/[slug].astro const route = Astro.routePattern; console.log(route); // it will log "blog/[slug]" ---// src/pages/index.js export const GET = (ctx) => { console.log(ctx.routePattern); // it will log src/pages/index.js return new Response.json({ loreum: 'ipsum' }); }; -
#11941
b6a5f39Thanks @Princesseuh! - Adds a newbuildOutputproperty to theastro:config:donehook 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
af867f3Thanks @ascorbic! - Adds experimental support for automatic responsive imagesThis feature is experimental and may change in future versions. To enable it, set
experimental.responsiveImagestotruein yourastro.config.mjsfile.{ experimental: { responsiveImages: true, }, }When this flag is enabled, you can pass a
layoutprop to any<Image />or<Picture />component to create a responsive image. When a layout is set, images have automatically generatedsrcsetandsizesattributes based on the image's dimensions and the layout type. Images withresponsiveandfull-widthlayouts 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" />Responsive image properties
These are additional properties available to the
<Image />and<Picture />components when responsive images are enabled:layout: The layout type for the image. Can beresponsive,fixed,full-widthornone. Defaults to value ofimage.experimentalLayout.fit: Defines how the image should be cropped if the aspect ratio is changed. Values match those of CSSobject-fit. Defaults tocover, or the value ofimage.experimentalObjectFitif set.position: Defines the position of the image crop if the aspect ratio is changed. Values match those of CSSobject-position. Defaults tocenter, or the value ofimage.experimentalObjectPositionif set.priority: If set, eagerly loads the image. Otherwise images will be lazy-loaded. Use this for your largest above-the-fold image. Defaults tofalse.
Default responsive image settings
You can enable responsive images for all
<Image />and<Picture />components by settingimage.experimentalLayoutwith a default value. This can be overridden by thelayoutprop 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
93351bcThanks @bluwy! - Adds support for passing values other than"production"or"development"to the--modeflag (e.g."staging","testing", or any custom value) to change the value ofimport.meta.env.MODEor the loaded.envfile. This allows you take advantage of Vite's mode feature.Also adds a new
--devOutputflag forastro buildthat will output a development-based build.Note that changing the
modedoes not change the kind of code transform handled by Vite and Astro:- In
astro dev, Astro will transform code with debug information. - In
astro build, Astro will transform code with the most optimized output and removes debug information. - In
astro build --devOutput(new flag), Astro will transform code with debug information like inastro dev.
This enables various usecases like:
# Run the dev server connected to a "staging" API astro dev --mode staging # Build a site that connects to a "staging" API astro build --mode staging # Build a site that connects to a "production" API with additional debug information astro build --devOutput # Build a site that connects to a "testing" API astro build --mode testingThe different modes can be used to load different
.envfiles, e.g..env.stagingor.env.production, which can be customized for each environment, for example with differentAPI_URLenvironment variable values. - In
-
#12510
14feaf3Thanks @bholmesdev! - Changes the generated URL query param from_astroActionto_actionwhen submitting a form using Actions. This avoids leaking the framework name into the URL bar, which may be considered a security issue. -
#11806
f7f2338Thanks @Princesseuh! - The value of the different properties onsupportedAstroFeaturesfor adapters can now be objects, with asupportandmessageproperties. The content of themessageproperty 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
limitedvalue, to explain to the user why support is limited. -
#12071
61d248eThanks @Princesseuh! -astro addno longer automatically setsoutput: '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
d813262Thanks @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
.astrocomponent into a server island by adding theserver:deferdirective 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
d10f918Thanks @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.
Customize form submission behavior
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:
// src/middleware.ts 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
3f02d5fThanks @ascorbic! - Changes the default content config location fromsrc/content/config.*tosrc/content.config.*.The previous location is still supported, and is required if the
legacy.collectionsflag is enabled. -
#11963
0a1036eThanks @florian-lefebvre! - Adds a newcreateCodegenDir()function to theastro:config:setuphook in the Integrations APIIn 4.14, we introduced the
injectTypesutility on theastro:config:donehook. It can create.d.tsfiles 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
.astrodirectory 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.tsfile, 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 theastro:config:setuphook by callingcreateCodegenDir(). 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
94f4fe8Thanks @Princesseuh! - Adds a new components exported fromastro/components: Welcome, to be used by the new Basics template -
#11806
f7f2338Thanks @Princesseuh! - Adds a newlimitedvalue for the different properties ofsupportedAstroFeaturesfor 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
74722cbThanks @florian-lefebvre! - Updatesastro/configimport to referenceastro/clienttypesWhen importing
astro/config, types fromastro/clientwill be made automatically available to your project. If your projecttsconfig.jsonchanges how references behave, you'll still have access to these types after runningastro sync. -
#12081
8679954Thanks @florian-lefebvre! - Removes the experimentalcontentCollectionsCacheintroduced in3.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
cacheManifestboolean argument is no longer passed to theastro:build:doneintegration hook:const integration = { name: "my-integration", hooks: { "astro:build:done": ({ - cacheManifest, logger }) => {} } }
Patch Changes
-
#12565
97f413fThanks @ascorbic! - Fixes a bug where content types were not generated when first running astro dev unless src/content exists -
#11987
bf90a53Thanks @florian-lefebvre! -render()signature now takesrenderOptionsas 2nd argumentThe signature for
app.render()has changed, and the second argument is now an options object calledrenderOptionswith more options for customizing rendering.The
renderOptionsare:addCookieHeader: Determines whether Astro will set theSet-Cookieheader, otherwise the adapter is expected to do so itself.clientAddress: The client IP address used to setAstro.clientAddress.locals: An object of locals that's set toAstro.locals.routeData: An object specifying the route to use.
-
#12522
33b0e30Thanks @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
4364bffThanks @ematipico! - Fixes an issue where an incorrect usage of Astro actions was lost when porting the fix from v4 to v5 -
#12438
c8f877cThanks @ascorbic! - Fixes a bug where legacy content types were generated for content layer collections if they were in the content directory -
#12035
325a57cThanks @ascorbic! - Correctly parse values returned from inline loader -
#11960
4410130Thanks @ascorbic! - Fixes an issue where the refresh context data was not passed correctly to content layer loaders -
#11878
334948cThanks @ascorbic! - Adds a new functionrefreshContentto theastro:server:setuphook 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,
refreshContentwill refresh all collections. You can optionally pass aloadersproperty, 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
contextobject 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
d7a396cThanks @matthewp! - Update error link to on-demand rendering guide -
#12127
55e9cd8Thanks @ascorbic! - Prevents Vite emitting an error when restarting itself -
#12516
cb9322cThanks @stramel! - Handle multiple root nodes on SVG files -
#11974
60211deThanks @ascorbic! - Exports theRenderResulttype -
#12578
07b9ca8Thanks @WesSouza! - Explicitly import index.ts to fix types when moduleResolution is NodeNext -
#11791
9393243Thanks @bluwy! - Updates Astro's default<script>rendering strategy and removes theexperimental.directRenderScriptoption 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
cfdaab2Thanks @ArmandPhilippot! - Fixes a type and an example in documenting thesecurity.checkOriginproperty of Astro config. -
#12168
1cd3085Thanks @ascorbic! - Allows "slug" as a field in content layer data -
#12302
7196c24Thanks @ematipico! - Fixes an issue where the origin check middleware run for prendered pages -
#12341
c1786d6Thanks @ematipico! - Fixes and issue whereAstro.currentLocalealways returned the default locale when consumed inside a server island. -
#11732
4cd6c43Thanks @matthewp! - Use GET requests with preloading for Server IslandsServer 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
50a0146Thanks @ascorbic! - Adds support for array patterns in the built-inglob()content collections loaderThe 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
ddc3a08Thanks @Princesseuh! - Properly handle including trailing slash on the image endpoint route based on the trailingSlash config -
#12169
15fa9baThanks @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.mjslike{ /old: /new }, failed to trigger the correct redirect in the dev server. -
#11914
b5d827bThanks @ascorbic! - Exports types for allLoaderContextproperties fromastro/loadersto make it easier to use them in custom loaders. TheScopedDataStoreinterface (which was previously internal) is renamed toDataStore, to reflect the fact that it's the only public API for the data store. -
#12270
25192a0Thanks @ematipico! - Fixes a bug where the params weren't correctly computed when rendering URLs with non-English characters -
#11927
5b4e3abThanks @florian-lefebvre! - Updates theenvconfiguration reference docs to include a full API reference forenvField. -
#12591
b731b3dThanks @ascorbic! - Fixes a bug where a catchall route would match an image endpoint request -
#12073
acf264dThanks @bluwy! - Replacesorawithyocto-spinner -
#12339
bdb75a8Thanks @ematipico! - Adds an error whenAstro.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
d023682Thanks @stramel! - Fix SVG Component sprite references -
#12486
dc3d842Thanks @matthewp! - Call server island early so it can set headers -
#12016
837ee3aThanks @matthewp! - Fixes actions with large amount of validation errors -
#11943
fa4671cThanks @sarah11918! - Updates error messages that assume content collections are located insrc/content/with more generic language -
#12030
10a756aThanks @ascorbic! - Resolves image paths in content layer with initial slash as project-relativeWhen 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
f10a3b7Thanks @matthewp! - Fixes use of Vitest with Astro 5 -
#12075
a19530eThanks @bluwy! - Parses frontmatter ourselves -
#12552
15f000cThanks @avanderbergh! - Fixed an issue where modifying theRequest.headersprototype during prerendering caused a build error. Removed conflicting value and writable properties from theheadersdescriptor to preventInvalid property descriptorerrors. -
#12070
9693ad4Thanks @ematipico! - Fixes an issue where the check origin middleware was incorrectly injected when the build output was"static" -
#12169
15fa9baThanks @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.mjslike 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]:- @astrojs/markdown-remark@6.0.0
- @astrojs/telemetry@3.2.0
- @astrojs/internal-helpers@0.4.2
Minor Changes
- #12510
14feaf3Thanks @bholmesdev! - Changes the generated URL query param from_astroActionto_actionwhen submitting a form using Actions. This avoids leaking the framework name into the URL bar, which may be considered a security issue.
Patch Changes
-
#12522
33b0e30Thanks @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
cb9322cThanks @stramel! - Handle multiple root nodes on SVG files -
#12511
d023682Thanks @stramel! - Fix SVG Component sprite references -
#12498
b140a3fThanks @ematipico! - Fixes a regression where Astro was trying to accessRequest.headers
Minor Changes
-
#12067
c48916cThanks @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.svgtotruein 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
sizeattribute to set equalheightandwidthproperties:--- 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
8309c61Thanks @florian-lefebvre! - Adds a newastro:routes:resolvedhook to the Integration API. Also update theastro:build:donehook by deprecatingroutesand adding a newassetsmap.When building an integration, you can now get access to routes inside the
astro:routes:resolvedhook: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
routesarray fromastro:build:doneis now deprecated, and exposed properties are now available onastro:routes:resolved, except fordistURL. For this, you can use the newly exposedassetsmap: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
af867f3Thanks @ascorbic! - Adds experimental support for automatic responsive imagesThis feature is experimental and may change in future versions. To enable it, set
experimental.responsiveImagestotruein yourastro.config.mjsfile.{ experimental: { responsiveImages: true, }, }When this flag is enabled, you can pass a
layoutprop to any<Image />or<Picture />component to create a responsive image. When a layout is set, images have automatically generatedsrcsetandsizesattributes based on the image's dimensions and the layout type. Images withresponsiveandfull-widthlayouts 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" />Responsive image properties
These are additional properties available to the
<Image />and<Picture />components when responsive images are enabled:layout: The layout type for the image. Can beresponsive,fixed,full-widthornone. Defaults to value ofimage.experimentalLayout.fit: Defines how the image should be cropped if the aspect ratio is changed. Values match those of CSSobject-fit. Defaults tocover, or the value ofimage.experimentalObjectFitif set.position: Defines the position of the image crop if the aspect ratio is changed. Values match those of CSSobject-position. Defaults tocenter, or the value ofimage.experimentalObjectPositionif set.priority: If set, eagerly loads the image. Otherwise images will be lazy-loaded. Use this for your largest above-the-fold image. Defaults tofalse.
Default responsive image settings
You can enable responsive images for all
<Image />and<Picture />components by settingimage.experimentalLayoutwith a default value. This can be overridden by thelayoutprop 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
3f02d5fThanks @ascorbic! - Changes the default content config location fromsrc/content/config.*tosrc/content.config.*.The previous location is still supported, and is required if the
legacy.collectionsflag is enabled.
Patch Changes
Minor Changes
-
#12373
d10f918Thanks @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.
Customize form submission behavior
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:
// src/middleware.ts 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(); });
Patch Changes
-
#12339
bdb75a8Thanks @ematipico! - Adds an error whenAstro.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.
Major Changes
-
#12268
4e9a3acThanks @ematipico! - The commandastro add vercelnow updates the configuration file differently, and adds@astrojs/vercelas module to import.This is a breaking change because it requires the version
8.*of@astrojs/vercel. -
#12231
90ae100Thanks @bluwy! - Updates the automaticcharset=utf-8behavior for Markdown pages, where instead of responding withcharset=utf-8in theContent-Typeheader, Astro will now automatically add the<meta charset="utf-8">tag instead.This behaviour only applies to Markdown pages (
.mdor similar Markdown files located withinsrc/pages/) that do not use Astro's speciallayoutfrontmatter 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
layoutfrontmatter 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-8to 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.
Minor Changes
-
#12243
eb41d13Thanks @florian-lefebvre! - ImprovesdefineConfigtype 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 fori18n.defaultLocaleis not one of the supported locales specified ini18n.locales. -
#12150
93351bcThanks @bluwy! - Adds support for passing values other than"production"or"development"to the--modeflag (e.g."staging","testing", or any custom value) to change the value ofimport.meta.env.MODEor the loaded.envfile. This allows you take advantage of Vite's mode feature.Also adds a new
--devOutputflag forastro buildthat will output a development-based build.Note that changing the
modedoes not change the kind of code transform handled by Vite and Astro:- In
astro dev, Astro will transform code with debug information. - In
astro build, Astro will transform code with the most optimized output and removes debug information. - In
astro build --devOutput(new flag), Astro will transform code with debug information like inastro dev.
This enables various usecases like:
# Run the dev server connected to a "staging" API astro dev --mode staging # Build a site that connects to a "staging" API astro build --mode staging # Build a site that connects to a "production" API with additional debug information astro build --devOutput # Build a site that connects to a "testing" API astro build --mode testingThe different modes can be used to load different
.envfiles, e.g..env.stagingor.env.production, which can be customized for each environment, for example with differentAPI_URLenvironment variable values. - In
Patch Changes
-
#12302
7196c24Thanks @ematipico! - Fixes an issue where the origin check middleware run for prendered pages -
#12341
c1786d6Thanks @ematipico! - Fixes and issue whereAstro.currentLocalealways returned the default locale when consumed inside a server island. -
#12270
25192a0Thanks @ematipico! - Fixes a bug where the params weren't correctly computed when rendering URLs with non-English characters
Minor Changes
-
#12226
51d13e2Thanks @ematipico! - The following renderer fields and integration fields now acceptURLas a type:Renderers:
AstroRenderer.clientEntrpointAstroRenderer.serverEntrypoint
Integrations:
InjectedRoute.entrypointAstroIntegrationMiddleware.entrypointDevToolbarAppEntry.entrypoint
Patch Changes
-
#12168
1cd3085Thanks @ascorbic! - Allows "slug" as a field in content layer data -
#12169
15fa9baThanks @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.mjslike{ /old: /new }, failed to trigger the correct redirect in the dev server. -
#12169
15fa9baThanks @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.mjslike this{ /old: "/new" }, the dev server return an HTML response that matches the one emitted by a static build.
Major Changes
-
#11979
423dfc1Thanks @bluwy! - Bumpsvitedependency 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
abf9a89Thanks @astrobot-houston! - Refactors legacycontentanddatacollections to use the Content Layer APIglob()loader for better performance and to support backwards compatibility. Also introduces thelegacy.collectionsflag 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 (
contentordata) and do not define aloaderare now implemented under the hood using the Content Layer API's built-inglob()loader, with extra backward-compatibility handling.In order to achieve backwards compatibility with existing
contentcollections, the following have been implemented:- a
globloader collection is defined, with patterns that match the previous handling (matchessrc/content/<collection name>/**/*.mdand other content extensions depending on installed integrations, with underscore-prefixed files and folders ignored) - When used in the runtime, the entries have an ID based on the filename in the same format as legacy collections
- A
slugfield is added with the same format as before - A
render()method is added to the entry, so they can be called usingentry.render() getEntryBySlugis supported
In order to achieve backwards compatibility with existing
datacollections, the following have been implemented:- a
globloader collection is defined, with patterns that match the previous handling (matchessrc/content/<collection name>/**/*{.json,.yaml}and other data extensions, with underscore-prefixed files and folders ignored) - Entries have an ID that is not slugified
getDataEntryByIdis supported
While 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:
- In previous versions of Astro, collections would be generated for all folders in
src/content/, even if they were not defined insrc/content/config.ts. This behavior is now deprecated, and collections should always be defined insrc/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. - The special
layoutfield is not supported in Markdown collection entries. This property is intended only for standalone page files located insrc/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. - Sort order of generated collections is non-deterministic and platform-dependent. This means that if you are calling
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.- the
keyargument ofgetEntry(collection, key)is typed asstring, rather than having types for every entry.
A new legacy configuration flag
legacy.collectionsis 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:// astro.config.mjs 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. - a
-
#12079
7febf1fThanks @ematipico! -paramspassed ingetStaticPathsare no longer automatically decoded.[changed]:
paramsaren't decoded anymore.In Astro v4.x,
paramsin were automatically decoded usingdecodeURIComponent.Astro v5.0 doesn't automatically decode
paramsingetStaticPathsanymore, so you'll need to manually decode them yourself if neededWhat should I do?
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 forgetStaticPathsbecause 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; ---
Patch Changes
Minor Changes
-
#12047
21b5e80Thanks @rgodha24! - Adds a new optionalparserproperty to the built-infile()loader for content collections to support additional file types such astomlandcsv.The
file()loader now accepts a second argument that defines aparserfunction. This allows you to specify a custom parser (e.g.toml.parseorcsv-parse) to create a collection from a file's contents. Thefile()loader will automatically detect and parse JSON and YAML files (based on their file extension) with no need for aparser.This works with any type of custom file formats including
csvandtoml. The following example defines a content collectiondogsusing a.tomlfile.[[dogs]] id = "..." age = "..." [[dogs]] id = "..." age = "..."After importing TOML's parser, you can load the
dogscollection into your project by passing both a file path andparserto thefile()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
parserargument 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
parserto thefile()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
idtodatabubbles: breed: 'Goldfish' age: 2 finn: breed: 'Betta' age: 1const fish = defineCollection({ loader: file('src/data/fish.yaml'), schema: z.object({ breed: z.string(), age: z.number() }), }); -
#12071
61d248eThanks @Princesseuh! -astro addno longer automatically setsoutput: '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
0a1036eThanks @florian-lefebvre! - Adds a newcreateCodegenDir()function to theastro:config:setuphook in the Integrations APIIn 4.14, we introduced the
injectTypesutility on theastro:config:donehook. It can create.d.tsfiles 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
.astrodirectory 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.tsfile, 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 theastro:config:setuphook by callingcreateCodegenDir(). 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
8679954Thanks @florian-lefebvre! - Removes the experimentalcontentCollectionsCacheintroduced in3.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
cacheManifestboolean argument is no longer passed to theastro:build:doneintegration hook:const integration = { name: "my-integration", hooks: { "astro:build:done": ({ - cacheManifest, logger }) => {} } }
Patch Changes
-
#12073
acf264dThanks @bluwy! - Replacesorawithyocto-spinner -
#12075
a19530eThanks @bluwy! - Parses frontmatter ourselves -
#12070
9693ad4Thanks @ematipico! - Fixes an issue where the check origin middleware was incorrectly injected when the build output was"static" -
Updated dependencies [
a19530e]:- @astrojs/markdown-remark@6.0.0-beta.2
Patch Changes
-
#12035
325a57cThanks @ascorbic! - Correctly parse values returned from inline loader -
#12022
ddc3a08Thanks @Princesseuh! - Properly handle including trailing slash on the image endpoint route based on the trailingSlash config -
#12016
837ee3aThanks @matthewp! - Fixes actions with large amount of validation errors -
#12030
10a756aThanks @ascorbic! - Resolves image paths in content layer with initial slash as project-relativeWhen 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.
Major Changes
-
#12008
5608338Thanks @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.
Patch Changes
- Updated dependencies [
5608338]:- @astrojs/markdown-remark@6.0.0-beta.1
Major Changes
-
#11982
d84e444Thanks @Princesseuh! - Adds a default exclude and include value to the tsconfig presets.{projectDir}/distis now excluded by default, and{projectDir}/.astro/types.d.tsand{projectDir}/**/*are included by default.Both of these options can be overridden by setting your own values to the corresponding settings in your
tsconfig.jsonfile. -
#11987
bf90a53Thanks @florian-lefebvre! - Thelocalsobject can no longer be overriddenMiddleware, API endpoints, and pages can no longer override the
localsobject 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, });
Minor Changes
-
#11980
a604a0cThanks @matthewp! - ViewTransitions component renamed to ClientRouterThe
<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.
Patch Changes
-
#11987
bf90a53Thanks @florian-lefebvre! -render()signature now takesrenderOptionsas 2nd argumentThe signature for
app.render()has changed, and the second argument is now an options object calledrenderOptionswith more options for customizing rendering.The
renderOptionsare:addCookieHeader: Determines whether Astro will set theSet-Cookieheader, otherwise the adapter is expected to do so itself.clientAddress: The client IP address used to setAstro.clientAddress.locals: An object of locals that's set toAstro.locals.routeData: An object specifying the route to use.
-
#11991
d7a396cThanks @matthewp! - Update error link to on-demand rendering guide
Major Changes
-
#11864
ee38b3aThanks @ematipico! - ### [changed]:entryPointtype inside the hookastro:build:ssrIn Astro v4.x, theentryPointtype wasRouteData.Astro v5.0 the
entryPointtype isIntegrationRouteData, which contains a subset of theRouteDatatype. The fieldsisIndexandfallbackRouteswere removed.What should I do?
Update your adapter to change the type of
entryPointfromRouteDatatoIntegrationRouteData.-import type {RouteData} from 'astro'; +import type {IntegrationRouteData} from "astro" -function useRoute(route: RouteData) { +function useRoute(route: IntegrationRouteData) { } -
#11908
518433eThanks @Princesseuh! - Theimage.endpointconfig 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/_imageconflicts 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
f7f2338Thanks @Princesseuh! - Removes theassetsproperty onsupportedAstroFeaturesfor adapters, as it did not reflect reality properly in many cases.Now, relating to assets, only a single
sharpImageServiceproperty is available, determining if the adapter is compatible with the built-in sharp image service. -
#11864
ee38b3aThanks @ematipico! - ### [changed]:routestype inside the hookastro:build:doneIn Astro v4.x, theroutestype wasRouteData.Astro v5.0 the
routestype isIntegrationRouteData, which contains a subset of theRouteDatatype. The fieldsisIndexandfallbackRouteswere removed.What should I do?
Update your adapter to change the type of
routesfromRouteDatatoIntegrationRouteData.-import type {RouteData} from 'astro'; +import type {IntegrationRouteData} from "astro" -function useRoute(route: RouteData) { +function useRoute(route: IntegrationRouteData) { } -
#11864
ee38b3aThanks @ematipico! - ### [changed]:RouteData.distURLis now an array In Astro v4.x,RouteData.distURLwasundefinedor aURLAstro v5.0,
RouteData.distURLisundefinedor an array ofURL. This was a bug, because a route can generate multiple files on disk, especially when using dynamic routes such as[slug]or[...slug].What should I do?
Update your code to handle
RouteData.distURLas 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 + } + } }
Minor Changes
-
#11806
f7f2338Thanks @Princesseuh! - The value of the different properties onsupportedAstroFeaturesfor adapters can now be objects, with asupportandmessageproperties. The content of themessageproperty 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
limitedvalue, to explain to the user why support is limited. -
#11955
d813262Thanks @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
.astrocomponent into a server island by adding theserver:deferdirective 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
f7f2338Thanks @Princesseuh! - Adds a newlimitedvalue for the different properties ofsupportedAstroFeaturesfor 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
74722cbThanks @florian-lefebvre! - Updatesastro/configimport to referenceastro/clienttypesWhen importing
astro/config, types fromastro/clientwill be made automatically available to your project. If your projecttsconfig.jsonchanges how references behave, you'll still have access to these types after runningastro sync.
Patch Changes
-
#11974
60211deThanks @ascorbic! - Exports theRenderResulttype -
#11939
7b09c62Thanks @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
createorupdateform submission, and uses thetypefield 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
createandupdateforms 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>
Major Changes
-
#11941
b6a5f39Thanks @Princesseuh! - Merges theoutput: 'hybrid'andoutput: 'static'configurations into one single configuration (now called'static') that works the same way as the previoushybridoption.It is no longer necessary to specify
output: 'hybrid'in your Astro config to use server-rendered pages. The newoutput: '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 youroutputconfiguration required. Any page route or endpoint can includeexport const prerender = falseto 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.
Minor Changes
-
#11941
b6a5f39Thanks @Princesseuh! - Adapters can now specify the build output type they're intended for using theadapterFeatures.buildOutputproperty. 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 aserveroutput, as a server is required to serve the server-rendered pages. -
#11941
b6a5f39Thanks @Princesseuh! - Adds a newbuildOutputproperty to theastro:config:donehook 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).
Patch Changes
-
#11960
4410130Thanks @ascorbic! - Fixes an issue where the refresh context data was not passed correctly to content layer loaders -
#11952
50a0146Thanks @ascorbic! - Adds support for array patterns in the built-inglob()content collections loaderThe 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()), }), });
Major Changes
-
#11916
46ea29fThanks @bluwy! - Updates how thebuild.clientandbuild.serveroption values get resolved to match existing documentation. With this fix, the option values will now correctly resolve relative to theoutDiroption. So ifoutDiris set to./dist/nested/, then by default:build.clientwill resolve to<root>/dist/nested/client/build.serverwill resolve to<root>/dist/nested/server/
Previously the values were incorrectly resolved:
build.clientwas resolved to<root>/dist/nested/dist/client/build.serverwas 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.
Minor Changes
-
#11875
a8a3d2cThanks @florian-lefebvre! - Adds a new propertyisPrerenderedto the globalsAstroandAPIContext. This boolean value represents whether or not the current page is prerendered:--- // src/pages/index.astro export const prerender = true; ---// src/middleware.js export const onRequest = (ctx, next) => { console.log(ctx.isPrerendered); // it will log true return next(); };
Patch Changes
-
#11927
5b4e3abThanks @florian-lefebvre! - Updates theenvconfiguration reference docs to include a full API reference forenvField. -
#11943
fa4671cThanks @sarah11918! - Updates error messages that assume content collections are located insrc/content/with more generic language
Major Changes
-
#11859
3804711Thanks @florian-lefebvre! - Changes the defaulttsconfig.jsonwith better defaults, and makessrc/env.d.tsoptionalAstro's default
tsconfig.jsonin starter examples has been updated to include generated types and exclude your build output. This means thatsrc/env.d.tsis only necessary if you have added custom type declarations or if you're not using atsconfig.jsonfile.Additionally, running
astro syncno longer creates, nor updates,src/env.d.tsas it is not required for type-checking standard Astro projects.To update your project to Astro's recommended TypeScript settings, please add the following
includeandexcludeproperties totsconfig.json:{ "extends": "astro/tsconfigs/base", + "include": ["**/*", ".astro/types.d.ts"], + "exclude": ["dist"] }
Minor Changes
-
#11911
c3dce83Thanks @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.contentLayerflag from your Astro config:// astro.config.mjs import { defineConfig } from 'astro' export default defineConfig({ - experimental: { - contentLayer: true - } })Loading your content
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()andfile()loaders to handle your local Markdown, MDX, Markdoc, and JSON files:// src/content/config.ts 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 />Creating a loader
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:
// src/content/config.ts 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.
Sharing your loaders
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:
// src/content/config.ts 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.
Patch Changes
-
#11902
d63bc50Thanks @ascorbic! - Fixes case where content layer did not update during clean dev builds on Linux and Windows -
#11914
b5d827bThanks @ascorbic! - Exports types for allLoaderContextproperties fromastro/loadersto make it easier to use them in custom loaders. TheScopedDataStoreinterface (which was previously internal) is renamed toDataStore, to reflect the fact that it's the only public API for the data store.
Major Changes
-
#11861
3ab3b4eThanks @bluwy! - Cleans up Astro-specfic metadata attached tovfile.datain 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.imagePaths
The types of
imagePathshas also been updated fromSet<string>tostring[]. Thevfile.data.astro.frontmattermetadata 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
560ef15Thanks @bluwy! - Updates internal Shiki rehype plugin to highlight code blocks as hast (using Shiki'scodeToHast()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 thepostprocesshook as it no longer runs on code blocks in.mdand.mdxfiles. (See the Shiki documentation on transformer hooks for more information).Code blocks in
.mdocfiles and<Code />component do not use the internal Shiki rehype plugin and are unaffected. -
#11819
2bdde80Thanks @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 fromnode_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.
Patch Changes
-
#11878
334948cThanks @ascorbic! - Adds a new functionrefreshContentto theastro:server:setuphook 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,
refreshContentwill refresh all collections. You can optionally pass aloadersproperty, 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
contextobject 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]:- @astrojs/markdown-remark@6.0.0-alpha.1
Major Changes
-
#11826
7315050Thanks @matthewp! - Deprecate Astro.globThe
Astro.globfunction has been deprecated in favor of Content Collections andimport.meta.glob.- If you want to query for markdown and MDX in your project, use Content Collections.
- If you want to query source files in your project, use
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.globlike so:- const posts = Astro.glob('./posts/*.md'); + const posts = Object.values(import.meta.glob('./posts/*.md', { eager: true })); -
#11827
a83e362Thanks @matthewp! - Prevent usage ofastro:contentin the clientUsage of
astro:contentin 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
4e5cc5aThanks @kevinzunigacuellar! - Changes the data returned forpage.url.current,page.url.next,page.url.prev,page.url.firstandpage.url.lastto include the value set forbasein your Astro config.Previously, you had to manually prepend your configured value for
baseto the URL path. Now, Astro automatically includes yourbasevalue innextandprevURLs.If you are using the
paginate()function for "previous" and "next" URLs, remove any existingbasevalue 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>
Minor Changes
-
#11698
05139efThanks @ematipico! - Adds a new property to the globalsAstroandAPIContextcalledroutePattern. TheroutePatternrepresents the current route (component) that is being rendered by Astro. It's usually a path pattern will look like this:blog/[slug]:--- // src/pages/blog/[slug].astro const route = Astro.routePattern; console.log(route); // it will log "blog/[slug]" ---// src/pages/index.js export const GET = (ctx) => { console.log(ctx.routePattern); // it will log src/pages/index.js return new Response.json({ loreum: 'ipsum' }); };
Patch Changes
-
#11791
9393243Thanks @bluwy! - Updates Astro's default<script>rendering strategy and removes theexperimental.directRenderScriptoption 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
d1bd1a1Thanks @ascorbic! - Refactors content layer sync to use a queue
Major Changes
-
#11798
e9e2139Thanks @matthewp! - Unflag globalRoutePriorityThe previously experimental feature
globalRoutePriorityis 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
ea71b90Thanks @florian-lefebvre! - Theastro:envfeature 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 usingastro: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
envoption 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 entireenvconfiguration 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
/clientor/servermodule:--- 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
7c0ccfcThanks @ematipico! - Updates the default value ofsecurity.checkOrigintotrue, 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
6617491Thanks @bluwy! - Removes internal JSX handling and moves the responsibility to the@astrojs/mdxpackage 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.js
If your project includes
.mdxfiles, you must upgrade@astrojs/mdxto the latest version so that it doesn't rely on these entrypoints to handle your JSX. -
#11782
9a2aaa0Thanks @Princesseuh! - Makes thecompiledContentproperty 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
cfa6a47Thanks @Princesseuh! - Removed support for the Squoosh image service. As the underlying librarylibsquooshis 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
Patch Changes
-
#11780
c6622adThanks @Princesseuh! - Deprecates the Squoosh image service, to be removed in Astro 5.0. We recommend migrating to the default Sharp service. -
#11732
4cd6c43Thanks @matthewp! - Use GET requests with preloading for Server IslandsServer 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
86a3391Thanks @ematipico! - Changes messages logged when using unsupported, deprecated, or experimental adapter features for clarity -
#11774
c6400abThanks @florian-lefebvre! - Fixes the path returned byinjectTypes -
#11771
49650a4Thanks @florian-lefebvre! - Fixes an error thrown byastro syncwhen anastro:envvirtual module is imported inside the Content Collections config -
#11744
b677429Thanks @bluwy! - Disables the WebSocket server when creating a Vite server for loading config files
Major Changes
-
#10742
b6fbdaaThanks @ematipico! - The lowest version of Node supported by Astro is now Node v18.17.1 and higher. -
#11715
d74617cThanks @Princesseuh! - Refactor the exported types from theastromodule. 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
e90f559Thanks @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
.astroexamples, onlyallowfullscreenis 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
8a53517Thanks @matthewp! - Remove support for functionPerRouteThis change removes support for the
functionPerRouteoption 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.
Patch Changes
Patch Changes
- #14241
760acc8Thanks @ematipico! - Fixes an issue where remote paths weren't correctly computed when generating assets
Patch Changes
- #12632
e7d14c3Thanks @ematipico! - Fixes an issue where thecheckOriginfeature wasn't correctly checking thecontent-typeheader
Patch Changes
- #12498
b140a3fThanks @ematipico! - Fixes a regression where Astro was trying to accessRequest.headers
Patch Changes
-
#12480
c3b7e7cThanks @matthewp! - Removes the default throw behavior inastro:env -
#12444
28dd3ceThanks @ematipico! - Fixes an issue where a server island hydration script might fail case the island ID misses from the DOM. -
#12476
80a9a52Thanks @florian-lefebvre! - Fixes a case where the Content Layerglob()loader would not update when renaming or deleting an entry -
#12418
25baa4eThanks @oliverlynch! - Fix cached image redownloading if it is the first asset -
#12477
46f6b38Thanks @ematipico! - Fixes an issue where the SSR build was emitting thedist/server/entry.mjsfile with an incorrect import at the top of the file/ -
#12365
a23985bThanks @apatel369! - Fixes an issue whereAstro.currentLocalewas not correctly returning the locale for 404 and 500 pages.
Patch Changes
-
#12436
453ec6bThanks @martrapp! - Fixes a potential null access in the clientside router -
#12392
0462219Thanks @apatel369! - Fixes an issue where scripts were not correctly injected during the build. The issue was triggered when there were injected routes with the sameentrypointand differentpattern
Patch Changes
- #12420
acac0afThanks @ematipico! - Fixes an issue where the dev server returns a 404 status code when a user middleware returns a validResponse.
Patch Changes
-
#12305
f5f7109Thanks @florian-lefebvre! - Fixes a case where the error overlay would not escape the message -
#12402
823e73bThanks @ematipico! - Fixes a case where Astro allowed to call an action without usingAstro.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
9cca108Thanks @bholmesdev! - Fixes unexpected 200 status in dev server logs for action errors and redirects.
Patch Changes
-
#12311
bf2723eThanks @dinesh-58! - Addscheckedto the list of boolean attributes. -
#12363
222f718Thanks @Fryuni! - Fixes code generated byastro addcommand when adding a version of an integration other than the defaultlatest. -
#12368
493fe43Thanks @bluwy! - Improves error logs when executing commands -
#12355
c4726d7Thanks @apatel369! - Improves error reporting for invalid frontmatter in MDX files during theastro buildcommand. The error message now includes the file path where the frontmatter parsing failed.
Patch Changes
-
#12333
836cd91Thanks @imattacus! - Destroy the server response stream if async error is thrown -
#12358
7680349Thanks @spacedawwwg! - HonorsinlineAstroConfigparameter ingetViteConfigwhen creating a logger -
#12353
35795a1Thanks @hippotastic! - Fixes an issue in dev server watch file handling that could cause multiple restarts for a single file change. -
#12351
5751488Thanks @florian-lefebvre! - Reverts a change made in4.16.6that prevented usage ofastro:envsecrets inside middleware in SSR -
#12346
20e5a84Thanks @bluwy! - Fixes sourcemap generation when prefetch is enabled -
#12349
1fc83d3Thanks @norskeld! - Fixes thegetImageoptions type so it properly extendsImageTransform
Patch Changes
-
#12338
9ca89b3Thanks @situ2001! - ResetsNODE_ENVto ensure install command run in dev mode -
#12286
9d6bcdbThanks @florian-lefebvre! - Fixes a case where a warning for experimentalastro:envsupport would be shown when using an adapter but not actually usingastro:env -
#12342
ffc836bThanks @liruifengv! - Fixes a typo in the command name of the CLI -
#12301
0cfc69dThanks @apatel369! - Fixes an issue with action handler context by passing the correct context (ActionAPIContext). -
#12312
5642ef9Thanks @koyopro! - Fixes an issue where usinggetViteConfig()returns incorrect and duplicate configuration -
#12245
1d4f6a4Thanks @bmenant! - Addcomponentsproperty to MDXInstance type definition (RenderResult and module import) -
#12340
94eaeeaThanks @ematipico! - Fixes an issue where Astro actions didn't work whenbasewas different from/
Patch Changes
-
#12263
e9e8080Thanks @Fryuni! - Fixes conflict between server islands and on-demand dynamic routes in the form of/[...rest]or/[paramA]/[paramB]. -
#12279
b781f88Thanks @jsparkdev! - Update wrong error message -
#12273
c2ee963Thanks @ascorbic! - Fixes an issue with some package managers where sites would not build if TypeScript was not installed. -
#12235
a75bc5eThanks @ematipico! - Fixes a bug where Astro Actions couldn't redirect to the correct pathname when there was a rewrite involved. -
#11839
ff522b9Thanks @icaliman! - Fixes error when returning a top-levelnullfrom an Astro file frontmatter -
#12272
388d237Thanks @ascorbic! - Correctly handles local images when using a base path in SSR
Patch Changes
-
#11823
a3d30a6Thanks @DerTimonius! - fix: improve error message when inferSize is used in local images with the Image component -
#12227
8b1a641Thanks @florian-lefebvre! - Fixes a case where environment variables would not be refreshed when usingastro:env -
#12239
2b6daa5Thanks @ematipico! - BREAKING CHANGE to the experimental Container API onlyChanges the default page rendering behavior of Astro components in containers, and adds a new option
partial: falseto 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: falsetorenderToString()andrenderToResponse():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>`
Patch Changes
-
#12223
79ffa5dThanks @ArmandPhilippot! - Fixes a false positive reported by the dev toolbar Audit app where a label was considered missing when associated with a buttonThe
buttonelement 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 alabel. -
#12199
c351352Thanks @ematipico! - Fixes a regression in the computation ofAstro.currentLocale -
#12222
fb55695Thanks @ematipico! - Fixes an issue where the edge middleware couldn't correctly compute the client IP address when callingctx.clientAddress()
Patch Changes
- #12206
12b0022Thanks @bluwy! - Reverts https://github.com/withastro/astro/pull/12173 which causedCan't modify immutable headerswarnings and 500 errors on Cloudflare Pages
Patch Changes
-
#12177
a4ffbfaThanks @matthewp! - Ensure we target scripts for execution in the routerUsing
document.scriptsis unsafe because if the application has aname="scripts"this will shadow the built-indocument.scripts. Fix is to usegetElementsByTagNameto ensure we're only grabbing real scripts. -
#12173
2d10de5Thanks @ematipico! - Fixes a bug where Astro Actions couldn't redirect to the correct pathname when there was a rewrite involved.
Minor Changes
-
#12039
710a1a1Thanks @ematipico! - Adds amarkdown.shikiConfig.langAliasoption 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
cjscode blocks using thejavascriptsyntax 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
3ac2263Thanks @chaegumi! - Adds a newbuild.concurrenyconfiguration option to specify the number of pages to build in parallelIn 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.
// astro.config.mjs import { defineConfig } from 'astro'; export default defineConfig({ build: { concurrency: 2, }, });
Patch Changes
-
#12160
c6fd1dfThanks @louisescher! - Fixes a bug whereastro.config.mtsandastro.config.ctsweren't reloading the dev server upon modifications. -
#12130
e96bcaeThanks @thehansys! - Fixes a bug in the parsing ofx-forwarded-\*Requestheaders, where multiple values assigned to those headers were not correctly parsed.Now, headers like
x-forwarded-proto: https,httpare correctly parsed. -
#12147
9db755aThanks @ascorbic! - Skips setting statusMessage header for HTTP/2 responseHTTP/2 doesn't support status message, so setting this was logging a warning.
-
#12151
bb6d37fThanks @ematipico! - Fixes an issue whereAstro.currentLocalewasn't incorrectly computed when thedefaultLocalebelonged to a custom locale path. -
Updated dependencies [
710a1a1]:- @astrojs/markdown-remark@5.3.0
Patch Changes
-
#12121
2490cebThanks @ascorbic! - Support passing the valuesInfinityand-Infinityas island props. -
#12118
f47b347Thanks @Namchee! - Removes thestrip-ansidependency in favor of the native Node API -
#12126
6e1dfebThanks @ascorbic! - Clear content layer cache when astro version changes -
#12117
a46839aThanks @ArmandPhilippot! - Updates Vite links to use their new domain -
#12124
499fbc9Thanks @ascorbic! - Allows special characters in Action names -
#12123
b8673dfThanks @Princesseuh! - Fixes missingbodyproperty on CollectionEntry types for content layer entries -
#12132
de35daaThanks @jcayzac! - Updates thecookiedependency to avoid the CVE 2024-47764 vulnerability. -
#12113
a54e520Thanks @ascorbic! - Adds a helpful error when attempting to render an undefined collection entry
Patch Changes
-
#12097
11d447fThanks @ascorbic! - Fixes error where references in content layer schemas sometimes incorrectly report as missing -
#12108
918953bThanks @lameuler! - Fixes a bug where data URL images were not correctly handled. The bug resulted in anENAMETOOLONGerror. -
#12105
42037f3Thanks @ascorbic! - Returns custom statusText that has been set in a Response -
#12109
ea22558Thanks @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
d3a74daThanks @ascorbic! - Handles case where an immutable Response object is returned from an endpoint -
#12090
d49a537Thanks @markjaquith! - Server islands: changes the server island HTML placeholder comment so that it is much less likely to get removed by HTML minifiers.
Patch Changes
-
#12084
12dae50Thanks @Princesseuh! - Adds missing filePath property on content layer entries -
#12046
d7779dfThanks @martrapp! - View transitions: Fixes Astro's fade animation to prevent flashing during morph transitions. -
#12043
1720c5bThanks @bluwy! - Fixes injected endpointprerenderoption detection -
#12095
76c5fbdThanks @TheOtterlord! - Fix installing non-stable versions of integrations withastro add
Patch Changes
-
#12034
5b3ddfaThanks @ematipico! - Fixes an issue where the middleware wasn't called when a project uses404.astro. -
#12042
243ecb6Thanks @ematipico! - Fixes a problem in the Container API, where a polyfill wasn't correctly applied. This caused an issue in some environments wherecryptoisn't supported. -
#12038
26ea5e8Thanks @ascorbic! - Resolves image paths in content layer with initial slash as project-relativeWhen 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.
Patch Changes
-
#12014
53cb41eThanks @ascorbic! - Fixes an issue where component styles were not correctly included in rendered MDX -
#12031
8c0cae6Thanks @ematipico! - Fixes a bug where the rewrite vianext(/*..*/)inside a middleware didn't compute the newAPIContext.params -
#12026
40e7a1bThanks @bluwy! - Initializes the Markdown processor only when there's.mdfiles -
#12028
d3bd673Thanks @bluwy! - Handles route collision detection only if it matchesgetStaticPaths -
#12027
dd3b753Thanks @fviolette! - Addselectedto the list of boolean attributes -
#12001
9be3e1bThanks @uwej711! - Remove dependency on path-to-regexp
Patch Changes
-
#11939
7b09c62Thanks @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
createorupdateform submission, and uses thetypefield 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
createandupdateforms 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
86ad1fdThanks @NikolaRHristov! - Fixes a typo in the server island JSDoc -
#11983
633eeaaThanks @uwej711! - Remove dependency on path-to-regexp
Patch Changes
-
#11879
bd1d4aaThanks @matthewp! - Allow passing a cryptography key via ASTRO_KEYFor 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_KEYenvironment 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
c58193aThanks @Princesseuh! - Fixesastro addnot using the proper export point when adding certain adapters
Patch Changes
-
#11902
d63bc50Thanks @ascorbic! - Fixes case where content layer did not update during clean dev builds on Linux and Windows -
#11886
7ff7134Thanks @matthewp! - Fixes a missing error message when actions throws duringastro sync -
#11904
ca54e3fThanks @wtchnm! - perf(assets): avoid downloading original image when using cache
Patch Changes
-
#11870
8e5257aThanks @ArmandPhilippot! - Fixes typo in documenting thefallbackTypeproperty in i18n routing -
#11884
e450704Thanks @ascorbic! - Correctly handles content layer data where the transformed value does not match the input schema -
#11900
80b4a18Thanks @delucis! - Fixes the user-facing type of the newi18n.routing.fallbackTypeoption to be optional
Minor Changes
-
#11729
1c54e63Thanks @ematipico! - Adds a new variantsyncfor theastro:config:setuphook'scommandproperty. This value is set when calling the commandastro sync.If your integration previously relied on knowing how many variants existed for the
commandproperty, you must update your logic to account for this new option. -
#11743
cce0894Thanks @ph1p! - Adds a new, optional propertytimeoutfor theclient:idledirective.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
cb356a5Thanks @ematipico! - Adds a new optionfallbackTypetoi18n.routingconfiguration that allows you to control how fallback pages are handled.When
i18n.fallbackis 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.htmlthat will contain the same HTML rendered by the page/en/index.htmlwhensrc/pages/fr/index.astrodoes not exist.// astro.config.mjs export default defineConfig({ i18n: { locals: ['en', 'fr'], defaultLocale: 'en', routing: { prefixDefaultLocale: true, fallbackType: 'rewrite', }, fallback: { fr: 'en', }, }, }); -
#11708
62b0d20Thanks @martrapp! - Adds a new objectswapFunctionsto expose the necessary utility functions onastro:transitions/clientthat 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
swapfunction 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-swaplifecycle event and adding a custom swap implementation. -
#11843
5b4070eThanks @bholmesdev! - Exposeszfrom the newastro:schemamodule. This is the new recommended import source for all Zod utilities when using Astro Actions.Migration for Astro Actions users
zwill no longer be exposed fromastro:actions. To usezin your actions, import it fromastro:schemainstead:import { defineAction, - z, } from 'astro:actions'; + import { z } from 'astro:schema'; -
#11843
5b4070eThanks @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:
--- // src/pages/newsletter.astro 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.
Patch Changes
-
#11677
cb356a5Thanks @ematipico! - Fixes a bug in the logic ofAstro.rewrite()which led to the value forbase, 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 hasbaseconfigured, you must now prepend the base to your existing rewrite URL:// astro.config.mjs export default defineConfig({ base: '/blog', });// src/middleware.js export function onRequest(ctx, next) { - return ctx.rewrite("/about") + return ctx.rewrite("/blog/about") } -
#11862
0e35afeThanks @ascorbic! - BREAKING CHANGE to experimental content layer loaders only!Passes
AstroConfiginstead ofAstroSettingsobject to content layer loaders.This will not affect you unless you have created a loader that uses the
settingsobject. If you have, you will need to update your loader to use theconfigobject 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
6272e6cThanks @bluwy! - Usesmagicastto update the config forastro add -
#11845
440a4beThanks @bluwy! - Replacesexecawithtinyexecinternally -
#11858
8bab233Thanks @ascorbic! - Correctly resolves content layer images when filePath is not set
Patch Changes
-
#11847
45b599cThanks @ascorbic! - Fixes a case where Vite would be imported by the SSR runtime, causing bundling errors and bloat. -
#11822
6fcaab8Thanks @bluwy! - Marks internalvite-plugin-fileurlplugin withenforce: 'pre' -
#11713
497324cThanks @voidfill! - Prevents prefetching of the same urls with different hashes. -
#11814
2bb72c6Thanks @eduardocereto! - Updates the documentation for experimental Content Layer API with a corrected code example -
#11842
1ffaae0Thanks @stephan281094! - Fixes a typo in theMissingImageDimensionerror message -
#11828
20d47aaThanks @bholmesdev! - Improves error message when invalid data is returned by an Action.
Patch Changes
-
#11809
62e97a2Thanks @bholmesdev! - Fixes usage of.transform(),.refine(),.passthrough(), and other effects on Action form inputs. -
#11812
260c4beThanks @bholmesdev! - ExposesActionAPIContexttype from theastro:actionsmodule. -
#11813
3f7630aThanks @bholmesdev! - Fixes unexpectedundefinedvalue when calling an action from the client without a return value.
Patch Changes
-
#11794
3691a62Thanks @bholmesdev! - Fixes unexpected warning log when using Actions on "hybrid" rendered projects. -
#11801
9f943c1Thanks @delucis! - Fixes a bug where thefilePathproperty was not available on content collection entries when using the content layerfile()loader with a JSON file that contained an object instead of an array. This was breaking use of theimage()schema utility among other things.
Patch Changes
-
#11780
c6622adThanks @Princesseuh! - Deprecates the Squoosh image service, to be removed in Astro 5.0. We recommend migrating to the default Sharp service. -
#11790
41c3fcbThanks @sarah11918! - Updates the documentation for experimentalastro:envwith a corrected link to the RFC proposal -
#11773
86a3391Thanks @ematipico! - Changes messages logged when using unsupported, deprecated, or experimental adapter features for clarity -
#11745
89bab1eThanks @bluwy! - Prints prerender dynamic value usage warning only if it's used -
#11774
c6400abThanks @florian-lefebvre! - Fixes the path returned byinjectTypes -
#11730
2df49a6Thanks @florian-lefebvre! - Simplifies path operations ofastro sync -
#11771
49650a4Thanks @florian-lefebvre! - Fixes an error thrown byastro syncwhen anastro:envvirtual module is imported inside the Content Collections config -
#11744
b677429Thanks @bluwy! - Disables the WebSocket server when creating a Vite server for loading config files
Patch Changes
-
#11725
6c1560fThanks @ascorbic! - Prevents content layer importing node builtins in runtime -
#11692
35af73aThanks @matthewp! - Prevent errant HTML from crashing server islandsWhen 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
3c2f93bThanks @florian-lefebvre! - Fixes a type issue when using the Content Layer in dev
Minor Changes
-
#11657
a23c69dThanks @bluwy! - Deprecates the option for route-generating files to export a dynamic value forprerender. Only static values are now supported (e.g.export const prerender = trueor= 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
prerenderexports from individual routing files:// src/pages/blog/[slug].astro - export const prerender = import.meta.env.PRERENDERInstead, create an integration with the
"astro:route:setup"hook and update the route'sprerenderoption:// astro.config.mjs 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
a79a8b0Thanks @ascorbic! - Adds a newinjectTypes()utility to the Integration API and refactors how type generation worksUse
injectTypes()in theastro:config:donehook to inject types into your user's project by adding a new a*.d.tsfile.The
filenameproperty will be used to generate a file at/.astro/integrations/<normalized_integration_name>/<normalized_filename>.d.tsand must end with".d.ts".The
contentproperty 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.// my-integration/index.js 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.tswill 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
d3d99fbThanks @jcayzac! - Adds a new propertymetato Astro's built-in<Code />component.This allows you to provide a value for Shiki's
metaattribute to pass options to transformers.The following example passes an option to highlight lines 1 and 3 to Shiki's
tranformerMetaHighlight:--- // src/components/Card.astro import { Code } from 'astro:components'; import { transformerMetaHighlight } from '@shikijs/transformers'; --- <Code code={code} lang="js" transformers={[transformerMetaHighlight()]} meta="{1,3}" /> -
#11360
a79a8b0Thanks @ascorbic! - Adds support for Intellisense features (e.g. code completion, quick hints) for your content collection entries in compatible editors under theexperimental.contentIntellisenseflag.import { defineConfig } from 'astro'; export default defineConfig({ experimental: { contentIntellisense: true, }, });When enabled, this feature will generate and add JSON schemas to the
.astrodirectory 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-intellisenseoption in your editor, or passing thecontentIntellisense: trueinitialization 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
a79a8b0Thanks @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.Getting started
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.tsusing the Content Layer API.Loading your content
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()andfile()loaders to handle your local Markdown, MDX, Markdoc, and JSON files:// src/content/config.ts 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 />Creating a loader
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:
// src/content/config.ts 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.
Sharing your loaders
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:
// src/content/config.ts 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 };Learn more
To find out more about using the Content Layer API, check out the Content Layer RFC and share your feedback.
Patch Changes
-
#11716
f4057c1Thanks @florian-lefebvre! - Fixes content types sync in dev -
#11645
849e4c6Thanks @bluwy! - Refactors internally to usenode:utilparseArgsinstead ofyargs-parser -
#11712
791d809Thanks @matthewp! - Fix mixed use of base + trailingSlash in Server Islands -
#11709
3d8ae76Thanks @matthewp! - Fix adapter causing Netlify to break
Patch Changes
-
#11678
34da907Thanks @ematipico! - Fixes a case where omitting a semicolon and line ending with carriage return - CRLF - in theprerenderoption could throw an error. -
#11535
932bd2eThanks @matthewp! - Encrypt server island propsServer 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
dc0a297Thanks @billy-le! - Fixes Astro Actionsinputvalidation when usingdefaultvalues with a form input. -
#11689
c7bda4cThanks @ematipico! - Fixes an issue in the Astro actions, where the size of the generated cookie was exceeding the size permitted by theSet-Cookieheader.
Patch Changes
-
#11653
32be549Thanks @florian-lefebvre! - Updatesastro:envdocs to reflect current developments and usage guidance -
#11658
13b912aThanks @bholmesdev! - FixesorThrow()type when calling an Action without aninputvalidator. -
#11603
f31d466Thanks @bholmesdev! - Improves user experience when render an Action result from a form POST request:- Removes "Confirm post resubmission?" dialog when refreshing a result.
- Removes the
?_astroAction=NAMEflag 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
actionstring 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
/successroute whenactions.signupsucceeds. You can add/successto youractionstring like so:<form method="POST" action={'/success' + actions.signup}></form>- On success, Astro will redirect to
/success. - On error, Astro will redirect back to the current page.
You can retrieve the action result from either page using the
Astro.getActionResult()function.Note on security
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
loginfunction may return a user's session id to retrieve from your Astro frontmatter, rather than the entire user object.
Patch Changes
-
#11648
589d351Thanks @bholmesdev! - Fixes unexpected error when refreshing a POST request from a form using Actions. -
#11600
09ec2caThanks @ArmandPhilippot! - DeprecatesgetEntryBySlugandgetDataEntryByIdfunctions exported byastro:contentin favor ofgetEntry. -
#11593
81d7150Thanks @bholmesdev! - Adds support forDate(),Map(), andSet()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
196092aThanks @abubakriz! - Fix toolbar audit incorrectly flagging images as above the fold. -
#11634
2716f52Thanks @bholmesdev! - Fixes internal server error when calling an Astro Action without arguments on Vercel. -
#11628
9aaf58cThanks @madbook! - Ensures consistent CSS chunk hashes across different environments
Patch Changes
-
#11584
a65ffe3Thanks @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 */ } }Migration
If you call actions directly from server code, update function calls to use the
Astro.callAction()wrapper for pages andcontext.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_compatornodejs_alsflags for Actions, we recommend removing these:compatibility_flags = [ - "nodejs_compat", - "nodejs_als" ]You can also remove
node:async_hooksfrom thevite.ssr.externaloption in yourastro.configfile:// astro.config.mjs import { defineConfig } from 'astro/config'; export default defineConfig({ - vite: { - ssr: { - external: ["node:async_hooks"] - } - } })
Minor Changes
-
#11507
a62345fThanks @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
e5e2d3eThanks @alexanderniebuhr! - Theexperimental.contentCollectionJsonSchemafeature 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 insrc/content/config.tsusing a library calledzod-to-json-schema.This feature requires you to manually set your schema's file path as the value for
$schemain 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.schemassetting, 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
45ad326Thanks @ematipico! - Theexperimental.rewritingfeature introduced behind a flag in v4.8.0 is no longer experimental and is available for general use.Astro.rewrite()andcontext.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.astropage component to display a different page's content, such as fallback localized content:--- // src/pages/es-cu/articles/introduction.astro return Astro.rewrite("/es/articles/introduction") ---Use
context.rewrite()in endpoints, for example to reroute to a different page:// src/pages/api.js export function GET(context) { if (!context.locals.allowed) { return context.rewrite('/'); } }The middleware
next()function now accepts a parameter with the same type as therewrite()function. For example, withnext("/"), you can call the next middleware function with a newRequest.// src/middleware.js 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:
// astro.config.mjs 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.
Patch Changes
-
#11509
dfbca06Thanks @bluwy! - Excludes hoisted scripts and styles from Astro components imported with?urlor?raw -
#11561
904f1e5Thanks @ArmandPhilippot! - Uses the correct pageSize default inpage.sizeJSDoc comment -
#11571
1c3265aThanks @bholmesdev! - BREAKING CHANGE to the experimental Actions API only. Install the latest@astrojs/reactintegration 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'; // Before const { data, error } = await actions.like.safe(); // After const { data, error } = await actions.like(); // Before const newLikes = await actions.like(); // After const newLikes = await actions.like.orThrow();Migration
To migrate your existing action calls:
- Remove
.safefrom existing safe action calls - Add
.orThrowto existing unsafe action calls
- Remove
-
#11546
7f26de9Thanks @ArmandPhilippot! - Remove "SSR Only" mention inAstro.redirectinline documentation and update reference link. -
#11525
8068131Thanks @ematipico! - Fixes a case where the build was failing whenexperimental.actionswas enabled, an adapter was in use, and there were not actions inside the user code base. -
#11574
e3f29d4Thanks @Princesseuh! - Fixes line with the error not being properly highlighted in the error overlay -
#11570
84189b6Thanks @bholmesdev! - BREAKING CHANGE to the experimental Actions API only. Install the latest@astrojs/reactintegration as well if you're using React 19 features.Updates the Astro Actions fallback to support
action={actions.name}instead of usinggetActionProps().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.queryStringproperty:--- 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>Migration
getActionProps()is now deprecated. To use the new fallback pattern, remove thegetActionProps()input from your form and pass your action function to the formactionattribute:--- 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
1953dbbThanks @bryanwood! - Allows actions to return falsy values without an error -
#11553
02c85b5Thanks @ematipico! - Fixes an issue in content collection caching, where two documents with the same contents were generating an error during the build. -
#11548
602c5bfThanks @TheOtterlord! - Fixesastro addfor packages with only prerelease versions -
#11566
0dcef3aThanks @Princesseuh! - Fixes DomException errors not being handled properly -
#11529
504c383Thanks @matthewp! - Fix server islands with trailingSlash: always
Patch Changes
-
#11505
8ff7658Thanks @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 200ms 08:22:13 [200] (rewrite) /about 23ms -
#11506
026e8baThanks @sarah11918! - Fixes typo in documenting theslot="fallback"attribute for Server Islands experimental feature. -
#11508
ca335e1Thanks @cramforce! - Escapes HTML in serialized props -
#11501
4db78aeThanks @martrapp! - Adds the missing export for accessing thegetFallback()function of the client site router.
Patch Changes
-
#11486
9c0c849Thanks @ematipico! - Adds a new function calledaddClientRendererto the Container API.This function should be used when rendering components using the
client:*directives. TheaddClientRendererAPI must be used after the use of theaddServerRenderer: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
4e142d3Thanks @Princesseuh! - Fixes inferRemoteSize type not working -
#11496
53ccd20Thanks @alfawal! - Hide the dev toolbar onwindow.print()(CTRL + P)
Minor Changes
-
#11341
49b5145Thanks @madcampos! - Adds support for Shiki'sdefaultColoroption.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: falsein 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
2e70741Thanks @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.IntegrationHooksinterface:// your-integration/types.ts 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:
// your-integration/index.ts 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:
// other-integration/index.ts import 'your-integration/types.ts'; export default (): AstroIntegration => { return { name: 'other-integration', hooks: { 'myLib:eventHappened': async (your, values) => { // ... }, }, }; }; -
#11305
d495df5Thanks @matthewp! - Experimental Server IslandsServer 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
.astrocomponent into a server island by adding theserver:deferdirective 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:deferdirective can be used on any Astro component in a project usinghybridorservermode 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
outputmode 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
7c9ed71Thanks @Princesseuh! - Adds a--noSyncparameter to theastro checkcommand to skip the type-gen step. This can be useful when runningastro checkinside packages that have Astro components, but are not Astro projects -
#11098
36e30a3Thanks @itsmatteomanf! - Adds a newinferRemoteSize()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 orgetImage(). 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
6f9b527Thanks @ARipeAppleByYoursTruly! - Adds Shiki'sdefaultColoroption to the<Code />component, giving you more control in applying multiple themes -
#11176
a751458Thanks @tsawada! - Adds two new values to the paginationpageprop:page.firstandpage.lastfor accessing the URLs of the first and last pages.
Patch Changes
-
#11477
7e9c4a1Thanks @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
ca969d5Thanks @florian-lefebvre! - Fixes a case where invalidastro:envvariables at runtime would not throw correctly -
#11489
061f1f4Thanks @ematipico! - Move root inside the manifest and make serialisable -
#11415
e9334d0Thanks @florian-lefebvre! - Refactors howsyncworks and when it's called. Fixes an issue withastro:envtypes in dev not being generated -
#11478
3161b67Thanks @bluwy! - Supports importing Astro components with Vite queries, like?url,?raw, and?direct -
#11491
fe3afebThanks @matthewp! - Fix for Server Islands in Vercel adapterVercel, and probably other adapters only allow pre-defined routes. This makes it so that the
astro:build:donehook includes the_server-islands/route as part of the route data, which is used to configure available routes. -
#11483
34f9c25Thanks @Princesseuh! - Fixes Astro not working on low versions of Node 18 and 20 -
Updated dependencies [
49b5145]:- @astrojs/markdown-remark@5.2.0
Patch Changes
-
#11459
bc2e74dThanks @mingjunlu! - Fixes false positive audit warnings on elements with the role "tabpanel". -
#11472
cb4e6d0Thanks @delucis! - Avoids targeting all files in thesrc/directory for eager optimization by Vite. After this change, only JSX, Vue, Svelte, and Astro components get scanned for early optimization. -
#11387
b498461Thanks @bluwy! - Fixes prerendering not removing unused dynamic imported chunks -
#11437
6ccb30eThanks @NuroDev! - Fixes a case where Astro's configexperimental.env.schemakeys did not allow numbers. Numbers are still not allowed as the first character to be able to generate valid JavaScript identifiers -
#11439
08baf56Thanks @bholmesdev! - Expands theisInputError()utility fromastro:actionsto accept errors of any type. This should now allow type narrowing from a try / catch block.// example.ts import { actions, isInputError } from 'astro:actions'; try { await actions.like(new FormData()); } catch (error) { if (isInputError(error)) { console.log(error.fields); } } -
#11452
0e66849Thanks @FugiTech! - Fixes an issue where using .nullish() in a formdata Astro action would always parse as a string -
#11438
619f07dThanks @bholmesdev! - Exposes utility types fromastro:actionsfor thedefineActionhandler (ActionHandler) and theActionErrorcode (ActionErrorCode). -
#11456
17e048dThanks @RickyC0626! - Fixesastro dev --openunexpected behavior that spawns a new tab every time a config file is saved -
#11337
0a4b31fThanks @florian-lefebvre! - Adds a new propertyexperimental.env.validateSecretsto allow validating private variables on the server.By default, this is set to
falseand 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.// astro.config.mjs import { defineConfig, envField } from 'astro/config'; export default defineConfig({ experimental: { env: { schema: { // ... }, validateSecrets: true, }, }, }); -
#11443
ea4bc04Thanks @bholmesdev! - Expose newActionReturnTypeutility fromastro:actions. This infers the return type of an action by passingtypeof actions.nameas a type argument. This example defines alikeaction that returnslikesas an object:// actions/index.ts 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:// client.ts import { actions, ActionReturnType } from 'astro:actions'; type LikesResult = ActionReturnType<typeof actions.like>; // -> { likes: number } -
#11436
7dca68fThanks @bholmesdev! - Fixesastro:actionsautocompletion for thedefineActionacceptproperty -
#11455
645e128Thanks @florian-lefebvre! - Improvesastro:envinvalid variables errors
Patch Changes
-
#11362
93993b7Thanks @ematipico! - Fixes an issue where creating manually the i18n middleware could break the logic of the functions of the virtual moduleastro:i18n -
#11349
98d9ce4Thanks @ematipico! - Fixes an issue where Astro didn't throw an error whenAstro.rewritewas used without providing the experimental flag -
#11352
a55ee02Thanks @ematipico! - Fixes an issue where the rewrites didn't update the status code when using manual i18n routing. -
#11388
3a223b4Thanks @mingjunlu! - Adjusts the color of punctuations in error overlay. -
#11369
e6de11fThanks @bluwy! - Fixes attribute rendering for non-boolean attributes with boolean values
Patch Changes
-
#11335
4c4741bThanks @ematipico! - Reverts #11292, which caused a regression to the input type -
#11326
41121fbThanks @florian-lefebvre! - Fixes a case where runningastro syncwhen using the experimentalastro:envfeature would fail if environment variables were missing -
#11338
9752a0bThanks @zaaakher! - Fixes svg icon margin in devtool tooltip title to look coherent inrtlandltrlayouts -
#11331
f1b78a4Thanks @bluwy! - Removesresolvepackage and simplify internal resolve check -
#11339
8fdbf0eThanks @matthewp! - Remove non-fatal errors from telemetryPreviously 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.
Patch Changes
-
#11308
44c61ddThanks @ematipico! - Fixes an issue where custom404.astroand500.astrowere not returning the correct status code when rendered inside a rewriting cycle. -
#11302
0622567Thanks @martrapp! - Fixes an issue with the view transition router when redirecting to an URL with different origin. -
Updated dependencies [
b6afe6a,41064ce]:- @astrojs/markdown-remark@5.1.1
- @astrojs/internal-helpers@0.4.1
Minor Changes
-
#11197
4b46bd9Thanks @braebo! - AddsShikiTransformersupport to the<Code />component with a newtransformersprop.Note that
transformersonly 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
9042be0Thanks @florian-lefebvre! - Improves the developer experience of the500.astrofile by passing it a newerrorprop.When an error is thrown, the special
src/pages/500.astropage now automatically receives the error as a prop. This allows you to display more specific information about the error on a custom 500 page.--- // src/pages/500.astro 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.
Patch Changes
-
#11280
fd3645fThanks @ascorbic! - Fixes a bug that prevented cookies from being set when using experimental rewrites -
#11275
bab700dThanks @syhily! - Drop duplicated brackets in data collections schema generation. -
#11272
ea987d7Thanks @ematipico! - Fixes a case where rewriting/would cause an issue, whentrailingSlashwas set to"never". -
#11272
ea987d7Thanks @ematipico! - Reverts a logic where it wasn't possible to rewrite/404in static mode. It's now possible again -
#11264
5a9c9a6Thanks @Fryuni! - Fixes type generation for empty content collections -
#11279
9a08d74Thanks @ascorbic! - Improves type-checking and error handling to catch case where an image import is passed directly togetImage() -
#11292
7f8f347Thanks @jdtjenkins! - Fixes a case wheredefineActionautocomplete for theacceptprop would not show"form"as a possible value -
#11273
cb4d078Thanks @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
f4b029bThanks @ascorbic! - Fixes an issue that would breakAstro.request.urlandAstro.request.headersinastro devif HTTP/2 was enabled.HTTP/2 is now enabled by default in
astro devifhttpsis configured in the Vite config.
Patch Changes
-
#11213
94ac7efThanks @florian-lefebvre! - Removes thePUBLIC_prefix constraint forastro:envpublic variables -
#11213
94ac7efThanks @florian-lefebvre! - BREAKING CHANGE to the experimentalastro:envfeature onlyServer secrets specified in the schema must now be imported from
astro:env/server. UsinggetSecret()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
4385bf7Thanks @ematipico! - Adds a new function calledaddServerRendererto 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 core import mdxRenderer from 'astro/jsx/server.js'; // In case you need to import a custom renderer import 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
de60c69Thanks @markgaze! - Fixes a performance issue with JSON schema generation -
#11242
e4fc2a0Thanks @ematipico! - Fixes a case where the virtual moduleastro:containerwasn't resolved -
#11236
39bc3a5Thanks @ascorbic! - Fixes a case where symlinked content collection directories were not correctly resolved -
#11258
d996db6Thanks @ascorbic! - Adds a new errorRewriteWithBodyUsedthat throws whenAstro.rewriteis used after the request body has already been read. -
#11243
ba2b14cThanks @V3RON! - Fixes a prerendering issue for libraries innode_moduleswhen a folder with an underscore is in the path. -
#11244
d07d2f7Thanks @ematipico! - Improves the developer experience of the custom500.astropage 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.astropage.Now, the development server will display the
500.astroand the original error is logged in the console. -
#11240
2851b0aThanks @ascorbic! - Ignores query strings in module identifiers when matching ".astro" file extensions in Vite plugin -
#11245
e22be22Thanks @bluwy! - Refactors prerendering chunk handling to correctly remove unused code during the SSR runtime
Patch Changes
-
#11231
58d7dbbThanks @ematipico! - Fixes a regression forgetViteConfig, where the inline config wasn't merged in the final config. -
#11228
1e293a1Thanks @ascorbic! - UpdatesgetCollection()to always return a cloned array -
#11207
7d9aac3Thanks @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
75a8fe7Thanks @ematipico! - Improve error message when usinggetLocaleByPathon path that doesn't contain any locales. -
#11195
0a6ab6fThanks @florian-lefebvre! - Adds support for enums toastro:envYou 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
66fc028Thanks @matthewp! - Close the iterator only after rendering is complete -
#11195
0a6ab6fThanks @florian-lefebvre! - Adds additional validation options toastro:envastro:envschema datatypesstringandnumbernow 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
97724daThanks @matthewp! - Let middleware handle the original request URL -
#10607
7327c6aThanks @frankbits! - Fixes an issue where a leading slash created incorrect conflict resolution between pages generated from static routes and catch-all dynamic routes
Patch Changes
-
#11198
8b9a499Thanks @florian-lefebvre! - Fixes a case whereastro:envgetSecretwould not retrieve environment variables properly in dev and build modes -
#11206
734b98fThanks @florian-lefebvre! - BREAKING CHANGE to the experimentalastro:envfeature onlyUpdates the adapter
astro:enventrypoint fromastro:env/setuptoastro/env/setup -
#11205
8c45391Thanks @Nin3lee! - Fixes a typo in the config reference
Minor Changes
-
#10974
2668ef9Thanks @florian-lefebvre! - Adds experimental support for theastro:envAPI.The
astro:envAPI 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/clientor/servermodule:--- 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. TheenvFieldhelper allows you define your variable as a string, number, or boolean and pass properties in an object:// astro.config.mjs 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(clientorserver) andaccess(privateorpublic) settings defined in yourenv.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/clientmodule: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/servermodule: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 theastro:env/servermodule:import { getSecret } from 'astro:env/server'; const API_SECRET = getSecret('API_SECRET'); // typed const SECRET_NOT_IN_SCHEMA = getSecret('SECRET_NOT_IN_SCHEMA'); // string | undefined
Note: 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"andaccess: "secret"in your schema.To learn more, check out the documentation.
-
Patch Changes
-
#11192
58b10a0Thanks @liruifengv! - Improves DX by throwing the originalAstroUserErrorwhen an error is thrown inside a.mdxfile. -
#11136
35ef53cThanks @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
803dd80Thanks @ematipico! - The integration now exposes a function calledgetContainerRenderer, 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
803dd80Thanks @ematipico! - BREAKING CHANGE to the experimental Container API onlyChanges the type of the
renderersoption of theAstroContainer::createfunction and adds a dedicated functionloadRenderers()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 fromastro:container, a virtual module that can be used when running the Astro container insidevite. -
#11136
35ef53cThanks @ematipico! - It's not possible anymore to useAstro.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
6e29a17Thanks @matthewp! - Fixes a case whereAstro.urlwould be incorrect when havingbuild.formatset to'preserve'in the Astro config -
#11182
40b0b4dThanks @ematipico! - Fixes an issue whereAstro.rewritewasn't carrying over the body of aRequestin on-demand pages. -
#11194
97fbe93Thanks @ematipico! - Fixes an issue where the functiongetViteConfigwasn't returning the correct merged Astro configuration
Patch Changes
-
#11171
ff8004fThanks @Princesseuh! - Guard globalThis.astroAsset usage in proxy code to avoid errors in wonky situations -
#11178
1734c49Thanks @theoephraim! - ImprovesisPromiseutility to check the presence ofthenon an object before trying to access it - which can cause undesired side-effects on Proxy objects -
#11183
3cfa2acThanks @66Leo66! - Suggestpnpm dlxinstead ofpnpxin update check. -
#11147
2d93902Thanks @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
19df89fThanks @ematipico! - Fixes an internal error that prevented theAstroContainerto render theContentcomponent.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
ba20c71Thanks @matthewp! - Retain client scripts in content cache
Patch Changes
-
#11138
98e0372Thanks @ematipico! - You can now passpropswhen 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, }, });
Minor Changes
-
#11051
12a1bccThanks @ematipico! - Introduces an experimental Container API to render.astrocomponents 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 theResponseemitted 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
2d4c8faThanks @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
securityoption inastro.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,DELETEandPUTwith 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
securityconfiguration docs. -
#11022
be68ab4Thanks @ematipico! - Thei18nDomainsrouting 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
siteconfigured.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
8ca7c73Thanks @bholmesdev! - Adds two new functionsexperimental_getActionState()andexperimental_withState()to support the React 19useActionState()hook when using Astro Actions. This introduces progressive enhancement when calling an Action with thewithState()utility.This example calls a
likeaction that accepts apostIdand returns the number of likes. Pass this action to theexperimental_withState()function to apply progressive enhancement info, and apply touseActionState()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 actionhandler. Callexperimental_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
a6916e4Thanks @linguofeng! - Updates Astro's code for adapters to use the headerx-forwarded-forto initialize theclientAddress.To take advantage of the new change, integration authors must upgrade the version of Astro in their adapter
peerDependenciesto4.9.0. -
#11071
8ca7c73Thanks @bholmesdev! - Adds compatibility for Astro Actions in the React 19 beta. Actions can be passed to aform actionprop 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> ); }
Patch Changes
-
#11088
9566fa0Thanks @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:actionsas you would for client actions:--- // src/pages/blog/[postId].astro import { actions } from 'astro:actions'; await actions.like({ postId: Astro.params.postId }); --- -
#11112
29a8650Thanks @bholmesdev! - Deprecate thegetApiContext()function. API Context can now be accessed from the second parameter to your Actionhandler():// src/actions/index.ts 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; } }), }
Patch Changes
-
#11073
f5c8feeThanks @matthewp! - Prevent cache content from being left in dist folderWhen
contentCollectionsCacheis enabled temporary cached content is copied into theoutDirfor processing. This fixes it so that this content is cleaned out, along with the rest of the temporary build JS. -
#11054
f6b171eThanks @bholmesdev! - Respect error status when handling Actions with a progressive fallback. -
#11092
bfe9c73Thanks @duckycoding-dev! - Changeslotattribute ofIntrinsicAttributesto match the definition ofHTMLAttributes's ownslotattribute of typestring | undefined | null -
#10875
b5f95b2Thanks @W1M0R! - Fixes a typo in a JSDoc annotation -
#11111
a5d79ddThanks @bholmesdev! - Fix unexpectedheaderswarning on prerendered routes when using Astro Actions. -
#11081
af42e05Thanks @V3RON! - Correctly position inspection tooltip in RTL modeWhen 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.
Patch Changes
-
#11065
1f988edThanks @ematipico! - Fixes a bug in the Astro rewrite logic, where rewriting the index with parameters -next("/?foo=bar")- didn't work as expected. -
#10924
3a0c02aThanks @Its-Just-Nans! - Handle image-size errors by displaying a clearer message -
#11058
749a7acThanks @matthewp! - Fix streaming in Node.js fast path -
#11052
a05ca38Thanks @florian-lefebvre! - Fixes a case where rewriting would conflict with the actions internal middleware -
#11062
16f12e4Thanks @ematipico! - Fixes a bug whereastro builddidn't create custom404.htmland500.htmlwhen a certain combination of i18n options was applied -
#10965
a8f0372Thanks @Elias-Chairi! - Update generator.ts to allow %23 (#) in dynamic urls -
#11069
240a70aThanks @ematipico! - Improves debug logging for on-demand pages
Patch Changes
-
#11026
8dfb1a2Thanks @bluwy! - Skips rendering script tags if it's inlined and empty whenexperimental.directRenderScriptis enabled -
#11043
d0d1710Thanks @bholmesdev! - Fixes minor type issues in actions component example -
#10999
5f353e3Thanks @bluwy! - The prefetch feature is updated to better support different browsers and different cache headers setup, including:- All prefetch strategies will now always try to use
<link rel="prefetch">if supported, or will fall back tofetch(). - The
prefetch()programmatic API'swithoption is deprecated in favour of an automatic approach that will also try to use<link rel="prefetch>if supported, or will fall back tofetch().
This change shouldn't affect most sites and should instead make prefetching more effective.
- All prefetch strategies will now always try to use
-
#11041
6cc3fb9Thanks @bholmesdev! - Fixes 500 errors when sending empty params or returning an empty response from an action. -
#11028
771d1f7Thanks @bholmesdev! - Throw on missing server output when using Astro Actions. -
#11029
bd34452Thanks @bholmesdev! - Actions: include validation error in thrown error message for debugging. -
#11046
086694aThanks @HiDeoo! - FixesgetViteConfig()type definition to allow passing an inline Astro configuration as second argument -
#11026
8dfb1a2Thanks @bluwy! - Fixes CSS handling if imported in a script tag in an Astro file whenexperimental.directRenderScriptis enabled -
#11020
2e2d6b7Thanks @xsynaptic! - Add type declarations forimport.meta.env.ASSETS_PREFIXwhen defined as an object for handling different file types. -
#11030
18e7f33Thanks @bholmesdev! - Actions: Fix missing message for custom Action errors. -
#10981
ad9227cThanks @mo! - Adds deprecated HTML attribute "name" to the list of valid attributes. This attribute has been replaced by the globalidattribute in recent versions of HTML. -
#11013
4ea38e7Thanks @QingXia-Ela! - Prevents unhandledrejection error when checking for latest Astro version -
#11034
5f2dd45Thanks @arganaphang! - Addpopovertargetactionto the attribute that can be passed to thebuttonandinputelement
Patch Changes
- #11006
7418bb0Thanks @bholmesdev! - Fixlocalsaccess from action handlers
Patch Changes
-
#10990
4161a2aThanks @liruifengv! - fix incorrect actions path on windows -
#10979
6fa89e8Thanks @BryceRussell! - Fix loading of non-index routes that end withindex.html
Patch Changes
-
#10987
05db5f7Thanks @ematipico! - Fix a regression where the flagexperimental.rewritingwas marked mandatory. Is is now optional. -
#10975
6b640b3Thanks @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
Minor Changes
-
#10935
ddd8e49Thanks @bluwy! - Exportsastro/jsx/rehype.jswith utilities to generate an Astro metadata object -
#10625
698c2d9Thanks @goulvenclech! - Adds the ability for multiple pages to use the same component as anentrypointwhen building an Astro integration. This change is purely internal, and aligns the build process with the behaviour in the development server. -
#10906
7bbd664Thanks @Princesseuh! - Adds a new radio checkbox component to the dev toolbar UI library (astro-dev-toolbar-radio-checkbox) -
#10963
61f47a6Thanks @delucis! - Adds support for passing an inline Astro configuration object togetViteConfig()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.// vitest.config.ts import { getViteConfig } from 'astro/config'; export default getViteConfig( /* Vite configuration */ { test: {} }, /* Astro configuration */ { site: 'https://example.com', trailingSlash: 'never', } ); -
#10867
47877a7Thanks @ematipico! - Adds experimental rewriting in Astro with a newrewrite()function and the middlewarenext()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.--- // src/pages/dashboard.astro if (!Astro.props.allowed) { return Astro.rewrite('/'); } ---// src/pages/api.js export function GET(ctx) { if (!ctx.locals.allowed) { return ctx.rewrite('/'); } }The middleware
next()function now accepts a parameter with the same type as therewrite()function. For example, withnext("/"), you can call the next middleware function with a newRequest.// src/middleware.js 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
c0c509bThanks @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
outputproperty and add theactionsflag to theexperimentalobject:{ 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 theastro:actionsmodule. These accept thehandlerproperty to define your server-side request handler. If your action accepts arguments, apply theinputproperty to validate parameters with Zod.This example defines two actions:
likeandcomment. Thelikeaction accepts a JSON object with apostIdstring, while thecommentaction accepts FormData withpostId,author, andbodystrings. Eachhandlerupdates your database and return a type-safe response.// src/actions/index.ts 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
actionsobject fromastro:actions. You can pass a type-safe object when using JSON, or a FormData object when usingaccept: 'form'in your action definition:// src/components/blog.tsx 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
7bbd664Thanks @Princesseuh! - Adds a newbuttonBorderRadiusproperty to theastro-dev-toolbar-buttoncomponent for the dev toolbar component library. This property can be useful to make a fully rounded button with an icon in the center.
Patch Changes
-
#10977
59571e8Thanks @BryceRussell! - Improve error message when accessingclientAddresson prerendered routes -
#10935
ddd8e49Thanks @bluwy! - Improves the error message when failed to render MDX components -
#10917
3412535Thanks @jakobhellermann! - Fixes a case where the local server would crash when the host also contained the port, eg. withX-Forwarded-Host: hostname:8080andX-Forwarded-Port: 8080headers -
#10959
685fc22Thanks @bluwy! - Refactors internal handling of styles and scripts for content collections to improve build performance -
#10889
4d905ccThanks @matthewp! - Preserve content modules properly in cache -
#10955
2978287Thanks @florian-lefebvre! - HandlesAstroUserErrors thrown while syncing content collections and exportsBaseSchemaandCollectionConfigtypes
Patch Changes
-
#10911
a86dc9dThanks @bluwy! - Skips adding CSS dependencies of CSS Vite modules as style tags in the HTML -
#10900
36bb3b6Thanks @martrapp! - Detects overlapping navigation and view transitions and automatically aborts all but the most recent one. -
#10933
007d17fThanks @Princesseuh! - Fixesapp.toggleStatenot working correctly -
#10931
4ce5cedThanks @ktym4a! - FixestoggleNotification()'s parameter type for the notification level not using the proper levels
Minor Changes
-
#10665
7b4f284Thanks @Princesseuh! - Adds new utilities to ease the creation of toolbar apps includingdefineToolbarAppto make it easier to define your toolbar app andappandserverhelpers 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-toggledevent and manually typing the value in the callback, you can now use theonAppToggledmethod. Additionally, communicating with the server does not require knowing any of the Vite APIs anymore, as a newserverobject is passed to theinitfunction 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
toolbarobject:"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
6fc4c0eThanks @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 checkUpdatesor setting theASTRO_DISABLE_UPDATE_CHECKenvironment variable tofalse. -
#10762
43ead8fThanks @bholmesdev! - Enables type checking for JavaScript files when using thestrictestTS config. This ensures consistency with Astro's other TS configs, and fixes type checking for integrations like Astro DB when using anastro.config.mjs.If you are currently using the
strictestpreset and would like to still disable.jsfiles, setallowJS: falsein yourtsconfig.json.
Patch Changes
-
#10861
b673bc8Thanks @mingjunlu! - Fixes an issue whereastro buildwrites type declaration files tooutDirwhen it's outside of root directory. -
#10684
8b59d5dThanks @PeterDraex! - Update sharp to 0.33 to fix issue with Alpine Linux
Patch Changes
-
#10846
3294f7aThanks @matthewp! - Prevent getCollection breaking in vitest -
#10856
30cf82aThanks @robertvanhoesel! - Prevents inputs with a name attribute of action or method to break ViewTransitions' form submission -
#10833
8d5f3e8Thanks @renovate! - Updatesesbuilddependency to v0.20. This should not affect projects in most cases. -
#10801
204b782Thanks @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
a2df344Thanks @martrapp! - Due to regression on mobile WebKit browsers, reverts a change made for JavaScript animations during view transitions.
Patch Changes
-
#10799
dc74afca9f5eebc2d61331298d6ef187d92051e0Thanks @martrapp! - Fixes an issue with persisted non-text input fields that have the focus during view transition navigation. -
#10773
35e43ecdaae7adc4b9a0b974192a033568cfb3f0Thanks @lilnasy! - Improves performance for frequent use of small components. -
#10763
63132771373ce1510be3e8814897accc0bf62ef8Thanks @matthewp! - Invalidate CC cache manifest when lockfile or config changes -
#10811
77822a822b04b5113726f713df104e8667333c59Thanks @AvinashReddy3108! - Update list of available integrations in theastro addCLI help.
Patch Changes
-
#10732
a92e263beb6e0166f1f13c97803d1861793e2a99Thanks @rishi-raj-jain! - Correctly setsbuild.assetsdirectory duringviteconfig setup -
#10776
1607face67051b16d4648555f1001b2a9308e377Thanks @fshafiee! - Fixes cookies type inference -
#10796
90669472df3a05b33f0de46fd2d039e3eba7f7ddThanks @bluwy! - Disables streaming when rendering site withoutput: "static" -
#10782
b0589d05538fcc77dd3c38198bf93f3548362cd8Thanks @nektro! - Handles possible null value when callingwhich-pmduring dynamic package installation -
#10774
308b5d8c122f44e7724bb2f3ad3aa5c43a83e584Thanks @Princesseuh! - Fixesastro addsometimes modifyingbaseUrlunintentionally -
#10783
4dbd545304d1a8af903c8c97f237eb55c988c40bThanks @jurajkapsz! - Fixes Picture component specialFormatsFallback fallback check -
#10775
06843121450899ecf0390ca4efaff6c9a6fe0f75Thanks @Princesseuh! - Fixes assets endpoint in serverless returning 404 in certain situations where the website might be under a protected route -
#10787
699f4559a279b374bddb3e5e48c72afe2709e8e7Thanks @martrapp! - Fixes a timing issue in the view transition simulation.
Patch Changes
-
#10708
742866c5669a2be4f8b5a4c861cadb933c381415Thanks @horo-fox! - Limits parallel imports withingetCollection()to prevent EMFILE errors when accessing files -
#10755
c6d59b6fb7db20af957a8706c8159c50619235efThanks @ematipico! - Fixes a case where the i18n fallback failed to correctly redirect to the index page with SSR enabled
Minor Changes
-
#10591
39988ef8e2c4c4888543c973e06d9b9939e4ac95Thanks @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
683d51a5eecafbbfbfed3910a3f1fbf0b3531b99Thanks @ematipico! - Deprecate support for versions of Node.js older thanv18.17.1for Node.js 18, older thanv20.0.3for Node.js 20, and the complete Node.js v19 release line.This change is in line with Astro's Node.js support policy.
-
#10678
2e53b5fff6d292b7acdf8c30a6ecf5e5696846a1Thanks @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
440681e7b74511a17b152af0fd6e0e4dc4014025Thanks @ematipico! - Adds a new i18n routing optionmanualto allow you to write your own i18n middleware:import { defineConfig } from 'astro/config'; // astro.config.mjs 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, andredirectToFallback:// middleware.js 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
middlewarefunction that manually creates Astro's i18n middleware. This allows you to extend Astro's i18n routing instead of completely replacing it. Runmiddlewarein combination with your own middleware, using thesequenceutility 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
9e14a78cb05667af9821948c630786f74680090dThanks @fshafiee! - Adds thehttpOnly,sameSite, andsecureoptions when deleting a cookie
Patch Changes
-
#10747
994337c99f84304df1147a14504659439a9a7326Thanks @lilnasy! - Fixes an issue where functions could not be used as named slots. -
#10750
7e825604ddf90c989537e07939a39dc249343897Thanks @OliverSpeir! - Fixes a false positive for "Invalidtabindexon non-interactive element" rule for roleless elements (divandspan). -
#10745
d51951ce6278d4b59deed938d65e1cb72b5102dfThanks @lilnasy! - Fixes an issue where CLI commands could not report the reason for failure before exiting. -
#10661
e2cd7f4291912dadd4a654bc7917856c58a72a97Thanks @liruifengv! - Fixed errorOverlay theme toggle bug. -
Updated dependencies [
ccafa8d230f65c9302421a0ce0a0adc5824bfd55,683d51a5eecafbbfbfed3910a3f1fbf0b3531b99]:- @astrojs/markdown-remark@5.1.0
- @astrojs/telemetry@3.1.0
Patch Changes
-
#10728
f508c4b7d54316e737f454a3777204b23636d4a0Thanks @ematipico! - Fixes a regression where some very specific code rendered usingexpressive-codewas not escaped properly. -
#10737
8a30f257b1f3618b01212a591b82ad7a63c82fbbThanks @lilnasy! - Fixes a regression where constructing and returning 404 responses from a middleware resulted in the dev server getting stuck in a loop. -
#10719
b21b3ba307235510707ee9f5bd49f71473a07004Thanks @ematipico! - Fixes a false positive fordivandspanelements 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
roleattribute. This means that cases like the following are now deemed correct:<div role="tablist"></div> <span role="button" onclick="" onkeydown=""></span>
Patch Changes
-
#10688
799f6f3f29a3ef4f76347870a209ffa89651adfaThanks @bluwy! - Marks rendererjsxImportSourceandjsxTransformOptionsoptions as deprecated as they are no longer used since Astro 3.0 -
#10657
93d353528fa1a85b67e3f1e9514ed2a1b42dfd94Thanks @natemoo-re! - Improves the color contrast for notification badges on dev toolbar apps -
#10693
1d26e9c7f7d8f47e33bc68d3b30bbffce25c7b63Thanks @apetta! - Adds thedisableremoteplaybackattribute to MediaHTMLAttributes interface -
#10695
a15975e41cb5eaf6ed8eb3ebaee676a17e433052Thanks @bluwy! - Skips prerender chunk if building with static output -
#10707
5e044a5eafaa206d2ef8b62c37d1bcd37f0a4078Thanks @horo-fox! - Logs an error when a page'sgetStaticPathsfails -
#10686
fa0f593890502faf5709ab881fe0e45519d2f7afThanks @bluwy! - Prevents inlining scripts if used by other chunks when using theexperimental.directRenderScriptoption
Patch Changes
-
#10679
ca6bb1f31ef041e6ccf8ef974856fa945ff5bb31Thanks @martrapp! - Generates missing popstate events for Firefox when navigating to hash targets on the same page. -
#10669
0464563e527f821e53d78028d9bbf3c4e1050f5bThanks @Princesseuh! - Fixes Astro waiting infinitely in CI when a required package was not installed
Patch Changes
-
#10666
55ddb2ba4889480f776a8d29b9dcd531b9f5ab3eThanks @lilnasy! - Fixes an issue where forwarded requests did not include hostname on node-based adapters. This also makes error pages more reliable. -
#10642
4f5dc14f315eba7ea6ec5cc8e5dacb0cb81288ddThanks @OliverSpeir! - Fixes typing issues when usingformatandqualityoptions with remote images -
#10616
317d18ef8c9cf4fd13647518e3fd352774a86481Thanks @NikolaRHristov! - This change disables thesharplibvipsimage cache as it errors when the file is too small and operations are happening too fast (runs into a race condition)
Patch Changes
-
#10470
320c309ca9fbe51c40e6ba846d04a0cb49aced5fThanks @liruifengv! - improvesclient:onlyerror message -
#10496
ce985631129e49f7ea90e6ea690ef9f9cf0e6987Thanks @florian-lefebvre! - Makes the warning less scary when adding 3rd-party integrations usingastro add
Patch Changes
-
#10495
046d69d517118ab5c0e71604b321729d66ddffffThanks @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
a16a829f4e25ad5c9a1b4557ec089fc8ab53320fThanks @martrapp! - Fixes an issue with outdated page titles in browser history when using text fragments in view transition navigation. -
#10584
e648c5575a8774af739231cfa9fc27a32086aa5fThanks @duanwilliam! - Fixes a bug where JSX runtime would error on components with nullish prop values in certain conditions. -
#10608
e31bea0704890ff92ce4f9b0ce536c1c90715f2cThanks @matthewp! - Fixes bug with head content being pushed into body -
Updated dependencies [
2cf116f80cb5e421ab5cc5eb4a654e7b78c1b8de,374efcdff9625ca43309d89e3b9cfc9174351512]:- @astrojs/markdown-remark@5.0.0
Patch Changes
-
#10596
20463a6c1e1271d8dc3cb0ab3419ee5c72abd218Thanks @Princesseuh! - AddremoveBasefunction -
Updated dependencies [
20463a6c1e1271d8dc3cb0ab3419ee5c72abd218]:- @astrojs/internal-helpers@0.4.0
Patch Changes
-
#10567
fbdc10f90f7baa5c49f2f53e3e4ce8f453814c01Thanks @Princesseuh! - Fixesastro:assetsnot working when using complex config withvite.build.rollupOptions.output.assetFileNames -
#10593
61e283e5a0d95b6ef5d3c4c985d6ee78f74bbd8eThanks @Princesseuh! - Fixes Polymorphic type helper causing TypeScript errors in certain cases after the previous update -
#10543
0fd36bdb383297b32cc523b57d2442132da41595Thanks @matthewp! - Fixes inline stylesheets with content collections cache -
#10582
a05953538fcf524786385830b99c0c5a015173e8Thanks @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.
Patch Changes
-
#10549
54c2f9707f5d038630143f769e3075c698474654Thanks @admirsaheta! - Updates theHTMLAttributestype exported fromastroto allow data attributes -
#10562
348c1ca1323d0516c2dcf8e963343cd12cb5407fThanks @apetta! - Fixes minor type issues inside the built-in components of Astro -
#10550
34fa8e131b85531e6629390307108ffc4adb7ed1Thanks @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]:- @astrojs/markdown-remark@4.3.2
Patch Changes
-
#10532
8306ce1ff7b71a2a0d7908336c9be462a54d395aThanks @martrapp! - Fixes a style issue ofclient:onlycomponents in DEV mode during view transitions. -
#10473
627e47d67af4846cea2acf26a96b4124001b26fcThanks @bluwy! - Fixes and improves performance when rendering Astro JSX
Patch Changes
-
#10504
8e4e554cc211e59c329c0a5d110c839c886ff120Thanks @Princesseuh! - Update Babel version to fix regression in Babel's7.24.2. -
Updated dependencies [
19e42c368184013fc30d1e46753b9e9383bb2bdf]:- @astrojs/markdown-remark@4.3.1
Patch Changes
- #10493
e4a6462751725878bfe47632eeafa6854cad5bf2Thanks @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.
Patch Changes
-
#10455
c12666166db724915e42e37a048483c99f88e6d9Thanks @lilnasy! - Adds a helpful error message that will be shown when an endpoint does not return aResponse. -
#10426
6a9a35ee15069541c3144012385366a3c689240aThanks @markgaze! - Fixes an issue with generating JSON schemas when the schema is a function -
#10448
fcece3658697248ab58f77b3d4a8b14d362f3c47Thanks @lilnasy! - Fixes an issue where multiple rendering errors resulted in a crash of the SSR app server.
Patch Changes
-
#10379
3776ecf0aa9e08a992d3ae76e90682fd04093721Thanks @1574242600! - Fixes a routing issue with partially truncated dynamic segments. -
#10442
f8e0ad3c52a37b8a2175fe2f5ff2bd0cd738f499Thanks @Princesseuh! - Fixes small rendering issues with the dev toolbar in certain contexts -
#10438
5b48cc0fc8383b0659a595afd3a6ee28b28779c3Thanks @bholmesdev! - Generate Astro DB types when runningastro sync. -
#10456
1900a8f9bc337f3a882178d1770e10ab67fab0ceThanks @martrapp! - Fixes an error when usingastro:transtions/clientwithout<ViewTransitions/>
Patch Changes
- #10427
128c7a36397d99608dea918885b68bd302d00e7fThanks @lilnasy! - Fixes an issue where error pages did not have access to theAstro.localsfields provided by the adapter.
Patch Changes
-
#10410
055fe293c6702dd27bcd6c4f59297c6d4385abb1Thanks @lilnasy! - Fixes an issue where configured redirects could not include certain characters in the target path. -
#9820
8edc42aa7c209b12d98ecf20cdecccddf7314af0Thanks @alexnguyennz! - Prevents fully formed URLs in attributes from being escaped
Patch Changes
- #10400
629c9d7c4d96ae5711d95601e738b3d31d268116Thanks @mingjunlu! - Fixes an issue where dev toolbar x-ray didn't escape props content.
Patch Changes
-
#10392
02aeb01cb8b62b9cc4dfe6069857219404343b73Thanks @martrapp! - Fixes broken types for some functions ofastro:transitions/client. -
#10390
236cdbb611587692d3c781850cb949604677ef82Thanks @bholmesdev! - Adds--helpreference for new db and studio CLI commands
Minor Changes
-
#10206
dc87214141e7f8406c0fdf6a7f425dad6dea6d3eThanks @lilnasy! - Allows middleware to run when a matching page or endpoint is not found. Previously, apages/404.astroorpages/[...catch-all].astroroute 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.astroor fallback route with spread params, or use a routing configuration option if your adapter provides one. -
#9960
c081adf998d30419fed97d8fccc11340cdc512e0Thanks @StandardGage! - Allows passing any props to the<Code />component -
#10102
e3f02f5fb1cf0dae3c54beb3a4af3dbf3b06abb7Thanks @bluwy! - Adds a newexperimental.directRenderScriptconfiguration option which provides a more reliable strategy to prevent scripts from being executed in pages where they are not used.This replaces the
experimental.optimizeHoistedScriptflag 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 enabledirectRenderScript:// astro.config.mjs import { defineConfig } from 'astro/config'; export default defineConfig({ experimental: { - optimizeHoistedScript: true, + directRenderScript: true } });With
experimental.directRenderScriptconfigured, scripts are now directly rendered as declared in Astro files (including existing features like TypeScript, importingnode_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
5a9528741fa98d017b269c7e4f013058028bdc5dThanks @bluwy! - Stabilizesmarkdown.shikiConfig.experimentalThemesasmarkdown.shikiConfig.themes. No behaviour changes are made to this option. -
#10189
1ea0a25b94125e4f6f2ac82b42f638e22d7bdffdThanks @peng! - Adds the option to pass an object tobuild.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 afallbackdomain 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:
// astro.config.mjs 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
3307cb34f17159dfd3f03144697040fcaa10e903Thanks @Princesseuh! - Adds support for emitting warning and info notifications from dev toolbar apps.When using the
toggle-notificationevent, the severity can be specified throughdetail.level:eventTarget.dispatchEvent( new CustomEvent('toggle-notification', { detail: { level: 'warning', }, }) ); -
#10186
959ca5f9f86ef2c0a5a23080cc01c25f53d613a9Thanks @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
9cd84bd19b92fb43ae48809f575ee12ebd43ea8fThanks @matthewp! - Changes the default behavior oftransition:persistto update the props of persisted islands upon navigation. Also adds a new view transitions optiontransition:persist-props(default:false) to prevent props from updating as needed.Islands which have the
transition:persistproperty 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
productsprops 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
productsmight 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=trueto persist both props and state during navigation:<ProductListing transition:persist-props="true" products={products} /> -
#9977
0204b7de37bf626e1b97175b605adbf91d885386Thanks @OliverSpeir! - Supports adding thedata-astro-rerunattribute on script tags so that they will be re-executed after view transitions<script is:inline data-astro-rerun> ... </script> -
#10145
65692fa7b5f4440c644c8cf3dd9bc50103d2c33bThanks @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$schemavalue 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:
// src/content/test/entry.json { + "$schema": "../../../.astro/collections/test.schema.json", "test": "test" }Alternatively, you can set this in your VSCode
json.schemassettings:"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
5a9528741fa98d017b269c7e4f013058028bdc5dThanks @bluwy! - Migratesshikijitoshiki1.0 -
#10268
2013e70bce16366781cc12e52823bb257fe460c0Thanks @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
5c7862a9fe69954f8630538ebb7212cd04b8a810Thanks @Princesseuh! - Updates the UI for dev toolbar audits with new information
Patch Changes
-
#10360
ac766647b0e6156b7c4a0bb9a11981fe168852d7Thanks @nmattia! - Fixes an issue where some CLI commands attempted to directly read vite config files. -
#10291
8107a2721b6abb07c3120ac90e03c39f2a44ab0cThanks @bluwy! - Treeshakes unused Astro component scoped styles -
#10368
78bafc5d661ff7dd071c241cb1303c4d8a774d21Thanks @Princesseuh! - Updates the basetsconfig.jsonpreset withjsx: 'preserve'in order to fix errors when importing Astro files inside.jsand.tsfiles. -
Updated dependencies [
c081adf998d30419fed97d8fccc11340cdc512e0,1ea0a25b94125e4f6f2ac82b42f638e22d7bdffd,5a9528741fa98d017b269c7e4f013058028bdc5d,a31bbd7ff8f3ec62ee507f72d1d25140b82ffc18]:- @astrojs/markdown-remark@4.3.0
- @astrojs/internal-helpers@0.3.0
Patch Changes
- #10317
33583e8b31ee8a33e26cf57f30bb422921f4745dThanks @lilnasy! - Fixes an issue where elements slotted within interactive framework components disappeared after hydration.
Patch Changes
-
#10355
8ce9fffd44b0740621178d61fb1425bf4155c2d7Thanks @ematipico! - Fixes a regression where full dynamic routes were prioritized over partial dynamic routes. Now a route likefood-[name].astrois matched before[name].astro. -
#10356
d121311a3f4b5345e344e31f75d4e7164d65f729Thanks @mingjunlu! - Fixes an issue wheregetCollectionmight returnundefinedwhen content collection is empty -
#10325
f33cce8f6c3a2e17847658cdedb015bd93cc1ee3Thanks @lilnasy! - Fixes an issue wherectx.siteincluded the configuredbasein API routes and middleware, unlikeAstro.sitein astro pages. -
#10343
f973aa9110592fa9017bbe84387f22c24a6d7159Thanks @ematipico! - Fixes some false positive in the dev toolbar a11y audits, by adding theaelement to the list of interactive elements. -
#10295
fdd5bf277e5c1cfa30c1bd2ca123f4e90e8d09d9Thanks @rossrobino! - Adds a prefetch fallback when using theexperimental.clientPrerenderoption. If prerendering fails, which can happen if Chrome extensions block prerendering, it will fallback to prefetching the URL. This works by adding aprefetchfield to thespeculationrulesscript, but does not create an extra request.
Patch Changes
- #10342
a2e9b2b936666b2a4779feb00dcb8ff0ab82c2ecThanks @matthewp! - Fixes @astrojs/db loading TS in the fixtures
Patch Changes
- #10336
f2e60a96754ed1d86001fe4d5d3a0c0ef657408dThanks @FredKSchott! - Fixes an issue where slotting interactive components within a "client:only" component prevented all component code in the page from running.
Patch Changes
-
#10281
9deb919ff95b1d2ffe5a5f70ec683e32ebfafd05Thanks @lilnasy! - Fixes an issue where404.astrowas ignored withi18nrouting enabled. -
#10279
9ba3e2605daee3861e3bf6c5768f1d8bced4709dThanks @lilnasy! - Fixes an issue where returning redirect responses resulted in missing files with certain adapters. -
#10319
19ecccedaab6d8fa0ff23711c88fa7d4fa34df38Thanks @lilnasy! - Fixes an issue where streaming SSR responses sometimes failed with "iterator.resultis not a function" on node-based adapters. -
#10302
992537e79f1847b590a2e226aac88a47a6304f68Thanks @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,.mdxetc) and such extension would be also within the path (like./.astro/index.astro). -
#10298
819d20a89c0d269333c2d397c1080884f516307aThanks @Fryuni! - Fix an incorrect conflict resolution between pages generated from static routes and rest parameters
Patch Changes
- #10235
4bc360cd5f25496aca3232f6efb3710424a14a34Thanks @sanman1k98! - Fixes jerky scrolling on IOS when using view transitions.
Patch Changes
-
#10278
a548a3a99c2835c19662fc38636f92b2bda26614Thanks @Princesseuh! - Fixes original images sometimes being kept / deleted when they shouldn't in both MDX and Markdoc -
#10280
3488be9b59d1cb65325b0e087c33bcd74aaa4926Thanks @bholmesdev! - Finalize db API to a shared db/ directory.
Patch Changes
- #10275
5e3e74b61daa2ba44c761c9ab5745818661a656eThanks @Princesseuh! - Fixes dev toolbar warning about using the proper loading attributes on images usingdata:URIs
Patch Changes
-
#10274
e556151603a2f0173059d0f98fdcbec0610b48ffThanks @lilnasy! - Fixes a regression introduced in v4.4.5 where image optimization did not work in dev mode when a base was configured. -
#10263
9bdbed723e0aa4243d7d6ee64d1c1df3b75b9aebThanks @martrapp! - Adds auto completion forastro:event names when adding or removing event listeners ondocument. -
#10284
07f89429a1ef5173d3321e0b362a9dc71fc74fe5Thanks @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.
Patch Changes
-
#10247
fb773c9161bf8faa5ebd7e115f3564c3359e56eaThanks @martrapp! - Fixes an issue wheretransition:animate="none"still allowed the browser-native morph animation. -
#10248
8ae5d99534fc09d650e10e64a09b61a2807574f2Thanks @ematipico! - Fixes an issue where multiple injected routes with the sameentrypointbut differentpatternwere incorrectly cached, causing some of them not being rendered in the dev server. -
#10250
57655a99db34e20e9661c039fab253b867013318Thanks @log101! - Fixes the overwriting of localised index pages with redirects -
#10239
9c21a9df6b03e36bd78dc553e13c55b9ef8c44cdThanks @mingjunlu! - Improves the message ofMiddlewareCantBeLoadedfor clarity -
#10222
ade9759cae74ca262b988260250bcb202235e811Thanks @martrapp! - Adds a warning in DEV mode when using view transitions on a device with prefer-reduced-motion enabled. -
#10251
9b00de0a76b4f4b5b808e8c78e4906a2497e8ecfThanks @mingjunlu! - Fixes TypeScript type definitions forCodecomponentthemeandexperimentalThemesprops
Patch Changes
-
#10221
4db82d9c7dce3b73fe43b86020fcfa326c1357ecThanks @matthewp! - Prevents errors in templates from crashing the server -
#10219
afcb9d331179287629b5ffce4020931258bebefaThanks @matthewp! - Fix dynamic slots missing hydration scripts -
#10220
1eadb1c5290f2f4baf538c34889a09d5fcfb9bd4Thanks @Princesseuh! - Fixes some built-in apps of the dev toolbar not closing when clicking the page -
#10154
e64bd0740b44aed5cfaf67e5c37a1c56ed4442f4Thanks @Cherry! - Fixes an issue whereconfig.vite.build.assetsInlineLimitcould not be set as a function. -
#10196
8fb32f390d40cfa12a82c0645928468d27218866Thanks @lilnasy! - Fixes an issue where a warning about headers being accessed in static mode is unnecessarily shown when i18n is enabled. -
#10199
6aa660ae7abc6841d7a3396b29f10b9fb7910ce5Thanks @lilnasy! - Fixes an issue where prerendered pages had access to query params in dev mode.
Patch Changes
-
#10195
903eace233033998811b72e27a54c80d8e59ff37Thanks @1574242600! - Fix build failure caused by read-only files under /public (in the presence of client-side JS). -
#10205
459f74bc71748279fe7dce0688f38bd74b51c5c1Thanks @martrapp! - Adds an error message for non-string transition:name values -
#10208
8cd38f02456640c063552aef00b2b8a216b3935dThanks @log101! - Fixes custom headers are not added to the Node standalone server responses in preview mode
Patch Changes
-
#10143
7c5fcd2fa817472f480bbfbbc11b9ed71a7210abThanks @bluwy! - Improves the defaultoptimizeDeps.entriesVite config to avoid globbing server endpoints, and respect thesrcDiroption -
#10197
c856c729404196900a7386c8426b81e79684a6a9Thanks @Princesseuh! - Fixes errors being logged twice in some cases -
#10166
598f30c7cd6c88558e3806d9bc5a15d426d83992Thanks @bluwy! - Improves Astro style tag HMR when updating imported styles -
#10194
3cc20109277813ccb9578ca87a8b0d680a73c35cThanks @matthewp! - Fixes an issue related to content collections usage in browser context caused bycsssec
Patch Changes
- #10169
a46249173edde66b03c19441144272baa8394fb4Thanks @ematipico! - Fixes an issue with thei18n.routingtypes, where an internal transformation was causing the generation of incorrect types for integrations.
Patch Changes
-
#9795
5acc3135ba5309a566def466fbcbabd23f70cd68Thanks @lilnasy! - Refactors internals relating to middleware, endpoints, and page rendering. -
#10105
1f598b372410066c6fcd41cba9915f6aaf7befa8Thanks @negativems! - Fixes an issue where some astro commands failed if the astro config file or an integration used the globalcryptoobject. -
#10165
d50dddb71d87ce5b7928920f10eb4946a5339f86Thanks @ematipico! - Fixes an issue where thei18n.routingobject had all its fields defined as mandatory. Now they all are optionals and shouldn't break when usingastro.config.mts. -
#10132
1da9c5f2f3fe70b0206d1b3e0c01744fa40d511cThanks @bluwy! - Simplifies internal Vite preview server teardown -
#10163
b92d35f1026f3e99abb888d1a845bdda4efdc327Thanks @mingjunlu! - Fixes an issue where audit fails to initialize when encountered<a>inside<svg> -
#10079
80f8996514e6d0546e94bd927650cd4ab2f1fa2fThanks @ktym4a! - Fix integrationData fetch to always be called even if View Transition is enabled. -
#10139
3c73441eb2eaba767d6dad1b30c0353195d28791Thanks @bluwy! - Fixes style-only change detection for Astro files if both the markup and styles are updated
Minor Changes
-
#9614
d469bebd7b45b060dc41d82ab1cf18ee6de7e051Thanks @matthewp! - Improves Node.js streaming performance.This uses an
AsyncIterableinstead of aReadableStreamto do streaming in Node.js. This is a non-standard enhancement by Node, which is done only in that environment. -
#10001
748b2e87cd44d8bcc1ab9d7e504703057e2000cdThanks @bholmesdev! - Removes content collection warning when a configured collection does not have a matching directory name. This should resolvei18ncollection warnings for Starlight users.This also ensures configured collection names are always included in
getCollection()andgetEntry()types even when a matching directory is absent. We hope this allows users to discover typos during development by surfacing type information. -
#10074
7443929381b47db0639c49a4d32aec4177bd9102Thanks @Princesseuh! - Add a UI showing the list of found problems when using the audit app in the dev toolbar -
#10099
b340f8fe3aaa81e38c4f1aa41498b159dc733d86Thanks @martrapp! - Fixes a regression where view transition names containing special characters such as spaces or punctuation stopped working.Regular use naming your transitions with
transition: nameis unaffected.However, this fix may result in breaking changes if your project relies on the particular character encoding strategy Astro uses to translate
transition:namedirectives into values of the underlying CSSview-transition-nameproperty. For example,Welcome to Astrois now encoded asWelcome_20to_20Astro_2e.This mainly affects spaces and punctuation marks but no Unicode characters with codes >= 128.
-
#9976
91f75afbc642b6e73dd4ec18a1fe2c3128c68132Thanks @OliverSpeir! - Adds a new optionalastro:assetsimage attributeinferSizefor use with remote images.Remote images can now have their dimensions inferred just like local images. Setting
inferSizetotrueallows you to usegetImage()and the<Image />and<Picture />components without setting thewidthandheightproperties.--- import { Image, Picture, getImage } from 'astro:assets'; const myPic = await getImage({ src: 'https://example.com/example.png', inferSize: true }); --- <Image src="https://example.com/example.png" inferSize alt="" /> <Picture src="https://example.com/example.png" inferSize alt="" />Read more about using
inferSizewith remote images in our documentation. -
#10015
6884b103c8314a43e926c6acdf947cbf812a21f4Thanks @Princesseuh! - Adds initial support for performance audits to the dev toolbar
Patch Changes
-
#10116
4bcc249a9f34aaac59658ca626c828bd6dbb8046Thanks @lilnasy! - Fixes an issue where the dev server froze when typescript aliases were used. -
#10096
227cd83a51bbd451dc223fd16f4cf1b87b8e44f8Thanks @Fryuni! - Fixes regression on routing priority for multi-layer index pagesThe sorting algorithm positions more specific routes before less specific routes, and considers index pages to be more specific than a dynamic route with a rest parameter inside of it. This means that
/blogis considered more specific than/blog/[...slug].But this special case was being applied incorrectly to indexes, which could cause a problem in scenarios like the following:
//blog/blog/[...slug]
The algorithm would make the following comparisons:
/is more specific than/blog(incorrect)/blog/[...slug]is more specific than/(correct)/blogis more specific than/blog/[...slug](correct)
Although the incorrect first comparison is not a problem by itself, it could cause the algorithm to make the wrong decision. Depending on the other routes in the project, the sorting could perform just the last two comparisons and by transitivity infer the inverse of the third (
/blog/[...slug>/>/blog), which is incorrect.Now the algorithm doesn't have a special case for index pages and instead does the comparison soleley for rest parameter segments and their immediate parents, which is consistent with the transitivity property.
-
#10120
787e6f52470cf07fb50c865948b2bc8fe45a6d31Thanks @bluwy! - Updates and supports Vite 5.1 -
#10096
227cd83a51bbd451dc223fd16f4cf1b87b8e44f8Thanks @Fryuni! - Fixes edge case on i18n fallback routesPreviously index routes deeply nested in the default locale, like
/some/nested/index.astrocould be mistaked as the root index for the default locale, resulting in an incorrect redirect on/. -
#10112
476b79a61165d0aac5e98459a4ec90762050a14bThanks @Princesseuh! - Renames the home Astro Devoolbar App toastro:home -
#10117
51b6ff7403c1223b1c399e88373075972c82c24cThanks @hippotastic! - Fixes an issue wherecreate astro,astro addand@astrojs/upgradewould fail due to unexpected package manager CLI output.
Patch Changes
-
#9857
73bd900754365b006ee730df9f379ba924e5b3faThanks @iamyunsin! - Fixes false positives in the dev overlay audit when multiplerolevalues exist. -
#10075
71273edbb429b5afdba6f8ee14681b66e4c09eccThanks @lilnasy! - Improves error messages for island hydration. -
#10072
8106178043050d142bf385bed2990730518f28e2Thanks @lilnasy! - Clarifies error messages in endpoint routing. -
#9971
d9266c4467ca0faa1213c1a5995164e5655ab375Thanks @mingjunlu! - Fixes an issue where ReadableStream wasn't canceled in dev mode
Patch Changes
-
#10063
dac759798c111494e76affd2c2504d63944871feThanks @marwan-mohamed12! - Movesshikiji-corefromdevDependenciestodependenciesto prevent type errors -
#10067
989ea63bb2a5a670021541198aa70b8dc7c4bd2fThanks @ematipico! - Fixes a regression in theastro:i18nmodule, where the functionsgetAbsoluteLocaleUrlandgetAbsoluteLocaleUrlListreturned a URL with double slash with a certain combination of options. -
#10060
1810309e65c596266355c3b7bb36cdac70f3305eThanks @lilnasy! - Fixes an issue where custom client directives added by integrations broke builds with a custom root. -
#9991
8fb67c81bb84530b39df4a1449c0862def0854afThanks @ktym4a! - Increases compatibility with standard browser behavior by changing where view transitions occur on browser back navigation.
Patch Changes
-
#10022
3fc76efb2a8faa47edf67562a1f0c84a19be1b33Thanks @lilnasy! - Fixes a regression where types for theastro:contentmodule did not include required exports, leading to typescript errors. -
#10016
037e4f12dd2f460d66f72c9f2d992b95e74d2da9Thanks @ematipico! - Fixes a bug where routes with a name that start with the name of thei18n.defaultLocalewere incorrectly returning a 404 response.
Patch Changes
-
#10013
e6b5306a7de779ce495d0ff076d302de0aa57eafThanks @delucis! - Fixes a regression in content collection types -
#10003
ce4283331f18c6178654dd705e3cf02efeef004aThanks @bholmesdev! - Adds support for.strict()on content collection schemas when a customslugis present.
Patch Changes
-
#9998
18ac0940ea1b49b6b0ddd9be1f96aef416e2d7eeThanks @ematipico! - Fixes a bug inAstro.currentLocalethat wasn't returning the correct locale when a locale is configured viapath -
#9998
18ac0940ea1b49b6b0ddd9be1f96aef416e2d7eeThanks @ematipico! - Fixes a regression inAstro.currentLocalewhere it stopped working properly with dynamic routes -
#9956
81acac24a3cac5a9143155c1d9f838ea84a70421Thanks @matthewp! - Fixes HMR for MDX dependencies in Content Collections -
#9999
c53a31321a935e4be04809046d7e0ba3cc41b272Thanks @MoustaphaDev! - Rollbacks the feature which allowed to dynamically generate slots with variable slot names due to unexpected regressions. -
#9906
3c0876cbed5033e6b5b42cc2b9d8b393d7e5a55eThanks @florian-lefebvre! - Improves the types for theastro:contentmodule by making low fidelity types available before runningastro sync
Patch Changes
-
#9932
9f0d89fa7e9e7c08c8600b0c49c2cce7489a7582Thanks @ematipico! - Fixes a case where a warning was logged even when the featurei18nDomainswasn't enabled -
#9907
6c894af5ab79f290f4ff7feb68617a66e91febc1Thanks @ktym4a! - Load 404.html on all non-existent paths on astro preview.
Patch Changes
-
#9841
27ea080e24e2c5cdc59b63b1dfe0a83a0c696597Thanks @kristianbinau! - Makes the warning clearer when having a custombaseand requesting a public URL without it -
#9888
9d2fdb293d6a7323e10126cebad18ef9a2ea2800Thanks @natemoo-re! - Improves error handling logic for theastro synccommand. -
#9918
d52529e09450c84933dd15d6481edb32269f537bThanks @LarryIVC! - Adds thenameattribute to the<details>tag type -
#9938
1568afb78a163db63a4cde146dec87785a83db1dThanks @lilnasy! - Fixes a regression where middleware did not run for prerendered pages and endpoints. -
#9931
44674418965d658733d3602668a9354e18f8ef89Thanks @lilnasy! - Fixes a regression where a response created withResponse.redirector containingnullas the body never completed in node-based adapters.
Minor Changes
-
#9839
58f9e393a188702eef5329e41deff3dcb65a3230Thanks @Princesseuh! - Adds a newComponentPropstype export fromastro/typesto get the props type of an Astro component.--- import type { ComponentProps } from 'astro/types'; import { Button } from './Button.astro'; type myButtonProps = ComponentProps<typeof Button>; --- -
#9159
7d937c158959e76443a02f740b10e251d14dbd8cThanks @bluwy! - Adds CLI shortcuts as an easter egg for the dev server:o + enter: opens the site in your browserq + enter: quits the dev serverh + enter: prints all available shortcuts
-
#9764
fad4f64aa149086feda2d1f3a0b655767034f1a8Thanks @matthewp! - Adds a newbuild.formatconfiguration option:'preserve'. This option will preserve your source structure in the final build.The existing configuration options,
fileanddirectory, either build all of your HTML pages as files matching the route name (e.g./about.html) or build all your files asindex.htmlwithin a nested directory structure (e.g./about/index.html), respectively. It was not previously possible to control the HTML file built on a per-file basis.One limitation of
build.format: 'file'is that it cannot createindex.htmlfiles for any individual routes (other than the base path of/) while otherwise building named files. Creating explicit index pages within your file structure still generates a file named for the page route (e.g.src/pages/about/index.astrobuilds/about.html) when using thefileconfiguration option.Rather than make a breaking change to allow
build.format: 'file'to be more flexible, we decided to create a newbuild.format: 'preserve'.The new format will preserve how the filesystem is structured and make sure that is mirrored over to production. Using this option:
about.astrobecomesabout.htmlabout/index.astrobecomesabout/index.html
See the
build.formatconfiguration options reference for more details. -
#9143
041fdd5c89920f7ccf944b095f29e451f78b0e28Thanks @ematipico! - Adds experimental support for a new i18n domain routing option ("domains") that allows you to configure different domains for individual locales in entirely server-rendered projects.To enable this in your project, first configure your
server-rendered project's i18n routing with your preferences if you have not already done so. Then, set theexperimental.i18nDomainsflag totrueand addi18n.domainsto map any of your supportedlocalesto custom URLs://astro.config.mjs" import { defineConfig } from 'astro/config'; export default defineConfig({ site: 'https://example.com', output: 'server', // required, with no prerendered pages adapter: node({ mode: 'standalone', }), i18n: { defaultLocale: 'en', locales: ['es', 'en', 'fr', 'ja'], routing: { prefixDefaultLocale: false, }, domains: { fr: 'https://fr.example.com', es: 'https://example.es', }, }, experimental: { i18nDomains: true, }, });With
"domains"configured, the URLs emitted bygetAbsoluteLocaleUrl()andgetAbsoluteLocaleUrlList()will use the options set ini18n.domains.import { getAbsoluteLocaleUrl } from 'astro:i18n'; getAbsoluteLocaleUrl('en', 'about'); // will return "https://example.com/about" getAbsoluteLocaleUrl('fr', 'about'); // will return "https://fr.example.com/about" getAbsoluteLocaleUrl('es', 'about'); // will return "https://example.es/about" getAbsoluteLocaleUrl('ja', 'about'); // will return "https://example.com/ja/about"Similarly, your localized files will create routes at corresponding URLs:
- The file
/en/about.astrowill be reachable at the URLhttps://example.com/about. - The file
/fr/about.astrowill be reachable at the URLhttps://fr.example.com/about. - The file
/es/about.astrowill be reachable at the URLhttps://example.es/about. - The file
/ja/about.astrowill be reachable at the URLhttps://example.com/ja/about.
See our Internationalization Guide for more details and limitations on this experimental routing feature.
- The file
-
#9755
d4b886141bb342ac71b1c060e67d66ca2ffbb8bdThanks @OliverSpeir! - Fixes an issue where images in Markdown required a relative specifier (e.g../)Now, you can use the standard
syntax in Markdown 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 Markdown images as they are no longer necessary:
-  +  <!-- This dog lives in the same folder as my article! -->
Patch Changes
-
#9908
2f6d1faa6f2d6de2d4ccd2a48adf5adadc82e593Thanks @lilnasy! - Improves http behavior relating to errors encountered while streaming a response. -
#9877
7be5f94dcfc73a78d0fb301eeff51614d987a165Thanks @fabiankachlock! - Fixes the content config type path on windows -
#9143
041fdd5c89920f7ccf944b095f29e451f78b0e28Thanks @ematipico! - Fixes an issue where the functiongetLocaleRelativeUrlListwasn't normalising the paths by default -
#9911
aaedb848b1d6f683840035865528506a346ea659Thanks @natemoo-re! - Fixes an issue where some adapters that do not include astart()export would error rather than silently proceed
Patch Changes
-
#9884
37369550ab57ca529fd6c796e5b0e96e897ca6e5Thanks @lilnasy! - Fixes an issue where multiple cookies were sent in a single Set-Cookie header in the dev mode. -
#9876
e9027f194b939ac5a4d795ee1a2c24e4a6fbefc0Thanks @friedemannsommer! - Fixes an issue where usingResponse.redirectin an endpoint led to an error. -
#9882
13c3b712c7ba45d0081f459fc06f142216a4ec59Thanks @natemoo-re! - Improves handling of YAML parsing errors -
#9878
a40a0ff5883c7915dd55881dcebd052b9f94a0ebThanks @lilnasy! - Fixes an issue where setting trailingSlash to "never" had no effect onAstro.url.
Patch Changes
-
#9840
70fdf1a5c660057152c1ca111dcc89ceda5c8840Thanks @delucis! - ExposeContentConfigtype fromastro:content -
#9865
00ba9f1947ca9016cd0ee4d8f6048027fab2ab9aThanks @ematipico! - Fixes a bug inAstro.currentLocalewhere the value was incorrectly computed during the build. -
#9838
0a06d87a1e2b94be00a954f350c184222fa0594dThanks @lilnasy! - Fixes an issue whereastro:i18ncould not be used in framework components. -
Updated dependencies [
44c957f893c6bf5f5b7c78301de7b21c5975584d]:- @astrojs/markdown-remark@4.2.1
Patch Changes
-
#9825
e4370e9e9dd862425eced25823c82e77d9516927Thanks @tugrulates! - Fixes false positive aria role errors on interactive elements -
#9828
a3df9d83ca92abb5f08f576631019c1604204bd9Thanks @ematipico! - Fixes a case where shared modules among pages and middleware were transformed to a no-op after the build. -
#9834
1885cea308a62b173a50967cf5a0b174b3c3f3f1Thanks @Princesseuh! - Fixes third-party dev toolbar apps not loading correctly when using absolute paths on Windows
Patch Changes
-
#9818
d688954c5adba75b0d676694fbf5fb0da1c0af13Thanks @Princesseuh! - Improves the wording of a few confusing error messages -
#9680
5d7db1dbb0ff06db98e08b0ca241ff09d0b8b44dThanks @loucyx! - Fixes types generation from Content Collections config file -
#9822
bd880e8437ea2df16f322f604865c1148a9fd4cfThanks @liruifengv! - Applies the correct escaping to identifiers used withtransition:name. -
#9830
f3d22136e53fd902310024519fc4de83f0a58039Thanks @lilnasy! - Fixes an issue where 404 responses from endpoints were replaced with contents of 404.astro in dev mode. -
#9816
2a44c8f93201958fba2d1e83046eabcaef186b7cThanks @Princesseuh! - Adds telemetry for when apps are toggled in the dev toolbar. This data is completely anonymous and only the names of built-in apps are shared with us. This data will help us monitor how much the dev toolbar is used and which apps are used more. For more information on how Astro collects telemetry, visit the following page: https://astro.build/telemetry/ -
#9807
b3f313138bb314e2b416c29cda507383c2a9f816Thanks @bluwy! - Fixes environment variables replacement forexport const prerender -
#9790
267c5aa2c7706f0ea3447f20a09d85aa560866adThanks @lilnasy! - Refactors internals of theastro:i18nmodule to be more maintainable. -
#9776
dc75180aa698b298264362bab7f00391af427798Thanks @lilnasy! - Simplifies internals that handle middleware.
Patch Changes
-
#9792
e22cb8b10c0ca9f6d88cab53cd2713f57875ab4bThanks @tugrulates! - Accept aria roleswitchon toolbar audit. -
#9606
e6945bcf23b6ad29388bbadaf5bb3cc31dd4a114Thanks @eryue0220! - Fixes escaping behavior for.htmlfiles and components -
#9786
5b29550996a7f5459a0d611feea6e51d44e1d8edThanks @Fryuni! - Fixes a regression in routing priority for index pages in rest parameter folders and dynamic sibling trees.Considering the following tree:
src/pages/ ├── index.astro ├── static.astro ├── [dynamic_file].astro ├── [...rest_file].astro ├── blog/ │ └── index.astro ├── [dynamic_folder]/ │ ├── index.astro │ ├── static.astro │ └── [...rest].astro └── [...rest_folder]/ ├── index.astro └── static.astroThe routes are sorted in this order:
/src/pages/index.astro /src/pages/blog/index.astro /src/pages/static.astro /src/pages/[dynamic_folder]/index.astro /src/pages/[dynamic_file].astro /src/pages/[dynamic_folder]/static.astro /src/pages/[dynamic_folder]/[...rest].astro /src/pages/[...rest_folder]/static.astro /src/pages/[...rest_folder]/index.astro /src/pages/[...rest_file]/index.astroThis allows for index files to be used as overrides to rest parameter routes on SSR when the rest parameter matching
undefinedis not desired. -
#9775
075706f26d2e11e66ef8b52288d07e3c0fa97eb1Thanks @lilnasy! - Simplifies internals that handle endpoints. -
#9773
9aa7a5368c502ae488d3a173e732d81f3d000e98Thanks @LunaticMuch! - Raises the required vite version to address a vulnerability invite.server.fs.denythat affected the dev mode. -
#9781
ccc05d54014e24c492ca5fddd4862f318aac8172Thanks @stevenbenner! - Fix build failure when image file name includes special characters
Patch Changes
- #9768
eed0e8757c35dde549707e71c45862438a043fb0Thanks @Princesseuh! - Fix apps being able to crash the dev toolbar in certain cases
Patch Changes
-
#9712
ea6cbd06a2580527786707ec735079ff9abd0ec0Thanks @bluwy! - Improves HMR behavior for style-only changes in.astrofiles -
#9739
3ecb3ef64326a8f77aa170df1e3c89cb5c12cc93Thanks @ematipico! - Makes i18n redirects take thebuild.formatconfiguration into account -
#9762
1fba85681e86aa83d24336d4209cafbc76b37607Thanks @ematipico! - Addspopovertarget" to the attribute that can be passed to thebutton` element -
#9605
8ce40a417c854d9e6a4fa7d5a85d50a6436b4a3cThanks @MoustaphaDev! - Adds support for dynamic slot names -
#9381
9e01f9cc1efcfb938355829676d51b24818ab2bbThanks @martrapp! - Improves the CLI output ofastro preferences listto include additional relevant information -
#9741
73d74402007896204ee965f6553dc83b3dec8d2fThanks @taktran! - Fixes an issue where dot files were not copied over from the public folder to the output folder, when build command was run in a folder other than the root of the project. -
#9730
8d2e5db096f1e7b098511b4fe9357434a6ff0703Thanks @Blede2000! - Allow i18n routing utilities like getRelativeLocaleUrl to also get the default local path when redirectToDefaultLocale is false -
Updated dependencies [
53c69dcc82cdf4000aff13a6c11fffe19096cf45,2f81cffa9da9db0e2802d303f94feaee8d2f54ec,a505190933365268d48139a5f197a3cfb5570870]:- @astrojs/markdown-remark@4.2.0
Patch Changes
- #9726
a4b696def3a7eb18c1ae48b10fd3758a1874b6feThanks @Fryuni! - Fixes a regression in routing priority betweenindex.astroand dynamic routes with rest parameters
Minor Changes
-
#9566
165cfc154be477337037185c32b308616d1ed6faThanks @OliverSpeir! - Allows remark plugins to pass options specifying how images in.mdfiles will be optimized -
#9661
d6edc7540864cf5d294d7b881eb886a3804f6d05Thanks @ematipico! - Adds new helper functions for adapter developers.Astro.clientAddresscan now be passed directly to theapp.render()method.
const response = await app.render(request, { clientAddress: '012.123.23.3' });- Helper functions for converting Node.js HTTP request and response objects to web-compatible
RequestandResponseobjects are now provided as static methods on theNodeAppclass.
http.createServer((nodeReq, nodeRes) => { const request: Request = NodeApp.createRequest(nodeReq); const response = await app.render(request); await NodeApp.writeResponse(response, nodeRes); });- Cookies added via
Astro.cookies.set()can now be automatically added to theResponseobject by passing theaddCookieHeaderoption toapp.render().
-const response = await app.render(request) -const setCookieHeaders: Array<string> = Array.from(app.setCookieHeaders(webResponse)); -if (setCookieHeaders.length) { - for (const setCookieHeader of setCookieHeaders) { - headers.append('set-cookie', setCookieHeader); - } -} +const response = await app.render(request, { addCookieHeader: true }) -
#9638
f1a61268061b8834f39a9b38bca043ae41caed04Thanks @ematipico! - Adds a newi18n.routingconfig optionredirectToDefaultLocaleto disable automatic redirects of the root URL (/) to the default locale whenprefixDefaultLocale: trueis set.In projects where every route, including the default locale, is prefixed with
/[locale]/path, this property allows you to control whether or notsrc/pages/index.astroshould automatically redirect your site visitors from/to/[defaultLocale].You can now opt out of this automatic redirection by setting
redirectToDefaultLocale: false:// astro.config.mjs export default defineConfig({ i18n: { defaultLocale: 'en', locales: ['en', 'fr'], routing: { prefixDefaultLocale: true, redirectToDefaultLocale: false, }, }, }); -
#9671
8521ff77fbf7e867701cc30d18253856914dbd1bThanks @bholmesdev! - Removes the requirement for non-content files and assets inside content collections to be prefixed with an underscore. For files with extensions like.astroor.css, you can now remove underscores without seeing a warning in the terminal.src/content/blog/ post.mdx - _styles.css - _Component.astro + styles.css + Component.astroContinue to use underscores in your content collections to exclude individual content files, such as drafts, from the build output.
-
#9567
3a4d5ec8001ebf95c917fdc0d186d29650533d93Thanks @OliverSpeir! - Improves the a11y-missing-content rule and error message for audit feature of dev-overlay. This also fixes an error where this check was falsely reporting accessibility errors. -
#9643
e9a72d9a91a3741566866bcaab11172cb0dc7d31Thanks @blackmann! - Adds a newmarkdown.shikiConfig.transformersconfig option. You can use this option to transform the Shikiji hast (AST format of the generated HTML) to customize the final HTML. Also updates Shikiji to the latest stable version.See Shikiji's documentation for more details about creating your own custom transformers, and a list of common transformers you can add directly to your project.
-
#9644
a5f1682347e602330246129d4666a9227374c832Thanks @rossrobino! - Adds an experimental flagclientPrerenderto prerender your prefetched pages on the client with the Speculation Rules API.// astro.config.mjs { prefetch: { prefetchAll: true, defaultStrategy: 'viewport', }, experimental: { clientPrerender: true, }, }Enabling this feature overrides the default
prefetchbehavior globally to prerender links on the client according to yourprefetchconfiguration. Instead of appending a<link>tag to the head of the document or fetching the page with JavaScript, a<script>tag will be appended with the corresponding speculation rules.Client side prerendering requires browser support. If the Speculation Rules API is not supported,
prefetchwill fallback to the supported strategy.See the Prefetch Guide for more
prefetchoptions and usage. -
#9439
fd17f4a40b83d14350dce691aeb79d87e8fcaf40Thanks @Fryuni! - Adds an experimental flagglobalRoutePriorityto prioritize redirects and injected routes equally alongside file-based project routes, following the same route priority order rules for all routes.// astro.config.mjs export default defineConfig({ experimental: { globalRoutePriority: true, }, });Enabling this feature ensures that all routes in your project follow the same, predictable route priority order rules. In particular, this avoids an issue where redirects or injected routes (e.g. from an integration) would always take precedence over local route definitions, making it impossible to override some routes locally.
The following table shows which route builds certain page URLs when file-based routes, injected routes, and redirects are combined as shown below:
- File-based route:
/blog/post/[pid] - File-based route:
/[page] - Injected route:
/blog/[...slug] - Redirect:
/blog/tags/[tag]->/[tag] - Redirect:
/posts->/blog
URLs are handled by the following routes:
Page Current Behavior Global Routing Priority Behavior /blog/tags/astroInjected route /blog/[...slug]Redirect to /tags/[tag]/blog/post/0Injected route /blog/[...slug]File-based route /blog/post/[pid]/postsFile-based route /[page]Redirect to /blogIn the event of route collisions, where two routes of equal route priority attempt to build the same URL, Astro will log a warning identifying the conflicting routes.
- File-based route:
Patch Changes
-
#9719
7e1db8b4ce2da9e044ea0393e533c6db2561ac90Thanks @bluwy! - Refactors Vite config to avoid Vite 5.1 warnings -
#9439
fd17f4a40b83d14350dce691aeb79d87e8fcaf40Thanks @Fryuni! - Updates Astro's routing priority rules to prioritize the most specifically-defined routes.Now, routes with more defined path segments will take precedence over less specific routes.
For example,
/blog/posts/[pid].astro(3 path segments) takes precedence over/blog/[...slug].astro(2 path segments). This means that:/pages/blog/posts/[id].astrowill build routes of the form/blog/posts/1and/blog/posts/a/pages/blog/[...slug].astrowill build routes of a variety of forms, includingblog/1and/blog/posts/1/a, but will not build either of the previous routes.
For a complete list of Astro's routing priority rules, please see the routing guide. This should not be a breaking change, but you may wish to inspect your built routes to ensure that your project is unaffected.
-
#9706
1539e04a8e5865027b3a8718c6f142885e7c8d88Thanks @bluwy! - Simplifies HMR handling, improves circular dependency invalidation, and fixes Astro styles invalidation -
Updated dependencies [
165cfc154be477337037185c32b308616d1ed6fa,e9a72d9a91a3741566866bcaab11172cb0dc7d31]:- @astrojs/markdown-remark@4.1.0
Patch Changes
-
#9665
d02a3c48a3ce204649d22e17b1e26fb5a6a60bcfThanks @bluwy! - Disables internal file watcher for one-off Vite servers to improve start-up performance -
#9664
1bf0ddd2777ae5f9fde3fd854a9e75aa56c080f2Thanks @bluwy! - Improves HMR for Astro style and script modules -
#9668
74008cc23853ed507b144efab02300202c5386edThanks @Princesseuh! - Fix the passthrough image service not generatingsrcsetvalues properly -
#9693
d38b2a4fe827e956662fcf457d1f1f84832c2f15Thanks @kidylee! - Disables View Transition form handling when theactionproperty points to an external URL -
#9678
091097e60ef38dadb87d7c8c1fc9cb939a248921Thanks @ematipico! - Adds an error during the build phase in casei18n.routing.prefixDefaultLocaleis set totrueand the index page is missing. -
#9659
39050c6e1f77dc21e87716d95e627a654828ee74Thanks @Princesseuh! - Fix Astro wrongfully deleting certain images imported with?urlwhen used in tandem withastro:assets -
#9685
35d54b3ddb3310ab4c505d49bd4937b2d25e4078Thanks @lilnasy! - Fixes an issue where anchor elements within a custom component could not trigger a view transition.
Patch Changes
-
#9642
cdb7bfa66260afc79b829b617492a01a709a86efThanks @martrapp! - Fixes an issue where View Transitions did not work when navigating to the 404 page -
#9637
5cba637c4ec39c06794146b0c7fd3225d26dcabbThanks @bluwy! - Improves environment variables replacement in SSR -
#9658
a3b5695176cd0280438938c1d6caef478a571415Thanks @martrapp! - Fixes an issue caused by trying to load text/partytown scripts during view transitions -
#9657
a4f90d95ff97abe59f2a1ef0956cab257ae36838Thanks @ematipico! - Fixes a bug where the custom status code wasn't correctly computed in the dev server -
#9627
a700a20291e19cde23705e8e661e833aec7d3095Thanks @lilnasy! - Adds a warning when setting cookies will have no effect -
#9652
e72efd6a9a1e2a70488fd225529617ffd8418534Thanks @bluwy! - Improves environment variables handling by using esbuild to perform replacements -
#9560
8b9c4844f7b302380835154fab1c3489979fc07dThanks @bluwy! - Fixes tsconfig alias with import.meta.glob -
#9653
50f39183cfec4a4522c1f935d710e5d9b724993bThanks @Princesseuh! - Pin Sharp to 0.32.6 until we can raise our semver requirements. To use the latest version of Sharp, you can add it to your project's dependencies.
Patch Changes
-
#9618
401fd3e8c8957a3bed6469a622cd67b157ca303fThanks @ldh3907! - Adds a second generic parameter toAPIRouteto type theparams -
#9600
47b951b3888a5a8a708d2f9b974f12fba7ec9ed3Thanks @jacobdalamb! - Improves tailwind config file detection when adding the tailwind integration usingastro add tailwindTailwind config file ending in
.ts,.mtsor.ctswill now be used instead of creating a newtailwind.config.mjswhen the tailwind integration is added usingastro add tailwind. -
#9622
5156c740506cbf6ec85c95e1663c14cbd438d75bThanks @bluwy! - Fixes the Sharp image servicelimitInputPixelsoption type
Minor Changes
-
#9513
e44f6acf99195a3f29b8390fd9b2c06410551b74Thanks @wtto00! - Adds a'load'prefetch strategy to prefetch links on page load -
#9377
fe719e27a84c09e46b515252690678c174a25759Thanks @bluwy! - Adds "Missing ARIA roles check" and "Unsupported ARIA roles check" audit rules for the dev toolbar -
#9573
2a8b9c56b9c6918531c57ec38b89474571331aeeThanks @bluwy! - Allows passing a string to--openandserver.opento open a specific URL on startup in development -
#9544
b8a6fa8917ff7babd35dafb3d3dcd9a58cee836dThanks @bluwy! - Adds a helpful error for static sites when you use theastro previewcommand if you have not previously runastro build. -
#9546
08402ad5846c73b6887e74ed4575fd71a3e3c73dThanks @bluwy! - Adds an option for the Sharp image service to allow large images to be processed. SetlimitInputPixels: falseto bypass the default image size limit:// astro.config.mjs import { defineConfig } from 'astro/config'; export default defineConfig({ image: { service: { entrypoint: 'astro/assets/services/sharp', config: { limitInputPixels: false, }, }, }, }); -
#9596
fbc26976533bbcf2de9d6dba1aa3ea3dc6ce0853Thanks @Princesseuh! - Adds the ability to set arootMarginsetting when using theclient:visibledirective. This allows a component to be hydrated when it is near the viewport, rather than hydrated when it has entered the viewport.<!-- Load component when it's within 200px away from entering the viewport --> <Component client:visible={{ rootMargin: '200px' }} /> -
#9063
f33fe3190b482a42ebc68cc5275fd7f2c49102e6Thanks @alex-sherwin! - Cookie encoding / decoding can now be customizedAdds new
encodeanddecodefunctions to allow customizing how cookies are encoded and decoded. For example, you can bypass the default encoding viaencodeURIComponentwhen adding a URL as part of a cookie:--- import { encodeCookieValue } from './cookies'; Astro.cookies.set('url', Astro.url.toString(), { // Override the default encoding so that URI components are not encoded encode: (value) => encodeCookieValue(value), }); ---Later, you can decode the URL in the same way:
--- import { decodeCookieValue } from './cookies'; const url = Astro.cookies.get('url', { decode: (value) => decodeCookieValue(value), }); ---
Patch Changes
-
#9593
3b4e629ac8c2fdb4b491bf01abc7794e2e100173Thanks @bluwy! - Improvesastro adderror reporting when the dependencies fail to install -
#9563
d48ab90fb41fbc0589cd2df711682a41382c03aaThanks @martrapp! - Fixes back navigation to fragment links (e.g.#about) in Firefox when using view transitionsCo-authored-by: Florian Lefebvre 69633530+florian-lefebvre@users.noreply.github.com Co-authored-by: Sarah Rainsberger sarah@rainsberger.ca
-
#9597
9fd24a546c45d48451da46637c14e7ed54dac76aThanks @lilnasy! - Fixes an issue where configuring trailingSlash had no effect on API routes. -
#9586
82bad5d6205672ed3f6a49d4de53d3a68367433eThanks @martrapp! - Fixes page titles in the browser's drop-down for back / forward navigation when using view transitions -
#9575
ab6049bd58e4d02f47d500f9db08a865bc7f09b8Thanks @bluwy! - Sets correctprocess.env.NODE_ENVdefault when using the JS API -
#9587
da307e4a080483f8763f1919a05fa2194bb14e22Thanks @jjenzz! - Adds aCSSPropertiesinterface that allows extending the style attribute -
#9513
e44f6acf99195a3f29b8390fd9b2c06410551b74Thanks @wtto00! - Ignores3gin slow connection detection. Only2gandslow-2gare considered slow connections.
Patch Changes
-
#9571
ec71f03cfd9b8195fb21c92dfda0eff63b6ebeedThanks @bluwy! - Removes telemetry for unhandled errors in the dev server -
#9548
8049f0cd91b239c52e37d571e3ba3e703cf0e4cfThanks @bluwy! - Fixes error overlay display on URI malformed error -
#9504
8cc3d6aa46f438d668516539c34b48ad748ade39Thanks @matiboux! - Implement i18n'sgetLocaleByPathfunction -
#9547
22f42d11a4fd2e154a0c5873c4f516584e383b70Thanks @bluwy! - Prevents ANSI codes from rendering in the error overlay -
#9446
ede3f7fef6b43a08c9371f7a2531e2eef858b94dThanks @alexnguyennz! - Toggle dev toolbar hitbox height when toolbar is visible -
#9572
9f6453cf4972ac28eec4f07a1373feaa295c8864Thanks @bluwy! - Documents supported--hostand--portflags inastro preview --help -
#9540
7f212f0831d8cd899a86fb94899a7cad8ec280dbThanks @matthewp! - Fixes remote images with encoded characters -
#9559
8b873bf1f343efc1f486d8ef53c38380e2373c08Thanks @sygint! - Adds 'starlight' to the displayed options forastro add -
#9537
16e61fcacb98e6bd948ac240bc082659d70193a4Thanks @walter9388! -<Image />srcset now parses encoded paths correctly
Patch Changes
-
#9522
bb1438d20d325acd15f3755c6e306e45a7c64bcdThanks @Zegnat! - Add support for autocomplete attribute to the HTML button type. -
#9531
662f06fd9fae377bed1aaa49adbba3542cced087Thanks @bluwy! - Fixes duplicated CSS modules content when it's imported by both Astro files and framework components -
#9501
eb36e95596fcdb3db4a31744e910495e22e3af84Thanks @Princesseuh! - Export JSX namespace fromastro/jsx-runtimefor language tooling to consume -
#9492
89a2a07c2e411cda32244b7b05d3c79e93f7dd84Thanks @lilnasy! - Improves error message for the case where two similarly named files result in the same content entry. -
#9532
7224809b73d2c3ec8e8aee2fa07463dc3b57a7a2Thanks @bluwy! - Prevents unnecessary URI decoding when rendering a route -
#9478
dfef925e1fd07f3efb9fde6f4f23548f2af7dc75Thanks @lilnasy! - Improves errors in certain places to also report their causes. -
#9463
3b0eaed3b544ef8c4ec1f7b0d5a8f475bcfeb25eThanks @Princesseuh! - Update Sharp version to ^0.33.1 -
#9512
1469e0e5a915e6b42b9953dbb48fe57a74518056Thanks @mingjunlu! - Prevents dev toolbar tooltip from overflowing outside of the screen -
#9497
7f7a7f1aeaec6b327ae0e5e7470a4f46174bf8aeThanks @lilnasy! - Adds a helpful warning message for when an exported API Route is not uppercase.
Patch Changes
-
#9452
e83b5095fThanks @florian-lefebvre! - Upgrades vite to latest -
#9352
f515b1421Thanks @tmcw! - Add a more descriptive error message when image conversion fails -
#9486
f6714f677Thanks @martrapp! - Fixes View Transition's form submission prevention, allowingpreventDefaultto be used. -
#9461
429be8cc3Thanks @Skn0tt! - update import created forastro create netlify -
#9464
faf6c7e11Thanks @Fryuni! - Fixes an edge case with view transitions where some spec-compliantContent-Typeheaders would cause a valid HTML response to be ignored. -
#9400
1e984389bThanks @bluwy! - Fixes importing dev toolbar apps from integrations on Windows -
#9487
19169db1fThanks @ematipico! - Improves logging of the generated pages during the build -
#9460
047d285beThanks @Princesseuh! - Fix Astro failing to build on certain exotic platform that reports their CPU count incorrectly -
#9466
5062d27a1Thanks @knpwrs! - Updates view transitionsformhandling with logic for theenctypeattribute -
#9458
fa3078ce9Thanks @ematipico! - Correctly handle the error in case the middleware throws a runtime error -
#9089
5ae657882Thanks @lilnasy! - Fixes an issue where redirects did not replace slugs when the target of the redirect rule was not a verbatim route in the project. -
#9483
c384f6924Thanks @Princesseuh! - Fix some false positive in the audit logic of the dev toolbar -
#9437
354a62c86Thanks @dkobierski! - Fixes incorrect hoisted script paths when custom rollup output file names are configured -
#9475
7ae4928f3Thanks @ematipico! - Remove the manifest from the generated files in thedist/folder.
Patch Changes
-
#9419
151bd429bThanks @matthewp! - Prevent Partytown from hijacking history APIs -
#9426
c01cc4e34Thanks @alexnguyennz! - Fixes warning for external URL redirects -
#9445
f963d07f2Thanks @natemoo-re! - Upgrades Astro's compiler to a crash when sourcemaps try to map multibyte characters -
#9126
6d2d0e279Thanks @lilnasy! - Fixes an issue where error pages were not shown when trailingSlash was set to "always". -
#9434
c01580a2cThanks @ematipico! - Improves the error message when a middleware doesn't return aResponse -
#9433
fcc2fd5b0Thanks @ematipico! - Correctly merge headers from the original response when an error page is rendered
Patch Changes
-
#9423
bda1d294fThanks @matthewp! - Error when getImage is passed an undefined src -
#9424
e1a5a2d36Thanks @matthewp! - Prevents dev server from crashing on unhandled rejections, and adds a helpful error message -
#9404
8aa17a64bThanks @Princesseuh! - Fixed some newer HTML attributes not being included in our type definitions -
#9414
bebf38c0cThanks @Skn0tt! - Adds the feature name to logs about feature deprecation / experimental status. -
#9418
2c168af67Thanks @alexnguyennz! - Fix broken link in CI instructions -
#9407
546d92c86Thanks @matthewp! - Allows file URLs as import specifiers
Patch Changes
-
#9380
ea0918259Thanks @ematipico! - Correctly handle the rendering of i18n routes whenoutput: "hybrid"is set -
#9374
65ddb0271Thanks @bluwy! - Fixes an issue where prerendered route paths that end with.mjswere removed from the final build -
#9375
26f7023d6Thanks @bluwy! - Prettifies generated route names injected by integrations -
#9387
a7c75b333Thanks @natemoo-re! - Fixes an edge case withastro addthat could install a prerelease instead of a stable release version.Prior to this change
astro add svelteinstallssvelte@5.0.0-next.22After this change
astro add svelteinstallssvelte@4.2.8 -
Updated dependencies [
270c6cc27]:- @astrojs/markdown-remark@4.0.1
Patch Changes
-
#9342
eb942942dThanks @Princesseuh! - Fix missingis:inlinetype for the<slot />element -
#9343
ab0281aeeThanks @martrapp! - Adds source file properties to HTML elements only if devToolbar is enabled -
#9336
c76901065Thanks @FredKSchott! - dev: fix issue where 404 and 500 responses were logged as 200 -
#9339
0bb3d5322Thanks @morinokami! - Fixed the log message to correctly display 'enabled' and 'disabled' when toggling 'Disable notifications' in the Toolbar.
Patch Changes
-
#9331
cfb20550dThanks @natemoo-re! - Updates an internal dependency (vitefu) to avoid a commonpeerDependencywarning -
#9327
3878a91beThanks @doseofted! - Fixes an edge case for<form method="dialog">when using View Transitions. Forms withmethod="dialog"no longer require an additionaldata-astro-reloadattribute.
Patch Changes
- #9315
631e5d01bThanks @ematipico! - Fixes an issue where logs that weren't grouped together by route when building the app.
Major Changes
-
#9138
abf601233Thanks @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.footnoteBackLabelis changed from"Back to content"to"Back to reference 1". See themdast-util-to-hastcommit for more information. -
#9181
cdabf6ef0Thanks @bluwy! - Removes support for returning simple objects from endpoints (deprecated since Astro 3.0). You should return aResponseinstead.ResponseWithEncodingis 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
MiddlewareHandlerinstead ofMiddlewareResponseHandler. If you useddefineMiddleware()to type the function, no changes are needed. -
#9263
3cbd8ea75Thanks @bluwy! - Removes additional deprecated APIs:- The Astro preview server now returns a 404 status instead of a 301 redirect when requesting assets from the public directory without a base.
- Removes special handling when referencing the
astro/client-imagetype. You should use theastro/clienttype instead. - Removes deprecated built-in
rsssupport ingetStaticPaths. You should use@astrojs/rssinstead. - Removes deprecated
Astro.request.paramssupport. You should useAstro.paramsinstead.
-
#9271
47604bd5bThanks @matthewp! - Renames Dev Overlay to Dev ToolbarThe previously named experimental Dev Overlay is now known as the Astro Dev Toolbar. Overlay plugins have been renamed as Toolbar Apps. All APIs have been updated to reflect this name change.
To not break existing APIs, aliases for the Toolbar-based names have been created. The previous API names will continue to function but will be deprecated in the future. All documentation has been updated to reflect Toolbar-based names.
-
#9122
1c48ed286Thanks @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. -
#9225
c421a3d17Thanks @natemoo-re! - Removes the opt-inhandleFormsproperty for<ViewTransitions />. Form submissions are now handled by default and this property is no longer necessary. This default behavior can be disabled by settingdata-astro-reloadon relevant<form />elements. -
#9196
37697a2c5Thanks @bluwy! - Removes support for Shiki custom language'spathproperty. The language JSON file should be imported and passed to the option instead.// astro.config.js + import customLang from './custom.tmLanguage.json' export default defineConfig({ markdown: { shikiConfig: { langs: [ - { path: './custom.tmLanguage.json' }, + customLang, ], }, }, }) -
#9199
49aa215a0Thanks @lilnasy! - This change only affects maintainers of third-party adapters. In the Integration API, theapp.render()method of theAppclass has been simplified.Instead of two optional arguments, it now takes a single optional argument that is an object with two optional properties:
routeDataandlocals.app.render(request) - app.render(request, routeData) + app.render(request, { routeData }) - app.render(request, routeData, locals) + app.render(request, { routeData, locals }) - app.render(request, undefined, locals) + app.render(request, { locals })The current signature is deprecated but will continue to function until next major version.
-
#9212
c0383ea0cThanks @alexanderniebuhr! - Removes deprecatedapp.match()option,matchNotFound -
#9168
153a5abb9Thanks @bluwy! - Removes deprecated features from Astro 3.0- Adapters are now required to pass
supportedAstroFeaturesto specify a list of features they support. - The
build.splitandbuild.excludeMiddlewareoptions are removed. UsefunctionPerRouteandedgeMiddlewarefrom adapters instead. - The
markdown.draftsoption and draft feature is removed. Use content collections instead. - Lowercase endpoint names are no longer supported. Use uppercase endpoint names instead.
getHeaders()exported from markdown files is removed. UsegetHeadings()instead.
- Adapters are now required to pass
Minor Changes
-
#9105
6201bbe96Thanks @FredKSchott! - Update CLI logging experience -
#9200
b4b851f5aThanks @ematipico! - Adds a new way to configure thei18n.localesarray.Developers can now assign a custom URL path prefix that can span multiple language codes:
// astro.config.mjs export default defineConfig({ experimental: { i18n: { defaultLocale: 'english', locales: ['de', { path: 'english', codes: ['en', 'en-US'] }, 'fr'], }, }, });With the above configuration, the URL prefix of the default locale will be
/english/. When computingAstro.preferredLocale, Astro will use thecodes. -
#9115
3b77889b4Thanks @natemoo-re! - Adds theastro preferencescommand to manage user preferences. User preferences are specific to individual Astro users, unlike theastro.config.mjsfile which changes behavior for everyone working on a project.User preferences are scoped to the current project by default, stored in a local
.astro/settings.jsonfile. Using the--globalflag, user preferences can also be applied to every Astro project on the current machine. Global user preferences are stored in an operating system-specific location.# Disable the dev overlay for the current user in the current project npm run astro preferences disable devOverlay # Disable the dev overlay for the current user in all Astro projects on this machine npm run astro preferences --global disable devOverlay # Check if the dev overlay is enabled for the current user npm run astro preferences list devOverlay -
#9139
459b26436Thanks @bluwy! - Reworks Vite's logger to use Astro's logger to correctly log HMR messages -
#9279
6a9669b81Thanks @martrapp! - Improves consistency between navigations with and without<ViewTransitions>. See #9279 for more details. -
#9161
bd0c2e9aeThanks @bluwy! - Renames theentryPointproperty of theinjectRouteintegrations API toentrypointfor consistency. A warning will be shown prompting you to update your code when using the old name. -
#9129
8bfc20511Thanks @FredKSchott! - Update error log formatting
Patch Changes
-
#9118
000e8f465Thanks @Princesseuh! - Redesign Dev Overlay main screen to show more information, such as the coolest integrations, your current Astro version and more. -
#9118
000e8f465Thanks @Princesseuh! - Fixes an issue where links with the same pathname as the current page, but different search params, were not prefetched. -
#9275
0968cb1a3Thanks @lilnasy! - Fixes an issue where html annotations relevant only to the dev server were included in the production build. -
#9252
7b74ec4baThanks @ematipico! - Consistently emit fallback routes in the correct folders, and emit routes that considertrailingSlash -
#9222
279e3c1b3Thanks @matthewp! - Ensure the dev-overlay-window is anchored to the bottom -
#9292
5428b3da0Thanks @natemoo-re! - Improves display forastro preferences listcommand -
#9235
9c2342c32Thanks @Princesseuh! - Fix SVG icons not showing properly in the extended dropdown menu of the dev overlay -
#9218
f4401c8c1Thanks @matthewp! - Improve high contrast mode with the Dev Overlay -
#9254
b750a161eThanks @matthewp! - Improve highlight/tooltip positioning when in fixed positions -
#9230
60cfa49e4Thanks @FredKSchott! - Update the look and feel of the dev overlay -
#9248
43ddb5217Thanks @martrapp! - Adds properties of the submit button (name, value) to the form data of a view transition -
#9170
8a228fce0Thanks @natemoo-re! - Adds new accessibility audits to the Dev Toolbar's built-in Audits app.The audits Astro performs are non-exhaustive and only capable of detecting a handful of common accessibility issues. Please take care to perform a thorough, manual audit of your site to ensure compliance with the Web Content Accessibility Guidelines (WCAG) international standard before publishing your site.
🧡 Huge thanks to the Svelte team for providing the basis of these accessibility audits!
-
#9149
0fe3a7ed5Thanks @bluwy! - Removes vendored Vite'simportMeta.d.tsfile in favour of Vite 5's newvite/types/import-meta.d.tsexport -
#9295
3d2dbb0e5Thanks @matthewp! - Remove aria-query packageThis is another CJS-only package that breaks usage.
-
#9274
feaba2c7fThanks @TheOtterlord! - Fix routing prefixes whenprefixDefaultLocaleistrue -
#9273
9887f2412Thanks @alexanderniebuhr! - Exports type for Dev Toolbar App under correct name -
#9150
710be505cThanks @bluwy! - Refactors virtual modules exports. This should not break your project unless you import Astro's internal modules, including:astro/middleware/namespaceastro/transitionsastro/transitions/routerastro/transitions/eventsastro/transitions/typesastro/prefetchastro/i18n
-
#9227
4b8a42406Thanks @matthewp! - Ensure overlay x-ray z-index is higher than the island -
#9255
9ea3e0b94Thanks @matthewp! - Adds instructions on how to hide the dev overlay -
#9293
cf5fa4376Thanks @matthewp! - Removes the 'a11y-role-has-required-aria-props' audit ruleThis audit rule depends on a CommonJS module. To prevent blocking the 4.0 release the rule is being removed temporarily.
-
#9214
4fe523b00Thanks @Princesseuh! - Fixes a number of small user experience bugs with the dev overlay -
#9013
ff8eadb95Thanks @bayssmekanique! - Returns the updated config in the integrationastro:config:setuphook'supdateConfig()API -
Updated dependencies [
abf601233,addb57c8e,c7953645e]:- @astrojs/markdown-remark@4.0.0
Patch Changes
-
#9275
0968cb1a3Thanks @lilnasy! - Fixes an issue where html annotations relevant only to the dev server were included in the production build. -
#9292
5428b3da0Thanks @natemoo-re! - Improves display forastro preferences listcommand -
#9293
cf5fa4376Thanks @matthewp! - Removes the 'a11y-role-has-required-aria-props' audit ruleThis audit rule depends on a CommonJS module. To prevent blocking the 4.0 release the rule is being removed temporarily.
Minor Changes
- #9279
6a9669b81Thanks @martrapp! - Improves consistency between navigations with and without<ViewTransitions>. See #9279 for more details.
Patch Changes
-
#9170
8a228fce0Thanks @natemoo-re! - Adds new accessibility audits to the Dev Toolbar's built-in Audits app.The audits Astro performs are non-exhaustive and only capable of detecting a handful of common accessibility issues. Please take care to perform a thorough, manual audit of your site to ensure compliance with the Web Content Accessibility Guidelines (WCAG) international standard before publishing your site.
🧡 Huge thanks to the Svelte team for providing the basis of these accessibility audits!
-
#9274
feaba2c7fThanks @TheOtterlord! - Fix routing prefixes whenprefixDefaultLocaleistrue -
#9273
9887f2412Thanks @alexanderniebuhr! - Exports type for Dev Toolbar App under correct name
Major Changes
-
#9271
47604bd5bThanks @matthewp! - Renames Dev Overlay to Dev ToolbarThe previously named experimental Dev Overlay is now known as the Astro Dev Toolbar. Plugins have been renamed as Toolbar Apps. This updates our references to reflect.
To not break existing APIs, aliases for the Toolbar-based names have been created. The previous API names will continue to function but will be deprecated in the future. All documentation has been updated to reflect Toolbar-based names.
Major Changes
-
#9263
3cbd8ea75Thanks @bluwy! - Removes additional deprecated APIs:- The Astro preview server now returns a 404 status instead of a 301 redirect when requesting assets from the public directory without a base.
- Removes special handling when referencing the
astro/client-imagetype. You should use theastro/clienttype instead. - Removes deprecated built-in
rsssupport ingetStaticPaths. You should use@astrojs/rssinstead. - Removes deprecated
Astro.request.paramssupport. You should useAstro.paramsinstead.
Minor Changes
-
#9200
b4b851f5aThanks @ematipico! - Adds a new way to configure thei18n.localesarray.Developers can now assign a custom URL path prefix that can span multiple language codes:
// astro.config.mjs export default defineConfig({ experimental: { i18n: { defaultLocale: 'english', locales: ['de', { path: 'english', codes: ['en', 'en-US'] }, 'fr'], routingStrategy: 'prefix-always', }, }, });With the above configuration, the URL prefix of the default locale will be
/english/. When computingAstro.preferredLocale, Astro will use thecodes. -
#9139
459b26436Thanks @bluwy! - Reworks Vite's logger to use Astro's logger to correctly log HMR messages
Patch Changes
-
#9252
7b74ec4baThanks @ematipico! - Consistently emit fallback routes in the correct folders, and emit routes that considertrailingSlash -
#9235
9c2342c32Thanks @Princesseuh! - Fix SVG icons not showing properly in the extended dropdown menu of the dev overlay -
#9254
b750a161eThanks @matthewp! - Improve highlight/tooltip positioning when in fixed positions -
#9230
60cfa49e4Thanks @FredKSchott! - Update the look and feel of the dev overlay -
#9248
43ddb5217Thanks @martrapp! - Adds properties of the submit button (name, value) to the form data of a view transition -
#9255
9ea3e0b94Thanks @matthewp! - Adds instructions on how to hide the dev overlay -
#9013
ff8eadb95Thanks @bayssmekanique! - Returns the updated config in the integrationastro:config:setuphook'supdateConfig()API
Major Changes
-
#9225
c421a3d17Thanks @natemoo-re! - Removes the opt-inhandleFormsproperty for<ViewTransitions />. Form submissions are now handled by default and can be disabled by settingdata-astro-reloadon relevant<form />elements. -
#9199
49aa215a0Thanks @lilnasy! - This change only affects maintainers of third-party adapters. In the Integration API, theapp.render()method of theAppclass has been simplified.Instead of two optional arguments, it now takes a single optional argument that is an object with two optional properties:
routeDataandlocals.app.render(request) - app.render(request, routeData) + app.render(request, { routeData }) - app.render(request, routeData, locals) + app.render(request, { routeData, locals }) - app.render(request, undefined, locals) + app.render(request, { locals })The current signature is deprecated but will continue to function until next major version.
-
#9212
c0383ea0cThanks @alexanderniebuhr! - Removes deprecatedapp.match()option,matchNotFound
Minor Changes
-
#9115
3b77889b4Thanks @natemoo-re! - Adds theastro preferencescommand to manage user preferences. User preferences are specific to individual Astro users, unlike theastro.config.mjsfile which changes behavior for everyone working on a project.User preferences are scoped to the current project by default, stored in a local
.astro/settings.jsonfile. Using the--globalflag, user preferences can also be applied to every Astro project on the current machine. Global user preferences are stored in an operating system-specific location.# Disable the dev overlay for the current user in the current project npm run astro preferences disable devOverlay # Disable the dev overlay for the current user in all Astro projects on this machine npm run astro preferences --global disable devOverlay # Check if the dev overlay is enabled for the current user npm run astro preferences list devOverlay -
#9129
8bfc20511Thanks @FredKSchott! - Update error log formatting
Patch Changes
-
#9222
279e3c1b3Thanks @matthewp! - Ensure the dev-overlay-window is anchored to the bottom -
#9218
f4401c8c1Thanks @matthewp! - Improve high contrast mode with the Dev Overlay -
#9227
4b8a42406Thanks @matthewp! - Ensure overlay x-ray z-index is higher than the island -
#9214
4fe523b00Thanks @Princesseuh! - Fixes a number of small user experience bugs with the dev overlay
Patch Changes
-
#9118
000e8f465Thanks @Princesseuh! - Redesign Dev Overlay main screen to show more information, such as the coolest integrations, your current Astro version and more. -
#9118
000e8f465Thanks @Princesseuh! - Fixes an issue where links with the same pathname as the current page, but different search params, were not prefetched.
Major Changes
-
#9138
abf601233Thanks @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.footnoteBackLabelis changed from"Back to content"to"Back to reference 1". See themdast-util-to-hastcommit for more information. -
#9181
cdabf6ef0Thanks @bluwy! - Removes support for returning simple objects from endpoints (deprecated since Astro 3.0). You should return aResponseinstead.ResponseWithEncodingis 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
MiddlewareHandlerinstead ofMiddlewareResponseHandler. If you useddefineMiddleware()to type the function, no changes are needed. -
#9122
1c48ed286Thanks @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. -
#9196
37697a2c5Thanks @bluwy! - Removes support for Shiki custom language'spathproperty. The language JSON file should be imported and passed to the option instead.// astro.config.js + import customLang from './custom.tmLanguage.json' export default defineConfig({ markdown: { shikiConfig: { langs: [ - { path: './custom.tmLanguage.json' }, + customLang, ], }, }, }) -
#9168
153a5abb9Thanks @bluwy! - Removes deprecated features from Astro 3.0- Adapters are now required to pass
supportedAstroFeaturesto specify a list of features they support. - The
build.splitandbuild.excludeMiddlewareoptions are removed. UsefunctionPerRouteandedgeMiddlewarefrom adapters instead. - The
markdown.draftsoption and draft feature is removed. Use content collections instead. - Lowercase endpoint names are no longer supported. Use uppercase endpoint names instead.
getHeaders()exported from markdown files is removed. UsegetHeadings()instead.
- Adapters are now required to pass
Minor Changes
-
#9105
6201bbe96Thanks @FredKSchott! - Update CLI logging experience -
#9161
bd0c2e9aeThanks @bluwy! - Renames theentryPointproperty of theinjectRouteintegrations API toentrypointfor consistency. A warning will be shown prompting you to update your code when using the old name.
Patch Changes
-
#9149
0fe3a7ed5Thanks @bluwy! - Removes vendored Vite'simportMeta.d.tsfile in favour of Vite 5's newvite/types/import-meta.d.tsexport -
#9150
710be505cThanks @bluwy! - Refactors virtual modules exports. This should not break your project unless you import Astro's internal modules, including:astro/middleware/namespaceastro/transitionsastro/transitions/routerastro/transitions/eventsastro/transitions/typesastro/prefetchastro/i18n
-
Updated dependencies [
abf601233,addb57c8e,c7953645e]:- @astrojs/markdown-remark@4.0.0-beta.0
Patch Changes
-
#10287
a90d685d7Thanks @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.
Patch Changes
-
#9226
8f8a40e93Thanks @outofambit! - Fix i18n fallback routing with routing strategy of always-prefix -
#9179
3f28336d9Thanks @lilnasy! - Fixes an issue where the presence of a slot in a page led to an error. -
#9219
067a65f5bThanks @natemoo-re! - Fix edge case where<style>updates inside of.astrofiles would ocassionally fail to update without reloading the page. -
#9236
27d3e86e4Thanks @ematipico! - The configurationi18n.routingStrategyhas been replaced with an object calledrouting.export default defineConfig({ experimental: { i18n: { - routingStrategy: "prefix-always", + routing: { + prefixDefaultLocale: true, + } } } })export default defineConfig({ experimental: { i18n: { - routingStrategy: "prefix-other-locales", + routing: { + prefixDefaultLocale: false, + } } } })
Patch Changes
- #9193
0dc99c9a2Thanks @florian-lefebvre! - Prevents the Code component from crashing if the lang isn't supported by falling back toplaintext.
Patch Changes
- #9189
d90714fc3Thanks @SpencerWhitehead7! - Fixes an issue where links with the same pathname as the current page, but different search params, were not prefetched.
Minor Changes
-
#9090
c87223c21Thanks @martrapp! - Take full control over the behavior of view transitions!Three new events now complement the existing
astro:after-swapandastro:page-loadevents: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 pageThe
astro:before-*events allow you to change properties and strategies of the view transition implementation. Theastro: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
0ea4bd47eThanks @smitbarmase! - Changes the fallback prefetch behavior on slow connections and when data saver mode is enabled. Instead of disabling prefetch entirely, thetapstrategy will be used. -
#9166
cba6cf32dThanks @matthewp! - The Picture component is no longer experimentalThe
<Picture />component, part ofastro: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
0ea4bd47eThanks @smitbarmase! - Adds aignoreSlowConnectionoption to theprefetch()API to prefetch even on data saver mode or slow connection.
Patch Changes
- #9157
7ff8d62bfThanks @ematipico! - Revert fix around fallback system, which broken injected styles
Patch Changes
-
#9121
f4efd1c80Thanks @peng! - Adds a warning ifastro addfetches a package but returns a non-404 status -
#9142
7d55cf68dThanks @ematipico! - Consistely emit fallback routes in the correct folders. -
#9119
306781795Thanks @ematipico! - Fix a flaw in the i18n fallback logic, where the routes didn't preserve their metadata, such as hoisted scripts -
#9140
7742fd7dcThanks @martrapp! - View Transitions: handle clicks on SVGAElements and image maps" -
#9101
e3dce215aThanks @ematipico! - Add a new propertyAstro.currentLocale, available wheni18nis enabled.
Patch Changes
-
#9091
536c6c9fdThanks @ematipico! - TheroutingStrategyprefix-alwaysshould not force its logic to endpoints. This fixes some regression withastro:assetsand@astrojs/rss. -
#9102
60e8210b0Thanks @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
Patch Changes
-
#9085
fc66ecff1Thanks @ematipico! - When redirecting to the default root locale, Astro middleare should take into consideration the value oftrailingSlash -
#9067
c6e449c5bThanks @danielhajduk! - Fixes display of debug messages when using the--verboseflag -
#9075
c5dc8f2ecThanks @Princesseuh! - Fix Passthrough image service generating multiple images with the same content in certain cases -
#9083
4537ecf0dThanks @bluwy! - Uses newcreateShikiHighlighterAPI from@astrojs/markdown-remarkto avoid code duplication -
#9084
045e5ec97Thanks @matthewp! - Supportsformmethodandformactionfor form overrides -
#9087
b895113a0Thanks @alexanderniebuhr! - Fixes the regression which broke bundling of image service for pre-rendered pages, which was introduced by #8854 -
#9058
5ef89ef33Thanks @Princesseuh! - Add a new settings panel to the dev overlay -
#9045
84312f24fThanks @rishi-raj-jain! - Fixes preview servertrailingSlashhandling for request URLs with query strings -
Updated dependencies [
4537ecf0d]:- @astrojs/markdown-remark@3.5.0
Patch Changes
- #9069
50164f5e3Thanks @natemoo-re! - Fix a regression introduced in 3.5.0 related to content collection styles
Patch Changes
- #9057
1bc331968Thanks @ematipico! - Correctly infer the presence of an user middleware
Patch Changes
-
#9037
ea71975ecThanks @sarah11918! - Updates i18n configuration reference -
#9051
15b84ccb9Thanks @ematipico! - Fix a regression where endpoints were incorrectly processed during SSG build whentrailingSlash: "always" -
#9042
7dedd17fcThanks @rishi-raj-jain! - Safely bail when thexclipcommand does not exist on Linux when trying to copy to clipboard withastro info -
#9050
bf0286e50Thanks @Princesseuh! - Fix --verbose flag not working -
#9049
49b82edb2Thanks @Princesseuh! - Fix image errors when images were used on the client
Minor Changes
-
#8869
f5bdfa272Thanks @matthewp! - ## Integration Hooks to add MiddlewareIt'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.tsfile themselves. Now, adding third-party middleware is as easy as adding a new integration.For integration authors, there is a new
addMiddlewarefunction in theastro:config:setuphook. 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
3e1239e42Thanks @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
staticsite 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 innode_modules/by default.In our internal testing on the real world Astro Docs project, this feature reduces the bundling step of
astro buildfrom 133.20s to 10.46s, about 92% faster. The end-to-endastro buildprocess used to take 4min 58s and now takes just over1minfor 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
--forceflag toastro build.astro build --force -
#8963
fda3a0213Thanks @matthewp! - Form support in View Transitions routerThe
<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
handleFormsprop to the `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-reloadproperty:--- // src/components/Contact.astro --- <form class="contact-form" action="/request" method="post" data-astro-reload> <!-- ...--> </form>Form support works on post
method="get"andmethod="post"forms. -
#8954
f0031b0a3Thanks @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
26b1484e8Thanks @Princesseuh! - Adds a new propertypropertiesToHashto the Image Services API to allow specifying which properties ofgetImage()/<Image />/<Picture />should be used for hashing the result files when doing local transformations. For most services, this will include properties such assrc,widthorqualitythat directly changes the content of the generated image. -
#9010
100b61ab5Thanks @jasikpark! - The<Picture />component will now usejpgandjpegrespectively as fallback formats when the original image is in those formats. -
#8974
143bacf39Thanks @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
i18nobject 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.astroCompute relative URLs for your links with
getRelativeLocaleUrlfrom the newastro:i18nmodule:--- 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.preferredLocaleandAstro.preferredLocaleList. These combine the browser'sAccept-Langaugeheader, 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
38e21d127Thanks @bluwy! - Prefetching is now supported in coreYou can enable prefetching for your site with the
prefetch: trueconfig. It is enabled by default when using View Transitions and can also be used to configure theprefetchbehaviour used by View Transitions.You can enable prefetching by setting
prefetch:truein your Astro config:// astro.config.js import { defineConfig } from 'astro/config'; export default defineConfig({ prefetch: true, });This replaces the
@astrojs/prefetchintegration, which is now deprecated and will eventually be removed. Visit the Prefetch guide for more information. -
#8903
c5010aad3Thanks @horo-fox! - Adds experimental support for multiple shiki themes with the newmarkdown.shikiConfig.experimentalThemesoption.
Patch Changes
-
#9016
1ecc9aa32Thanks @Princesseuh! - Add ability to "Click to go editor" on auditted elements in the dev overlay -
#9029
29b83e9e4Thanks @Princesseuh! - Use UInt8Array instead of Buffer for both the input and return values of thetransform()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
UInt8Arrayto aBufferusingBuffer.from(your_array). -
Updated dependencies [
c5010aad3]:- @astrojs/markdown-remark@3.4.0
Patch Changes
-
#9000
35739d01eThanks @martrapp! - Fixes an error in dev mode on Safari where view transitions prevented navigating to pages withclient:onlycomponents -
#9014
d979b8f0aThanks @Princesseuh! - Add animations, shadows and general styling tweaks to the Dev Overlay to better match the intended design. -
#8996
3988bbcc9Thanks @bluwy! - Adds compatibility for shiki languages with thepathproperty -
#8986
910eb00feThanks @Princesseuh! - Fixsizesattribute not being present onsourceelements when using it on the Picture component
Patch Changes
-
#8977
40a061679Thanks @matthewp! - Prevent route announcer from being visible -
#8929
2da33b7a1Thanks @lilnasy! - Fixes an issue where rendering the same slot multiple times invoked it only once. -
#8978
cc3278bb6Thanks @Princesseuh! - In the dev overlay, add a tooltip showing the currently hovered / focused plugin's name
Patch Changes
-
#8966
262cef248Thanks @Princesseuh! - Fix Dev Overlay not working properly when view transitions are enabled -
#8932
5fed432b0Thanks @Princesseuh! - Fixed window component appearing over the dev overlay on small windows. Added a maximum length to sections of the tooltip component -
#8965
430c470acThanks @matthewp! - Move VT route announcer styles to a classDoing so allows stricter CSP policies.
-
#8762
35cd810f0Thanks @evadecker! - Upgrades Zod to 3.22.4 -
#8928
ca90b47cfThanks @HiDeoo! - Renames dev overlay UI Toolkit component names for consistency.
Minor Changes
-
#8755
fe4079f05Thanks @matthewp! - Page PartialsA 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
doctypeor 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
4740d761aThanks @Princesseuh! - Improved image optimization performanceAstro 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
e99586787Thanks @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
8c3d4a859Thanks @alexanderniebuhr! - Moves the logic for overriding the image service out of core and into adapters. Also fixes a regression where a validastro:assetsimage service configuration could be overridden.
Patch Changes
-
#8870
5ea6ee0edThanks @xstevenyung! - prevent production install on astro add cmd -
#8840
5c888c10bThanks @martrapp! - Fixes styles ofclient:onlycomponents not persisting during view transitions in dev mode -
#8814
ad2bb9155Thanks @lilnasy! - Fix an issue where500.astrodid not render when the middleware threw an error. -
#8863
326e17893Thanks @florian-lefebvre! - Fixes an issue where the dev server logged the full file path on updates.
Patch Changes
-
#8852
2c18e2d12Thanks @rayriffy! - Only use Vite config from astro.config.mjs as source of truth -
#8828
11f45b9a3Thanks @rishi-raj-jain! - fix file system path references -
#8779
2b8a459a6Thanks @ematipico! - Enriches the explanation of thebaseconfiguration with examples.
Patch Changes
-
#8823
8946f2a25Thanks @Princesseuh! - Fix duplicate images being created in some cases when using densities and/or widths -
#8842
b405b039aThanks @Princesseuh! - Fixes Picture component not taking into account the fallback format specified -
#8827
ce3025cfaThanks @rishi-raj-jain! - better error handling there whenever we don't get a normal 200 response -
#8817
f8de1983bThanks @bluwy! - Fix error overlay syntax highlighting -
#8838
2f9e2083dThanks @dominikg! - deps: unpin and update tsconfck from3.0.0-next.9to^3.0.0 -
#8823
8946f2a25Thanks @Princesseuh! - fix remote srcset images not being resized
Minor Changes
-
#8808
2993055beThanks @delucis! - Adds support for an--outDirCLI flag toastro build -
#8502
c4270e476Thanks @bluwy! - Updates the internalshikisyntax highlighter toshikiji, 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
shikijinow produces a smaller HTML markup by attaching a fallbackcolorstyle to thepreorcodeelement, instead of to the linespandirectly. 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
spanwill inherit thecolorfrom the parent, but if you're relying on a specific HTML markup, please check your site carefully after upgrading to verify the styles. -
#8798
f369fa250Thanks @Princesseuh! - Fixedtsconfig.json's new array format forextendsnot working. This was done by migrating Astro to usetsconfckinstead oftsconfig-resolverto find and parsetsconfig.jsonfiles. -
#8620
b2ae9ee0cThanks @Princesseuh! - Adds experimental support for generatingsrcsetattributes and a new<Picture />component.srcsetsupportTwo new properties have been added to
ImageandgetImage():densitiesandwidths.These properties can be used to generate a
srcsetattribute, 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" /><img src="/_astro/my_image.hash.webp" srcset="/_astro/my_image.hash.webp 1.5x, /_astro/my_image.hash.webp 2x" alt="My cool image" />Picture component
The experimental
<Picture />component can be used to generate a<picture>element with multiple<source>elements.The example below uses the
formatproperty 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" /> <img src="..." alt="My super image in multiple formats!" /> </picture>The
Picturecomponent takes all the same props as theImagecomponent, including the newdensitiesandwidthsproperties.
Patch Changes
-
#8771
bd5aa1cd3Thanks @lilnasy! - Fixed an issue where the transitions router did not work within framework components. -
#8800
391729686Thanks @lilnasy! - Fixed an issue where attempting to assign a variable onto locals threw an error. -
#8795
f999365b8Thanks @bluwy! - Fix markdown page charset to be utf-8 by default (same as Astro 2) -
#8810
0abff97feThanks @jacobthesheep! - Removenetwork-information-typespackage since TypeScript supports Network Information API natively. -
#8813
3bef32f81Thanks @martrapp! - Save and restore focus for persisted input elements during view transitions -
Updated dependencies [
c4270e476]:- @astrojs/markdown-remark@3.3.0
Patch Changes
-
#8638
160d1cd75Thanks @florian-lefebvre! - The@astrojs/tailwindintegration now creates atailwind.config.mjsfile by default -
#8767
30de32436Thanks @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
c4a7ec425Thanks @lilnasy! - Fixed an issue on Windows where lowercase drive letters in current working directory led to missing scripts and styles. -
#8772
c24f70d91Thanks @martrapp! - Fix flickering during view transitions -
#8754
93b092266Thanks @bluwy! - Make CSS chunk names less confusing -
#8776
29cdfa024Thanks @martrapp! - Fix transition attributes on islands -
#8773
eaed844eaThanks @sumimakito! - Fix an issue where HTML attributes do not render if getHTMLAttributes in an image service returns a Promise
Patch Changes
-
#8680
31c59ad8bThanks @bluwy! - Fix hydration on slow connection -
#8698
47ea310f0Thanks @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
345808170Thanks @bluwy! - Fix duplicated Astro and Vite injected styles
Minor Changes
-
#8696
2167ffd72Thanks @matthewp! - Support adding integrations dynamicallyAstro 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/sitemapis 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
2167ffd72Thanks @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
2167ffd72Thanks @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-loadevent, 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.
Patch Changes
-
#8647
408b50c5eThanks @lilnasy! - Fixed an issue where configured redirects with dynamic routes did not work in dev mode. -
#8696
2167ffd72Thanks @matthewp! - Fix logLevel passed to Vite build -
#8696
2167ffd72Thanks @matthewp! - Fix NoImageMetadata image path error message -
#8670
e797b6816Thanks @MichailiK! - Fix asset optimization failing when outDir is outside the project directory -
#8684
824dd4670Thanks @matthewp! - Support content collections with % in filename -
#8648
cfd895d87Thanks @lilnasy! - Fixed an issue where a response with status code 404 led to an endless loop of implicit rerouting in dev mode.
Patch Changes
-
#8591
863f5171eThanks @rishi-raj-jain! - add site url to the location of redirect -
#8633
63141f3f3Thanks @Princesseuh! - Fix build not working when having multiple images in the same Markdown file -
#8636
974d5117aThanks @martrapp! - fix: no deletion of scripts during view transition -
#8645
cb838b84bThanks @matthewp! - Fix getDataEntryById to lookup by basename -
#8640
f36c4295bThanks @matthewp! - Warn on empty content collections -
#8615
4c4ad9d16Thanks @alexanderniebuhr! - Improve the logging of assets for adapters that do not support image optimization
Patch Changes
-
#8612
bcad715ceThanks @matthewp! - Ensure cookies are attached when middleware changes the Response -
#8598
bdd267d08Thanks @Princesseuh! - Fix relative images in Markdown breaking the build process in certain circumstances -
#8382
e522a5eb4Thanks @DerTimonius! - Do not throw an error for an empty collection directory. -
#8600
ed54d4644Thanks @FredKSchott! - Improve config info telemetry -
#8592
70f2a8003Thanks @bluwy! - Fix alias plugin causing CSS ordering issue -
#8614
4398e9298Thanks @lilnasy! - Fixed an issue where spaces and unicode characters in project path prevented middleware from running. -
#8603
8f8b9069dThanks @matthewp! - Prevent body scripts from re-executing on navigation -
#8609
5a988eaf6Thanks @bluwy! - Fix Astro HMR from a CSS dependency -
Updated dependencies [
ed54d4644]:- @astrojs/telemetry@3.0.2
Patch Changes
-
#8580
8d361169bThanks @rishi-raj-jain! - add hide to style & script generated for island -
#8568
95b5f6280Thanks @Princesseuh! - Fix small types issues related toastro:assets's AVIF support andgetImage -
#8579
0586e20e8Thanks @rishi-raj-jain! - show redirect symbol as of the page
Minor Changes
-
#8467
ecc65abbfThanks @Princesseuh! - Add a newimage.endpointsetting to allow using a custom endpoint in dev and SSR -
#8518
2c4fc878bThanks @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
c92e0acd7Thanks @Princesseuh! - Add types for the object syntax forstyle(ex:style={{color: 'red'}})
Patch Changes
-
#8532
7522bb491Thanks @bluwy! - Improve markdown rendering performance by sharing processor instance -
#8537
f95febf96Thanks @martrapp! - bugfix checking media-type in client-side router -
#8536
b85c8a78aThanks @Princesseuh! - Improved error messages aroundastro:assets -
#7607
45364c345Thanks @FineWolf! - AddCollectionKey,ContentCollectionKey, andDataCollectionKeyexports toastro:content -
Updated dependencies [
d93987824,7522bb491]:- @astrojs/markdown-remark@3.2.0
Patch Changes
-
#8484
78b82bb39Thanks @bb010g! - fix(astro): add support forsrc/content/config.mtsfiles -
#8504
5e1099f68Thanks @ematipico! - Minify the HTML of the redicts emitted during the build. -
#8480
644825845Thanks @yamanoku! - Do not add type="text/css" to inline style tag -
#8472
fa77fa63dThanks @matthewp! - Prevent client:only styles from being removed in dev (View Transitions) -
#8506
23f9536deThanks @mascii! - chore: correct description ofattributeoption inscopedStyleStrategy -
#8505
2db9762ebThanks @martrapp! - Restore horizontal scroll position on history navigation (view transitions) -
#8461
435b10549Thanks @rdwz! - Fix lang unspecified code blocks (markdownlint MD040) -
#8492
a6a516d94Thanks @xiBread! - fix(types): makeimage.serviceoptional -
#8522
43bc5f2a5Thanks @martrapp! - let view transitions handle same origin redirects -
#8491
0ca332ba4Thanks @martrapp! - Bugfixes for back navigation in the view transition client-side router
Patch Changes
-
#8437
b3cf1b327Thanks @Princesseuh! - Fix imports of images with uppercased file extensions not working -
#8440
b92d066b7Thanks @natemoo-re! - Fix issue whererenderToFinalDestinationwould throw in internal Astro code
Patch Changes
-
#8351
7d95bd9baThanks @lilnasy! - Fixed a case where dynamic imports tried to preload inlined stylesheets. -
#8353
1947ef7a9Thanks @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
61ad70fdcThanks @itsmatteomanf! - Fixes remote assets caching logic to not use expired assets -
#8306
d2f2a11cdThanks @jacobthesheep! - Support detecting Bun when logging messages with package manager information. -
#8414
5126c6a40Thanks @Princesseuh! - Fix missing type forimageConfigexport fromastro:assets -
#8416
48ff7855bThanks @Princesseuh! - Installing will no longer fail when Sharp can't be installed -
#8332
8935b3b46Thanks @martrapp! - Fix scroll position when navigating back from page w/o ViewTransitions
Patch Changes
-
#8388
362491b8dThanks @natemoo-re! - Properly handleBEFORE_HYDRATION_SCRIPTgeneration, fixing MIME type error on hydration. -
#8370
06e7256b5Thanks @itsmatteomanf! - Removed extra curly brace.
Patch Changes
-
#8366
c5633434fThanks @natemoo-re! - UpdatechunkFileNamesto avoid emitting invalid characters -
#8367
405ad9501Thanks @Princesseuh! - Fixtsccomplaining about imports of.astrofiles in specific cases -
#8357
6b1e79814Thanks @itsmatteomanf! - Added counter to show progress for assets image generation. Fixed small unit of measurement error. -
Updated dependencies [
0ce0720c7]:- @astrojs/telemetry@3.0.1
Patch Changes
-
#8327
5f3a44aeeThanks @natemoo-re! - Improveastro infocommand formatting, allow users to copy info automatically -
#8320
b21038c19Thanks @ematipico! - Exclude redirects from split entry points -
#8331
7a894eec3Thanks @matthewp! - Prevent View Transition fallback from waiting on looping animations -
#8231
af41b03d0Thanks @justinbeaty! - Fixes scroll behavior when using View Transitions by enablingmanualscroll restoration
Patch Changes
-
#8324
0752cf368Thanks @matthewp! - Prevent React hook call warnings when used with MDXWhen 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.
Patch Changes
- #8300
d4a6ab733Thanks @ematipico! - Correctly retrive middleware when using it in SSR enviroments.
Patch Changes
- #8293
d9bd7cf5cThanks @Princesseuh! - Fixtscerrors insideastro/components/index.ts
Patch Changes
-
#8290
ef37f9e29Thanks @matthewp! - Remove "experimental" text from the image config options, for docs and editor etc. text displayed. -
#8290
ef37f9e29Thanks @matthewp! - Prevent astro check cache issuesastro checkhits cache issues in 3.0 causing it never to work on the first try. -
#8283
c32f52a62Thanks @ematipico! - Add useful warning when deprecated options are still used.
Major Changes
-
#8188
d0679a666Thanks @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
364d861bdThanks @ematipico! - Removed automatic flattening ofgetStaticPathsresult..flatMapand.flatshould now be used to ensure that you're returning a flat array. -
#8113
2484dc408Thanks @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
81545197aThanks @natemoo-re! - Fixes for theclass:listdirective- Previously,
class:listwould ocassionally not be merged theclassprop when passed to Astro components. Now,class:listis always converted to aclassprop (as a string value). - Previously,
class:listdiverged fromclsxin a few edge cases. Now,class:listusesclsxdirectly.class:listused to deduplicate matching values, but it no longer doesclass:listused to sort individual values, but it no longer doesclass:listused to supportSetand other iterables, but it no longer does
- Previously,
-
#8179
6011d52d3Thanks @matthewp! - Astro 3.0 Release Candidate -
#8188
80f1494cdThanks @ematipico! - Thebuild.splitandbuild.excludeMiddlewareconfiguration options are deprecated and have been replaced by options in the adapter config.If your config includes the
build.excludeMiddlewareoption, replace it withedgeMiddlewarein 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.splitoption, replace it withfunctionPerRoutein 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
e45f30293Thanks @natemoo-re! - Change the View Transition built-in animation options.The
transition:animatevaluemorphhas been renamed toinitial. Also, this is no longer the default animation.If no
transition:animatedirective is specified, your animations will now default tofade.Astro also supports a new
transition:animatevalue,none. This value can be used on a page's<html>element to disable animated full-page transitions on an entire page. -
#8188
c0de7a7b0Thanks @ematipico! - Sharp is now the default image service used forastro: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
3c3100851Thanks @ematipico! - Remove support forAstro.__renderMarkdownwhich 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
34cb20021Thanks @bluwy! - Remove backwards-compatible kebab-case transform for camelCase CSS variable names passed to thestyleattribute. 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
be6bbd2c8Thanks @bluwy! - Remove deprecated config option types, deprecated script/style attributes, and deprecatedimageexport fromastro:content -
#8188
7511a4980Thanks @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 ofastro:assetssuch as enforcingalt, no CLS etc to users -
#7979
dbc97b121Thanks @bluwy! - Export experimentaldev,build,preview, andsyncAPIs fromastro. 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
7d2f311d4Thanks @ematipico! - Removed support for old syntax of the API routes. -
#8085
68efd4a8bThanks @bluwy! - Remove exports forastro/internal/*andastro/runtime/server/*in favour ofastro/runtime/*. Add newastro/compiler-runtimeexport 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
7bd1b86f8Thanks @ematipico! - Implements a new scope style strategy called"attribute". When enabled, styles are applied usingdata-*attributes.The default value of
scopedStyleStrategyis"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
519a1c4e8Thanks @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
includeandexcludeconfig 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 theincludeandexcludeoptions.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
5208a3c8fThanks @natemoo-re! - Removed duplicateastro/dist/jsxexport. Please use theastro/jsxexport instead -
#8188
84af8ed9dThanks @ematipico! - Remove MDX plugin re-ordering hack -
#8180
f003e7364Thanks @ematipico! - The scoped hash created by the Astro compiler is now lowercase. -
#7878
0f637c71eThanks @bluwy! - The value ofimport.meta.env.BASE_URL, which is derived from thebaseoption, will no longer have a trailing slash added by default or whentrailingSlash: "ignore"is set. The existing behavior ofbasein combination withtrailingSlash: "always"ortrailingSlash: "never"is unchanged.If your
basealready has a trailing slash, no change is needed.If your
basedoes not have a trailing slash, add one to preserve the previous behaviour:// astro.config.mjs - base: 'my-base', + base: 'my-base/', -
#8118
8a5b0c1f3Thanks @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.inlineStylesheetsconfiguration. 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 intoTo go back to the previous default behavior, change
build.inlineStylesheetsto "never".import { defineConfig } from 'astro/config'; export default defineConfig({ build: { inlineStylesheets: 'never', }, }); -
#8188
148e61d24Thanks @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
e79e3779dThanks @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
96beb883aThanks @ematipico! - Updatetsconfig.jsonpresets withmoduleResolution: '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
997a0db8aThanks @ematipico! - Theastro checkcommand now requires an external package@astrojs/checkand an install oftypescriptin your project. This was done in order to make the mainastropackage smaller and give more flexibility to users in regard to the version of TypeScript they use. -
#8188
80f1494cdThanks @ematipico! - Thebuild.splitandbuild.excludeMiddlewareconfiguration options are deprecated and have been replaced by options in the adapter config.If your config includes the
build.excludeMiddlewareoption, replace it withedgeMiddlewarein 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.splitoption, replace it withfunctionPerRoutein 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
0f0625504Thanks @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
e1ae56e72Thanks @ematipico! - Astro.cookies.get(key) returns undefined if cookie doesn't existWith this change, Astro.cookies.get(key) no longer always returns a
AstroCookieobject. Instead it now returnsundefinedif the cookie does not exist.You should update your code if you assume that all calls to
get()return a value. When using withhas()you still need to assert the value, like so:--- if (Astro.cookies.has(id)) { const id = Astro.cookies.get(id)!; } --- -
#8188
f32d093a2Thanks @ematipico! - The propertycompressHTMLis nowtrueby default. Setting this value totrueis no longer required.If you do not want to minify your HTML output, you must set this value to
falseinastro.config.mjs.import {defineConfig} from "astro/config"; export default defineConfig({ + compressHTML: false }) -
#8188
f01eb585eThanks @ematipico! - Astro's default port when running the dev or preview server is now4321.This will reduce conflicts with ports used by other tools.
-
#7921
b76c166bdThanks @Princesseuh! -astro:assetsis now enabled by default. If you were previously using theexperimental.assetsflag, please remove it from your config. Also note that the previous@astrojs/imageintegration is incompatible, and must be removed.This also brings two important changes to using images in Astro:
- New ESM shape: importing an image will now return an object with different properties describing the image such as its path, format and dimensions. This is a breaking change and may require you to update your existing images.
- In Markdown, MDX, and Markdoc, the
![]()syntax will now resolve relative images located anywhere in your project in addition to remote images and images stored in thepublic/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
32669cd47Thanks @ematipico! - Remove MDX specialcomponentsexport handling
Minor Changes
-
#8188
cd2d7e769Thanks @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
44f7a2872Thanks @matthewp! - View Transitions unflaggedView 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
ea7ff5177Thanks @matthewp! -astro:namespace aliases for middleware and componentsThis adds aliases of
astro:middlewareandastro:componentsfor 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
036388f66Thanks @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
a8f35777eThanks @matthewp! - Finalize View Transition event names -
#8012
866ed4098Thanks @ematipico! - Add a newastro/errorsmodule. Developers can importAstroUserError, and provide amessageand an optionalhint
Patch Changes
-
#8139
db39206cbThanks @Princesseuh! - Useundicifor File changeset for Node 16 compatibility -
#8188
adf9fccfdThanks @ematipico! - Do not throw Error when users pass an object with a "type" property -
#8234
0c7b42dc6Thanks @natemoo-re! - Update telemetry notice -
#8251
46c4c0e05Thanks @Princesseuh! - Adds a link to the error reference in the CLI when an error occurs -
#8128
c2c71d90cThanks @Princesseuh! - Update error message when Sharp couldn't be found (tends to happen on pnpm notably) -
#7998
65c354969Thanks @bluwy! - Callastro synconce before callingastro check -
#8232
a824863abThanks @matthewp! - Use .js to import logger -
#8253
1048aca55Thanks @matthewp! - Fix, lazily initialize ResponseWithEncoding -
#8263
9e021a91cThanks @Princesseuh! - Add a type param to AstroGlobal to type params. This will eventually be used automatically by our tooling to provide typing and completions forAstro.params -
#8217
c37632a20Thanks @martrapp! - Specifydata-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
acf652fc1Thanks @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
42785c7b7Thanks @ematipico! - Improve fidelity of time stats when runningastro build -
#8266
8450379dbThanks @Princesseuh! - Fiximage.servicerequiring to be set manually whenimage.domainsorimage.remotePatternswas assigned a value -
#8078
2540feedbThanks @alexanderniebuhr! - Reimplement https://github.com/withastro/astro/pull/7509 to correctly emit pre-rendered pages now thatbuild.splitis deprecated and this configuration has been moved tofunctionPerRouteinside the adapter. -
#8264
1f58a7a1bThanks @natemoo-re! - Fireastro:unmountevent when island is disconnected -
#8188
2ae9d37f0Thanks @ematipico! - Open to configuredbasewhenastro dev --openruns -
#8188
70f34f5a3Thanks @ematipico! - Remove StreamingCompatibleResponse polyfill -
#8229
ffc9e2d3dThanks @Princesseuh! - Paginate will now return exact types instead of a naive Record -
#8099
732111cdcThanks @bluwy! - Deprecate themarkdown.draftsconfiguration 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: truefrontmatter property instead. -
#8188
33b8910cfThanks @ematipico! - On back navigation only animate view transitions that were animated going forward. -
#8196
632579dc2Thanks @bluwy! - Prevent bundling sharp as it errors in runtime -
#8237
3674584e0Thanks @Princesseuh! - Fixastro checknot finding the@astrojs/checkpackage -
#8258
1db4e92c1Thanks @matthewp! - Allow fallback animations on html element -
#8270
e7f872e91Thanks @matthewp! - Prevent ViewTransition script from being added by mistake -
#8271
16f09dfffThanks @matthewp! - Fix video persistence regression -
#8072
4477bb41cThanks @matthewp! - Update Astro types to reflect that compress defaults to true -
#8214
55c10d1d5Thanks @Princesseuh! - Automatically update user's env.d.ts with the proper types to help out migrating away from assets being experimental -
#8130
3e834293dThanks @Princesseuh! - Add some polyfills for Stackblitz until they support Node 18. Running Astro on Node 16 is still not officially supported, however. -
#8188
a87cbe400Thanks @ematipico! - fix: reinsert attribute to specify direction of ViewTransition (forward / back) -
#8132
767eb6866Thanks @bluwy! - Deprecate returning simple objects from endpoints. Endpoints should only return aResponse.To return a result with a custom encoding not supported by a
Response, you can use theResponseWithEncodingutility 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]:- @astrojs/telemetry@3.0.0
- @astrojs/internal-helpers@0.2.0
- @astrojs/markdown-remark@3.0.0
Patch Changes
-
#8234
0c7b42dc6Thanks @natemoo-re! - Update telemetry notice -
#8263
9e021a91cThanks @Princesseuh! - Add a type param to AstroGlobal to type params. This will eventually be used automatically by our tooling to provide typing and completions forAstro.params -
#8264
1f58a7a1bThanks @natemoo-re! - Fireastro:unmountevent when island is disconnected -
#8258
1db4e92c1Thanks @matthewp! - Allow fallback animations on html element -
Updated dependencies [
0c7b42dc6]:- @astrojs/telemetry@3.0.0-rc.4
Patch Changes
-
#8251
46c4c0e05Thanks @Princesseuh! - Adds a link to the error reference in the CLI when an error occurs -
#8253
1048aca55Thanks @matthewp! - Fix, lazily initialize ResponseWithEncoding -
#8229
ffc9e2d3dThanks @Princesseuh! - Paginate will now return exact types instead of a naive Record -
#8237
3674584e0Thanks @Princesseuh! - Fixastro checknot finding the@astrojs/checkpackage
Major Changes
-
#8207
e45f30293Thanks @natemoo-re! - Change the View Transition built-in animation options.The
transition:animatevaluemorphhas been renamed toinitial. Also, this is no longer the default animation.If no
transition:animatedirective is specified, your animations will now default tofade.Astro also supports a new
transition:animatevalue,none. This value can be used on a page's<html>element to disable animated full-page transitions on an entire page.
Minor Changes
-
#8218
44f7a2872Thanks @matthewp! - View Transitions unflaggedView 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
a8f35777eThanks @matthewp! - Finalize View Transition event names
Patch Changes
-
#8217
c37632a20Thanks @martrapp! - Specifydata-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
acf652fc1Thanks @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
632579dc2Thanks @bluwy! - Prevent bundling sharp as it errors in runtime -
#8214
55c10d1d5Thanks @Princesseuh! - Automatically update user's env.d.ts with the proper types to help out migrating away from assets being experimental
Major Changes
-
#8142
81545197aThanks @natemoo-re! - Fixes for theclass:listdirective- Previously,
class:listwould ocassionally not be merged theclassprop when passed to Astro components. Now,class:listis always converted to aclassprop (as a string value). - Previously,
class:listdiverged fromclsxin a few edge cases. Now,class:listusesclsxdirectly.class:listused to deduplicate matching values, but it no longer doesclass:listused to sort individual values, but it no longer doesclass:listused to supportSetand other iterables, but it no longer does
- Previously,
-
#8179
6011d52d3Thanks @matthewp! - Astro 3.0 Release Candidate -
#8170
be6bbd2c8Thanks @bluwy! - Remove deprecated config option types, deprecated script/style attributes, and deprecatedimageexport fromastro:content -
#8180
f003e7364Thanks @ematipico! - The scoped hash created by the Astro compiler is now lowercase. -
#8169
e79e3779dThanks @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
Patch Changes
-
#8147
adf9fccfdThanks @astrobot-houston! - Do not throw Error when users pass an object with a "type" property -
#8152
582132328Thanks @andremralves! - Displays a new config error ifoutDiris placed withinpublicDir. -
#8147
42785c7b7Thanks @astrobot-houston! - Improve fidelity of time stats when runningastro build -
#8171
95120efbeThanks @Princesseuh! - Fix missing type forimageConfigexport fromastro:assets -
#8147
2ae9d37f0Thanks @astrobot-houston! - Open to configuredbasewhenastro dev --openruns -
#8099
732111cdcThanks @bluwy! - Deprecate themarkdown.draftsconfiguration 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: truefrontmatter property instead. -
#8147
33b8910cfThanks @astrobot-houston! - On back navigation only animate view transitions that were animated going forward. -
#8163
179796405Thanks @delucis! - Make typing ofdefineCollectionmore permissive to support advanced union and intersection types -
#8147
a87cbe400Thanks @astrobot-houston! - fix: reinsert attribute to specify direction of ViewTransition (forward / back) -
#8132
767eb6866Thanks @bluwy! - Deprecate returning simple objects from endpoints. Endpoints should only return aResponse.To return a result with a custom encoding not supported by a
Response, you can use theResponseWithEncodingutility class instead.Before:
export function GET() { return { body: '...', encoding: 'binary', }; }After:
export function GET({ ResponseWithEncoding }) { return new ResponseWithEncoding('...', undefined, 'binary'); } -
Updated dependencies [
6011d52d3,e79e3779d]:- @astrojs/markdown-remark@3.0.0-rc.1
- @astrojs/telemetry@3.0.0-rc.3
- @astrojs/internal-helpers@0.2.0-rc.2
Patch Changes
- #8139
db39206cbThanks @Princesseuh! - Useundicifor File changeset for Node 16 compatibility
Major Changes
-
#8113
2484dc408Thanks @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
dbc97b121Thanks @bluwy! - Export experimentaldev,build,preview, andsyncAPIs fromastro. 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
68efd4a8bThanks @bluwy! - Remove exports forastro/internal/*andastro/runtime/server/*in favour ofastro/runtime/*. Add newastro/compiler-runtimeexport 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
5208a3c8fThanks @natemoo-re! - Removed duplicateastro/dist/jsxexport. Please use theastro/jsxexport instead -
#8118
8a5b0c1f3Thanks @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.inlineStylesheetsconfiguration. 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 intoTo go back to the previous default behavior, change
build.inlineStylesheetsto "never".import { defineConfig } from 'astro/config'; export default defineConfig({ build: { inlineStylesheets: 'never', }, }); -
#7921
b76c166bdThanks @Princesseuh! -astro:assetsis now enabled by default. If you were previously using theexperimental.assetsflag, please remove it from your config. Also note that the previous@astrojs/imageintegration is incompatible, and must be removed.This also brings two important changes to using images in Astro:
- New ESM shape: importing an image will now return an object with different properties describing the image such as its path, format and dimensions. This is a breaking change and may require you to update your existing images.
- In Markdown, MDX, and Markdoc, the
![]()syntax will now resolve relative images located anywhere in your project in addition to remote images and images stored in thepublic/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.
Minor Changes
-
#8101
ea7ff5177Thanks @matthewp! -astro:namespace aliases for middleware and componentsThis adds aliases of
astro:middlewareandastro:componentsfor 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.
Patch Changes
-
#8128
c2c71d90cThanks @Princesseuh! - Update error message when Sharp couldn't be found (tends to happen on pnpm notably) -
#8092
7177f7579Thanks @natemoo-re! - Ensure dotfiles are cleaned during static builds -
#8070
097a8e4e9Thanks @lilnasy! - Fix a handful of edge cases with prerendered 404/500 pages -
#8078
2540feedbThanks @alexanderniebuhr! - Reimplement https://github.com/withastro/astro/pull/7509 to correctly emit pre-rendered pages now thatbuild.splitis deprecated and this configuration has been moved tofunctionPerRouteinside the adapter. -
#8105
0e0fa605dThanks @martrapp! - ViewTransition: bug fix for lost scroll position in browser history -
#7778
d6b494376Thanks @y-nk! - Added support for optimizing remote images from authorized sources when usingastro: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.buildto 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
4477bb41cThanks @matthewp! - Update Astro types to reflect that compress defaults to true -
#8130
3e834293dThanks @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]:- @astrojs/telemetry@3.0.0-beta.2
Patch Changes
- Updated dependencies [
2aa6d8ace]:- @astrojs/internal-helpers@0.2.0-beta.1
Major Changes
-
#7952
3c3100851Thanks @astrobot-houston! - Remove support forAstro.__renderMarkdownwhich 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
34cb20021Thanks @bluwy! - Remove backwards-compatible kebab-case transform for camelCase CSS variable names passed to thestyleattribute. 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
7bd1b86f8Thanks @ematipico! - Implements a new scope style strategy called"attribute". When enabled, styles are applied usingdata-*attributes.The default value of
scopedStyleStrategyis"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
519a1c4e8Thanks @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
includeandexcludeconfig 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 theincludeandexcludeoptions.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
0f637c71eThanks @bluwy! - The value ofimport.meta.env.BASE_URL, which is derived from thebaseoption, will no longer have a trailing slash added by default or whentrailingSlash: "ignore"is set. The existing behavior ofbasein combination withtrailingSlash: "always"ortrailingSlash: "never"is unchanged.If your
basealready has a trailing slash, no change is needed.If your
basedoes not have a trailing slash, add one to preserve the previous behaviour:// astro.config.mjs - base: 'my-base', + base: 'my-base/',
Minor Changes
- #8012
866ed4098Thanks @ematipico! - Add a newastro/errorsmodule. Developers can importAstroUserError, and provide amessageand an optionalhint
Patch Changes
-
#7998
65c354969Thanks @bluwy! - Callastro synconce before callingastro check -
#7952
70f34f5a3Thanks @astrobot-houston! - Remove StreamingCompatibleResponse polyfill -
#8011
5b1e39ef6Thanks @bluwy! - Move hoisted script analysis optimization behind theexperimental.optimizeHoistedScriptoption -
Updated dependencies [
b675acb2a]:- @astrojs/telemetry@3.0.0-beta.1
Major Changes
-
1eae2e3f7Thanks @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. -
76ddef19cThanks @Princesseuh! - Removed automatic flattening ofgetStaticPathsresult..flatMapand.flatshould now be used to ensure that you're returning a flat array. -
3fdf509b2Thanks @ematipico! - Thebuild.splitandbuild.excludeMiddlewareconfiguration options are deprecated and have been replaced by options in the adapter config.If your config includes the
build.excludeMiddlewareoption, replace it withedgeMiddlewarein 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.splitoption, replace it withfunctionPerRoutein your adapter options:import { defineConfig } from "astro/config"; import netlify from "@astrojs/netlify/functions"; export default defineConfig({ build: { - split: true }, adapter: netlify({ + functionPerRoute: true }), }); -
2f951cd40Thanks @Princesseuh! - Sharp is now the default image service used forastro: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.
-
c022a4217Thanks @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 ofastro:assetssuch as enforcingalt, no CLS etc to users -
67becaa58Thanks @ematipico! - Removed support for old syntax of the API routes. -
dfc2d93e3Thanks @bluwy! - Remove MDX plugin re-ordering hack -
3dc1ca2faThanks @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. -
1be84dfeeThanks @Princesseuh! - Updatetsconfig.jsonpresets withmoduleResolution: '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 -
35f01df79Thanks @Princesseuh! - Theastro checkcommand now requires an external package@astrojs/checkand an install oftypescriptin your project. This was done in order to make the mainastropackage smaller and give more flexibility to users in regard to the version of TypeScript they use. -
3fdf509b2Thanks @ematipico! - Thebuild.splitandbuild.excludeMiddlewareconfiguration options are deprecated and have been replaced by options in the adapter config.If your config includes the
build.excludeMiddlewareoption, replace it withedgeMiddlewarein 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.splitoption, replace it withfunctionPerRoutein your adapter options:import { defineConfig } from "astro/config"; import vercel from "@astrojs/vercel/serverless"; export default defineConfig({ build: { - split: true }, adapter: vercel({ + functionPerRoute: true }), }); -
78de801f2Thanks @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" })); } -
59d6e569fThanks @matthewp! - Astro.cookies.get(key) returns undefined if cookie doesn't existWith this change, Astro.cookies.get(key) no longer always returns a
AstroCookieobject. Instead it now returnsundefinedif the cookie does not exist.You should update your code if you assume that all calls to
get()return a value. When using withhas()you still need to assert the value, like so:--- if (Astro.cookies.has(id)) { const id = Astro.cookies.get(id)!; } --- -
7723c4cc9Thanks @ematipico! - The propertycompressHTMLis nowtrueby default. Setting this value totrueis no longer required.If you do not want to minify your HTML output, you must set this value to
falseinastro.config.mjs.import {defineConfig} from "astro/config"; export default defineConfig({ + compressHTML: false }) -
fb5cd6b56Thanks @ematipico! - Astro's default port when running the dev or preview server is now4321.This will reduce conflicts with ports used by other tools.
-
631b9c410Thanks @bluwy! - Remove MDX specialcomponentsexport handling
Minor Changes
-
9b4f70a62Thanks @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, }, }, }; } -
bc37331d8Thanks @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...'); }, }, }; }
Patch Changes
- Updated dependencies [
1eae2e3f7]:- @astrojs/telemetry@3.0.0-beta.0
- @astrojs/internal-helpers@0.2.0-beta.0
- @astrojs/markdown-remark@3.0.0-beta.0
Patch Changes
-
#8152
582132328Thanks @andremralves! - Displays a new config error ifoutDiris placed withinpublicDir. -
#8166
fddd4dc71Thanks @martrapp! - ViewTransitions: Fixes in the client-side router -
#8182
cfc465ddeThanks @martrapp! - View Transitions: self link (href="") does not trigger page reload -
#8171
95120efbeThanks @Princesseuh! - Fix missing type forimageConfigexport fromastro:assets -
#8187
273335cb0Thanks @bluwy! - Fix Astro components parent-child render order -
#8184
9142178b1Thanks @martrapp! - Fix: The scrolling behavior of ViewTransitions is now more similar to the expected browser behavior -
#8163
179796405Thanks @delucis! - Make typing ofdefineCollectionmore permissive to support advanced union and intersection types
Patch Changes
- #8136
97c8760d7Thanks @andremralves! - Fix 404 response leading to an infinite loop when there is no 404 page.
Patch Changes
-
#8127
b12c8471fThanks @natemoo-re! - Do not throw Error when users pass an object with a "type" property -
#8092
7177f7579Thanks @natemoo-re! - Ensure dotfiles are cleaned during static builds -
#8122
fa6b68a77Thanks @natemoo-re! - Improve fidelity of time stats when runningastro build -
#8070
097a8e4e9Thanks @lilnasy! - Fix a handful of edge cases with prerendered 404/500 pages -
#8123
1f6497c33Thanks @natemoo-re! - Open to configuredbasewhenastro dev --openruns -
#8105
0e0fa605dThanks @martrapp! - ViewTransition: bug fix for lost scroll position in browser history -
#8116
b290f0a99Thanks @martrapp! - On back navigation only animate view transitions that were animated going forward. -
#7778
d6b494376Thanks @y-nk! - Added support for optimizing remote images from authorized sources when usingastro: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.buildto 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' }], }, }); -
#8109
da6e3da1cThanks @martrapp! - fix: reinsert attribute to specify direction of ViewTransition (forward / back)
Patch Changes
-
#7702
c19987df0Thanks @shishkin! - Fix AstroConfigSchema type export -
#8084
560e45924Thanks @hbgl! - Stream request body instead of buffering it in memory. -
#8066
afc45af20Thanks @Princesseuh! - Add support for non-awaited imports to the Image component andgetImage -
#7866
d1f7143f9Thanks @43081j! - Add second type argument to the AstroGlobal type to type Astro.self. This change will ultimately allow our editor tooling to provide props completions and intellisense for<Astro.self /> -
#8032
3e46634fdThanks @natemoo-re! -astro addnow passes down--save-prod,--save-dev,--save-exact, and--no-saveflags for installation -
#8035
a12027b6aThanks @fyndor! - Removed extra double quotes from computed style in shiki code component
Patch Changes
-
#8027
1b8d30209Thanks @natemoo-re! - Ensure dev server restarts respect whenbaseis removed -
#8033
405913cdfThanks @matthewp! - Prevent script re-evaluation on page transition -
#8036
87d4b1843Thanks @ematipico! - Fix a bug where the middleware entry point was passed to integrations even though the configurationbuild.excludeMiddlewarewas set tofalse. -
#8022
c23377caaThanks @bluwy! - Always return a new array instance fromgetCollectionin prod -
#8013
86bee2812Thanks @martrapp! - Links with hash marks now trigger view transitions if they lead to a different page. Links to the same page do not trigger view transitions.
Patch Changes
Patch Changes
- #7986
8e5a27b48Thanks @natemoo-re! - Ensure injectRoute is properly handled inbuildas well asdev
Patch Changes
-
#7945
a00cfb894Thanks @matthewp! - Fix race condition when performing swap for fallback -
#7983
6cd7290d2Thanks @natemoo-re! - Fix filename generation for.astropages -
#7946
9d0070095Thanks @andremralves! - Fix: missing CSS import when 404 server Response redirects to a custom 404 page. -
#7977
a4a637c8fThanks @bluwy! - Fix inline root resolve logic -
#7943
c2682a17cThanks @natemoo-re! - Ensure that injected routes fromnode_modulesare properly detected
Patch Changes
Minor Changes
-
#7861
41afb8405Thanks @matthewp! - Persistent DOM and Islands in Experimental View TransitionsWith
viewTransitions: trueenabled in your Astro config's experimental section, pages using the<ViewTransition />routing component can now access a newtransition:persistdirective.With this directive, you can keep the state of DOM elements and islands on the old page when transitioning to the new page.
For example, to keep a video playing across page navigation, add
transition:persistto the element:<video controls="" autoplay="" transition:persist> <source src="https://ia804502.us.archive.org/33/items/GoldenGa1939_3/GoldenGa1939_3_512kb.mp4" type="video/mp4" /> </video>This
<video>element, with its current state, will be moved over to the next page (if the video also exists on that page).Likewise, this feature works with any client-side framework component island. In this example, a counter's state is preserved and moved to the new page:
<Counter count={5} client:load transition:persist />See our View Transitions Guide to learn more on usage.
Patch Changes
-
#7821
c00b6f0c4Thanks @ottomated! - Fixes an issue that prevents importing'astro/app' -
#7917
1f0ee494aThanks @bluwy! - Prevent integration hooks from re-triggering if the server restarts on config change, but the config fails to load. -
#7901
00cb28f49Thanks @bluwy! - Improve sourcemap generation and performance -
#7911
c264be349Thanks @martrapp! - fix for #7882 by setting state in page navigation (view transitions) -
#7909
e1e958a75Thanks @tonydangblog! - Fix: ignore.jsonfiles nested in subdirectories within content collection directories starting with an_underscore.
Patch Changes
-
#7754
298dbb89fThanks @natemoo-re! - Refactor404and500route handling for consistency and improved prerendering support -
#7885
9e2203847Thanks @andremralves! - Fix incorrect build path logging for 404.astro pages. -
#7887
5c5da8d2fThanks @ffxsam! - Add logging for when JSON.parse fails within hydrate func -
#7895
0b8375fe8Thanks @bluwy! - Fix streaming Astro components -
#7876
89d015db6Thanks @ematipico! - Check forgetStaticPathsonly if the file has the.astroextension. -
#7879
ebf7ebbf7Thanks @bluwy! - Refactor and improve Astro config loading flow
Patch Changes
Patch Changes
-
#7826
31c4031baThanks @Princesseuh! - Fixastro:assetsnot working on Windows in build when using Squoosh -
#7823
5161cf919Thanks @matthewp! - Adds anastro:beforeloadevent for the dark mode use-case -
#7836
59b556232Thanks @matthewp! - Upgrade compiler to bring in Image view transition support -
#7824
267487e63Thanks @matthewp! - Prevent navigation on hash change -
#7829
b063a2d8aThanks @Princesseuh! - Fixastro:assetsendpoint not working in dev and SSR ifexperimental.assetswas enabled by an integration (such as Starlight) -
#7734
d5f526b33Thanks @Princesseuh! - Fix some global state related toastro:assetsnot getting cleaned out properly in SSR with no pre-rendered pages -
#7843
7dbcbc86bThanks @matthewp! - Fixes head propagation regression
Patch Changes
-
#7782
0f677c009Thanks @bluwy! - Refactor Astro rendering to write results directly. This improves the rendering performance for all Astro files. -
#7786
188eeddd4Thanks @matthewp! - Execute scripts when navigating to a new page.When navigating to an new page with client-side navigation, scripts are executed (and re-executed) so that any new scripts on the incoming page are run and the DOM can be updated.
However,
type=modulescripts never re-execute in Astro, and will not do so in client-side routing. To support cases where you want to modify the DOM, a newastro:loadevent listener been added:document.addEventListener('astro:load', () => { updateTheDOMSomehow(); });
Patch Changes
-
#7777
3567afac4Thanks @bluwy! - Fix rendering TextEncoder encoding error regression -
#7759
1792737daThanks @Princesseuh! - Fix SharedImageService's types not properly reflecting that image services hooks can be async -
#7766
da7f1128bThanks @Princesseuh! - Fix missingreferrerpolicyon ScriptHTMLAttributes -
#7746
0c9959704Thanks @birkskyum! - Update Vite to 4.4
Patch Changes
-
#7756
274e67532Thanks @matthewp! - Fixes case where there is FOUC caused by stylesheets not loaded -
#7742
e52852628Thanks @andersk! - Fix parsing image assets from a Markdown line along with other markup. -
#7757
c2d6cfd0cThanks @matthewp! - Prevent animations when prefers-reduced-motion -
#7750
201d32dcfThanks @matthewp! - Trigger full page refresh on back nav from page without VT enabled
Minor Changes
-
#7686
ec745d689Thanks @matthewp! - Redirects configurationThis change moves the
redirectsconfiguration out of experimental. If you were previously using experimental redirects, remove the following experimental flag:experimental: { redirects: true, }If you have been waiting for stabilization before using redirects, now you can do so. Check out the docs on redirects to learn how to use this built-in feature.
-
#7707
3a6e42e19Thanks @ottomated! - Improved hoisted script bundlingAstro's static analysis to determine which
<script>tags to bundle together just got a little smarter!Astro create bundles that optimize script usage between pages and place them in the head of the document so that they are downloaded as early as possible. One limitation to Astro's existing approach has been that you could not dynamically use hoisted scripts. Each page received the same, all-inclusive bundle whether or not every script was needed on that page.
Now, Astro has improved the static analysis to take into account the actual imports used.
For example, Astro would previously bundle the
<script>s from both the<Tab>and<Accordian>component for the following library that re-exports multiple components:@matthewp/my-astro-lib
export { default as Tabs } from './Tabs.astro'; export { default as Accordion } from './Accordion.astro';Now, when an Astro page only uses a single component, Astro will send only the necessary script to the page. A page that only imports the
<Accordian>component will not receive any<Tab>component's scripts:--- import { Accordion } from '@matthewp/my-astro-lib'; ---You should now see more efficient performance with Astro now supporting this common library re-export pattern.
-
#7511
6a12fcecbThanks @matthewp! - Built-in View Transitions Support (experimental)Astro now supports view transitions through the new
<ViewTransitions />component and thetransition:animate(and associated) directives. View transitions are a great fit for content-oriented sites, and we see it as the best path to get the benefits of client-side routing (smoother transitions) without sacrificing the more simple mental model of MPAs.Enable support for view transitions in Astro 2.9 by adding the experimental flag to your config:
import { defineConfig } from 'astro/config'; export default defineConfig({ experimental: { viewTransitions: true, }, });This enables you to use the new APIs added.
This is a component which acts as the router for transitions between pages. Add it to the
<head>section of each individual page where transitions should occur in the client as you navigate away to another page, instead of causing a full page browser refresh. To enable support throughout your entire app, add the component in some common layout or component that targets the<head>of every page.CommonHead.astro
--- import { ViewTransitions } from 'astro:transitions'; --- <meta charset="utf-8" /> <title>{Astro.props.title}</title> <ViewTransitions />With only this change, your app will now route completely in-client. You can then add transitions to individual elements using the
transition:animatedirective.Animations
Add
transition:animateto any element to use Astro's built-in animations.<header transition:animate="slide"></header>In the above, Astro's
slideanimation will cause the<header>element to slide out to the left, and then slide in from the right when you navigate away from the page.You can also customize these animations using any CSS animation properties, for example, by specifying a duration:
--- import { slide } from 'astro:transition'; --- <header transition:animate={slide({ duration: 200 })}></header>Continue learning
Check out the client-side routing docs to learn more.
Patch Changes
-
#7701
019b797bfThanks @bluwy! - Fix redirects map object-form value validation -
#7704
d78db48acThanks @bluwy! - Fix absolute path handling when passingroot,srcDir,publicDir,outDir,cacheDir,build.client, andbuild.serverconfigs in Windows -
#7713
d088351f5Thanks @natemoo-re! - Update warning whengetStaticPathsis detected but a route is not prerendered.
Patch Changes
-
#7711
72bbfac97Thanks @natemoo-re! - Fixstatuscode for custom404and500pages in the dev server -
#7693
d401866f9Thanks @natemoo-re! - Fix loading of/404.astropage when dynamic route returns 404 -
#7706
4f6b5ae2bThanks @Princesseuh! - Fix Markdoc integration not being able to importemitESMImagefrom Astro -
#7694
06c255716Thanks @natemoo-re! - Fix route matching behavior whengetStaticPathsresult includes hyphenated params
Patch Changes
-
#7680
cc8e9de88Thanks @ematipico! - Throw an error whenbuild.splitis set totruebutoutputisn't set to"server". -
#7679
1a6f833c4Thanks @bluwy! - Handle inlining non-string boolean environment variables -
#7691
cc0f81c04Thanks @Princesseuh! - Fix not being able to build on Vercel Edge whenastro:assetswas enabled even when using a non-Node image service
Patch Changes
-
#7637
af5827d4fThanks @Princesseuh! - Fixastro:assetsnot respecting EXIF rotation -
#7644
213e10991Thanks @matthewp! - Fix for allowing the root path / as a redirect -
#7644
213e10991Thanks @matthewp! - Fix static redirects prefered over dynamic regular routes -
#7643
4b82e55cfThanks @alvinometric! - Add support for using.svgfiles withastro:assets's base services. The SVGs will NOT be processed and will be return as-is, however, proper attributes, alt enforcement etc will all work correctly.
Patch Changes
-
#7611
904921cbeThanks @bluwy! - Ignore content .json files prefixed with underscores (regression) -
#7618
3669e2d27Thanks @ematipico! - Add a fallback label ifastro infocommand can't determine the package manager used. -
#7620
831dfd151Thanks @delucis! - Filter outastrofrom integration peer dependencies when runningastro add
Minor Changes
-
#7532
9e5fafa2bThanks @ematipico! - Theastro/middlewaremodule exports a new utility calledtrySerializeLocals.This utility can be used by adapters to validate their
localsbefore sending it to the Astro middleware.This function will throw a runtime error if the value passed is not serializable, so consumers will need to handle that error.
-
#7532
9e5fafa2bThanks @ematipico! - Astro exposes the middleware file path to the integrations in the hookastro:build:ssr// myIntegration.js import type { AstroIntegration } from 'astro'; function integration(): AstroIntegration { return { name: 'fancy-astro-integration', hooks: { 'astro:build:ssr': ({ middlewareEntryPoint }) => { if (middlewareEntryPoint) { // do some operations } }, }, }; }The
middlewareEntryPointis only defined if the user has created an Astro middleware. -
#7432
6e9c29579Thanks @ematipico! - Adds a new commandastro info, useful for sharing debugging information about your current environment when you need help!astro infoOutput
Astro version v2.6.6 Package manager pnpm Platform darwin Architecture arm64 Adapter @astrojs/vercel/serverless Integrations None -
#7532
9e5fafa2bThanks @ematipico! - Theastro/middlewaremodule exports a new API calledcreateContext.This a low-level API that adapters can use to create a context that can be consumed by middleware functions.
-
#7532
9e5fafa2bThanks @ematipico! - Introduced a new build option for SSR, calledbuild.excludeMiddleware.// astro.config.mjs import { defineConfig } from 'astro/config'; export default defineConfig({ build: { excludeMiddleware: true, }, });When enabled, the code that belongs to be middleware won't be imported by the final pages/entry points. The user is responsible for importing it and calling it manually.
Patch Changes
- #7532
9e5fafa2bThanks @ematipico! - Correctly track the middleware during the SSR build.
Patch Changes
-
#7527
9e2426f75Thanks @natemoo-re! - Default registry logic to fallback to NPM if registry command fails (sorry, Bun users!) -
#7542
cdc28326cThanks @natemoo-re! - Fix bug when usingdefine:varswith astyleobject -
#7521
19c2d43eaThanks @knpwrs! - AddPropsgeneric forAPIRoutetype -
#7531
2172dd4f0Thanks @wackbyte! - Fix serialization ofundefinedin framework component props -
#7539
1170877b5Thanks @jc1144096387! - Update registry logic, improving edge cases (http support, redirects, registries ending with '/')
Patch Changes
-
#7273
6dfd7081bThanks @bluwy! - Fix error stacktrace from Vite SSR runtime -
#7370
83016795eThanks @bluwy! - Simplify nested hydration flow -
#7488
d3247851fThanks @natemoo-re! - PasscompressHTMLsetting to server adapters -
#7494
2726098bcThanks @itsmatteomanf! - Replaces the instance ofsetTimeout()in the runtime to usequeueMicrotask(), to resolve limitations on Cloudflare Workers. -
#7509
f4fea3b02Thanks @ematipico! - Correctly emit pre-rendered pages whenbuild.splitis set totrue
Patch Changes
-
#7490
601403744Thanks @ematipico! - Fix the URL that belongs toentryPointsin the hookastro:build:ssr. The paths were created with the wrong output directory. -
#7459
869197aafThanks @bluwy! - Fix missing styles for Markdoc files in development -
#7476
478cd9d8fThanks @hirasso! - Allow astro to be installed underneath a folder with leading slashes -
#7479
57e603038Thanks @bluwy! - Handle esbuild 0.18 changes -
#7381
f359d77b1Thanks @matthewp! - Prevent accidental inclusion of page CSS in dev mode -
Updated dependencies [
2b7539952]:- @astrojs/internal-helpers@0.1.1
Minor Changes
-
#7353
76fcdb84dThanks @bholmesdev! - Remove legacy handling for MDX content collections. Ensure you are using@astrojs/mdxv0.18 or above. -
#7385
8e2923cc6Thanks @ematipico! -Astro.localsis now exposed to the adapter API. Node Adapter can now pass in alocalsobject in the SSR handler middleware. -
#7220
459b5bd05Thanks @ematipico! - Shipped a new SSR build configuration mode:split. When enabled, Astro will "split" the singleentry.mjsfile and instead emit a separate file to render each individual page during the build process.These files will be emitted inside
dist/pages, mirroring the directory structure of your page files insrc/pages/, for example:├── pages │ ├── blog │ │ ├── entry._slug_.astro.mjs │ │ └── entry.about.astro.mjs │ └── entry.index.astro.mjsTo enable, set
build.split: truein your Astro config:// src/astro.config.mjs export default defineConfig({ output: 'server', adapter: node({ mode: 'standalone', }), build: { split: true, }, });
Patch Changes
-
#7438
30bb36371Thanks @bluwy! - Fixastro:build:setuphookupdateConfigutility, where the configuration wasn't correctly updated when the hook was fired. -
#7436
3943fa390Thanks @kossidts! - Fix an issue related to the documentation. Destructure the argument of the function to customize the Astro dev server based on the command run. -
#7424
7877a06d8Thanks @bholmesdev! - Update internal types for more stable builds for Astro maintainers. -
#7427
e314a04bfThanks @ematipico! - Correctly emit the middleware code during the build phase. The file emitted is nowdist/middleware.mjs -
#7423
33cdc8622Thanks @bmenant! - Ensure injected/_imageendpoint for image optimization is not prerendered on hybrid output.
Patch Changes
-
#7341
491c2db42Thanks @bholmesdev! - Improve error message for unsupported Zod transforms from the content config. -
#7352
0a8d178c9Thanks @bholmesdev! - Raise error when multiple content collection entries have the same slug
Patch Changes
-
#7310
52f0480d1Thanks @Edo-San! - Fixed a bug that threw an Exception when spreading potentially undefined values as HTML attributes -
#7339
e3271f8c1Thanks @bholmesdev! - Add readable error message for invalid dynamic routes. -
#7316
e6bff651fThanks @bholmesdev! - Fix Zod errors getting flagged as configuration errors -
#7342
bbcf69e7bThanks @matthewp! - Fix for experimental redirects in dev mode -
#7326
1430ffb47Thanks @calebdwilliams! - Fixes issue where Astro doesn't respect custom npm registry settings during project creation
Patch Changes
- #7307
8034edd9eThanks @bholmesdev! - Fix [Object AsyncGenerator] appearing in markup for Markdoc documents
Minor Changes
-
#7067
57f8d14c0Thanks @matthewp! - Experimental redirects supportThis change adds support for the redirects RFC, currently in stage 3: https://github.com/withastro/roadmap/pull/587
Now you can specify redirects in your Astro config:
import { defineConfig } from 'astro/config'; export defineConfig({ redirects: { '/blog/old-post': '/blog/new-post' } });You can also specify spread routes using the same syntax as in file-based routing:
import { defineConfig } from 'astro/config'; export defineConfig({ redirects: { '/blog/[...slug]': '/articles/[...slug]' } });By default Astro will build HTML files that contain the
<meta http-equiv="refresh">tag. Adapters can also support redirect routes and create configuration for real HTTP-level redirects in production. -
#7237
414eb19d2Thanks @bluwy! - Remove experimental flag for custom client directives -
#7274
b5213654bThanks @Princesseuh! - Update basetsconfig.jsontemplate withallowJs: trueto provide a better relaxed experience for users unfamilliar with TypeScript.allowJsis still set tofalse(its default value) when using thestrictestpreset. -
#7180
e3b8c6296Thanks @lilnasy! - The Inline Stylesheets RFC is now stable!You can now control how Astro bundles your css with a configuration change:
export default defineConfig({ ... build: { inlineStylesheets: "auto" } ... })The options:
inlineStylesheets: "never": This is the behavior you are familiar with. Every stylesheet is external, and added to the page via a<link>tag. Default.inlineStylesheets: "auto": Small stylesheets are inlined into<style>tags and inserted into<head>, while larger ones remain external.inlineStylesheets: "always": Every style required by the page is inlined.
As always, css files in the
publicfolder are not affected. -
#7260
39403c32fThanks @natemoo-re! - Unflags support foroutput: 'hybrid'mode, which enables pre-rendering by default. The additionalexperimental.hybridOutputflag can be safely removed from your configuration. -
#7109
101f03209Thanks @ematipico! - Remove experimental flag for the middleware
Patch Changes
-
#7296
a7e2b37ffThanks @Princesseuh! - Fix HTML component type causing an error when imported in the editor -
#7294
dd1a6b6c9Thanks @matthewp! - Fix cookies not being set by middleware -
#7197
d72cfa7caThanks @bluwy! - Fix nested astro-island hydration race condition -
#7262
144813f73Thanks @andremralves! - Fix injected scripts not injected to injected routes -
#7242
890a2bc98Thanks @JerryWu1234! - remove the white space after the doctype according to the property compressHTML
Patch Changes
-
#7215
6e27f2f6dThanks @bmenant! - Node adapter fallbacks to:authorityhttp2 pseudo-header whenhostis nullish. -
#7233
96ae37eb0Thanks @bluwy! - FixgetViteConfigand Vitest setup with content collections -
#7136
fea306936Thanks @johannesspohr! - Render arrays of components in parallel -
#7257
5156c4f90Thanks @thiti-y! - fix: build fail upon have 'process.env' in *.md file. -
#7268
9e7366567Thanks @bholmesdev! - Fix: ignore.jsonfiles within content collection directories starting with an_underscore. -
#7185
339529fc8Thanks @bholmesdev! - Bring back improved style and script handling across content collection files. This addresses bugs found in a previous release to@astrojs/markdoc.
Patch Changes
-
#7193
8b041bf57Thanks @ematipico! - Refactor how pages are emitted during the internal bundling. Now each page is emitted as a separate entry point. -
#7218
6c7df28abThanks @bluwy! - Fix CSS deduping and missing chunks -
#7235
ee2aca80aThanks @MoustaphaDev! - Prioritize dynamic prerendered routes over dynamic server routes -
#7192
7851f9258Thanks @ematipico! - Detectmdxfiles using their full extension -
#7244
bef3a75dbThanks @bholmesdev! - Remove the auto-generated$entryvariable for Markdoc entries. To access frontmatter as a variable, you can passentry.dataas a prop where you render your content:--- import { getEntry } from 'astro:content'; const entry = await getEntry('docs', 'why-markdoc'); const { Content } = await entry.render(); --- <Content frontmatter={entry.data} /> -
#7204
52af9ad18Thanks @bluwy! - Add error message ifAstro.globis called outside of an Astro file -
#7246
f5063d0a0Thanks @bholmesdev! - Fix content collection build errors for empty collections or underscore files of type.json. -
#7062
cf621340bThanks @wulinsheng123! - fix miss a head when the templaterender has a promise -
#7189
2bda7fb0bThanks @elevatebart! - fix: add astro-static-slot to the list of inert tags in astro css -
#7219
af3c5a2e2Thanks @bluwy! - UseAstroErrorforAstro.globerrors -
#7139
f2f18b440Thanks @Princesseuh! - Thesrcproperty returned by ESM importing images withastro:assetsis now an absolute path, unlocking support for importing images outside the project. -
Updated dependencies [
bf63f615f]:- @astrojs/webapi@2.2.0
Patch Changes
-
#6832
904131aecThanks @wulinsheng123! - fix a bug when Fragment is as a slot -
#7178
57e65d247Thanks @bholmesdev! - Fix: revert Markdoc asset bleed changes. Production build issues were discovered that deserve a different fix.
Patch Changes
-
#7125
4ce8bf7c6Thanks @bluwy! - Make vite-plugin-content-virtual-mod rungetEntrySlug10 at a time to preventEMFILE: too many open fileserror -
#7166
626dd41d0Thanks @ematipico! - Move generation of renderers code into their own file -
#7174
92d1f017eThanks @ematipico! - Remove restriction around serialisable data forAstro.locals -
#7172
2ca94269eThanks @Princesseuh! - Add types forimport.meta.env.ASSETS_PREFIXandimport.meta.env.SITE -
#7134
5b6a0312aThanks @alexvuka1! - value of var can be undefined when usingdefine:vars -
#7171
79ba74832Thanks @bluwy! - Prevent Vite watching on Astro config load
Patch Changes
-
#6758
f558a9e20Thanks @bholmesdev! - Improve style and script handling across content collection files. This addresses style bleed present in@astrojs/markdocv0.1.0 -
#7143
b41963b77Thanks @johannesspohr! - Render 404 page content when aResponsewith status 404 is returned from a page
Patch Changes
-
#7128
72f686a68Thanks @johannesspohr! - Fix routes created byinjectRoutefor SSR -
#7132
319a0a7a0Thanks @ematipico! - Emit middleware as an entrypoint during build -
#7036
852d59a8dThanks @ematipico! - Emit pages as dynamic import chunks during the build -
#7126
530fb9ebeThanks @bluwy! - Add route information when warning ofgetStaticPaths()ignored -
#7118
3257dd289Thanks @Princesseuh! - Fix unnecessary warning showing on start when a collection folder was empty. The warning was also enhanced to add more information about possible causes.
Minor Changes
-
#7071
e186ecc5eThanks @johannesspohr! - Render sibling components in parallel -
#6850
c6d7ebefdThanks @bholmesdev! - Content collections now support data formats including JSON and YAML. You can also create relationships, or references, between collections to pull information from one collection entry into another. Learn more on our updated Content Collections docs. -
#6991
719002ca5Thanks @MoustaphaDev! - Enable experimental support for hybrid SSR with pre-rendering enabled by defaultastro.config.mjs
import { defineConfig } from 'astro/config'; export defaultdefineConfig({ output: 'hybrid', experimental: { hybridOutput: true, }, })Then add
export const prerender = falseto any page or endpoint you want to opt-out of pre-rendering.src/pages/contact.astro
--- export const prerender = false; if (Astro.request.method === 'POST') { // handle form submission } --- <form method="POST"> <input type="text" name="name" /> <input type="email" name="email" /> <button type="submit">Submit</button> </form> -
#7074
73ec6f6c1Thanks @bluwy! - Integrations can add newclient:directives through theastro:config:setuphook'saddClientDirective()API. To enable this API, the user needs to setexperimental.customClientDirectivestotruein their config.import { defineConfig } from 'astro/config'; import onClickDirective from 'astro-click-directive'; export default defineConfig({ integrations: [onClickDirective()], experimental: { customClientDirectives: true, }, });export default function onClickDirective() { return { hooks: { 'astro:config:setup': ({ addClientDirective }) => { addClientDirective({ name: 'click', entrypoint: 'astro-click-directive/click.js', }); }, }, }; }<Counter client:click />The client directive file (e.g.
astro-click-directive/click.js) should export a function of typeClientDirective:import type { ClientDirective } from 'astro'; const clickDirective: ClientDirective = (load, opts, el) => { window.addEventListener( 'click', async () => { const hydrate = await load(); await hydrate(); }, { once: true } ); }; export default clickDirective; -
#6706
763ff2d1eThanks @wulinsheng123! - Adds an opt-in way to minify the HTML output.Using the
compressHTMLoption Astro will remove whitespace from Astro components. This only applies to components written in.astroformat and happens in the compiler to maximize performance. You can enable with:import { defineConfig } from 'astro/config'; export default defineConfig({ compressHTML: true, });Compression occurs both in development mode and in the final build.
-
#7069
c1669c001Thanks @Princesseuh! - AddedPolymorphictype helper toastro/typesto easily create polymorphic components:--- import { HTMLTag, Polymorphic } from 'astro/types'; type Props<Tag extends HTMLTag> = Polymorphic<{ as: Tag }>; const { as: Tag, ...props } = Astro.props; --- <Tag {...props} /> -
#7093
3d525efc9Thanks @matthewp! - Prevent removal of nested slots within islandsThis change introduces a new flag that renderers can add called
supportsAstroStaticSlot. What this does is let Astro know that the render is sending<astro-static-slot>as placeholder values for static (non-hydrated) slots which Astro will then remove.This change is completely backwards compatible, but fixes bugs caused by combining ssr-only and client-side framework components like so:
<Component> <div> <Component client:load> <span>Nested</span> </Component> </div> </Component>
Patch Changes
-
#7102
4516d7b22Thanks @Princesseuh! - Fix image services not being usable on Edge runtimes -
#7044
914c439bcThanks @Steffan153! - Escape closing script tag withdefine:vars -
#6851
e9fc2c221Thanks @timozander! - Added warning message when using unsupported file extensions in pages/ -
#7106
075eee08fThanks @ematipico! - Fix middleware for API endpoints that useResponse, and log a warning for endpoints that don't useResponse. -
#7110
fc52681baThanks @delucis! - Fix formatting in theNoMatchingRenderererror message. -
#7095
fb84622afThanks @bholmesdev! - Generate headingids and populate theheadingsproperty for all Markdoc files -
#7011
cada10a46Thanks @TheOtterlord! - Throw an error when unknown experimental keys are present -
#7091
cd410c5ebThanks @MoustaphaDev! - Fix double prepended forward slash in SSR -
#7108
410428672Thanks @Princesseuh! - Fix imports using ?raw and ?url not working whenexperimental.assetsis enabled -
Updated dependencies [
826e02890]:- @astrojs/markdown-remark@2.2.1
Patch Changes
-
#7000
c87d42e76Thanks @craigjennings11! - Remove 'paths' requirement for tsconfig path aliasing -
#7055
4f1073a6aThanks @Princesseuh! - Fix astro:assets interfering with SSR query params ending with image extensions
Patch Changes
-
#7047
48395c815Thanks @Princesseuh! - Fix/_imageendpoint not being prefixed with thebasepath in build SSR -
#6916
630f8c8efThanks @bholmesdev! - Add fast lookups for content collection entries when usinggetEntryBySlug(). This generates a lookup map to ensure O(1) retrieval.
Patch Changes
-
#7009
1d4db68e6Thanks @Princesseuh! - Fix types fromastro/clientnot working properly due toclient-base.d.tsbeing an non-ambient declaration file -
#7010
e9f0dd9b4Thanks @ematipico! - Callnext()without return anything should work, with a warning
Patch Changes
- #6995
71332cf96Thanks @Princesseuh! - Move sharpImageService and squooshImageService functions toastro/configso they can be imported
Minor Changes
-
#6990
818252acdThanks @Princesseuh! - Generated optimized images are now cached inside thenode_modules/.astro/assetsfolder. The cached images will be used to avoid doing extra work and speed up subsequent builds. -
#6659
80e3d4d3dThanks @lilnasy! - Implement Inline Stylesheets RFC as experimental -
#6771
3326492b9Thanks @matthewp! - Implements a new class-based scoping strategyThis implements the Scoping RFC, providing a way to opt in to increased style specificity for Astro component styles.
This prevents bugs where global styles override Astro component styles due to CSS ordering and the use of element selectors.
To enable class-based scoping, you can set it in your config:
import { defineConfig } from 'astro/config'; export default defineConfig({ scopedStyleStrategy: 'class', });Note that the 0-specificity
:wherepseudo-selector is still the default strategy. The intent is to change'class'to be the default in 3.0. -
#6959
cac4a321eThanks @bluwy! - Support<Code inline />to output inline code HTML (nopretag) -
#6721
831b67cdbThanks @ematipico! - Implements a new experimental middleware in Astro.The middleware is available under the following experimental flag:
export default defineConfig({ experimental: { middleware: true, }, });Or via CLI, using the new argument
--experimental-middleware.Create a file called
middleware.{js,ts}inside thesrcfolder, and export aonRequestfunction.From
astro/middleware, use thedefineMiddlewareutility to take advantage of type-safety, and use thesequenceutility to chain multiple middleware functions.Example:
import { defineMiddleware, sequence } from 'astro/middleware'; const redirects = defineMiddleware((context, next) => { if (context.request.url.endsWith('/old-url')) { return context.redirect('/new-url'); } return next(); }); const minify = defineMiddleware(async (context, next) => { const repsonse = await next(); const minifiedHtml = await minifyHtml(response.text()); return new Response(minifiedHtml, { status: 200, headers: response.headers, }); }); export const onRequest = sequence(redirects, minify); -
#6932
49514e4ceThanks @bluwy! - Upgrade shiki to v0.14.1. This updates the shiki theme colors and adds the theme name to thepretag, e.g.<pre class="astro-code github-dark">.
Patch Changes
Patch Changes
-
#6967
a8a319aefThanks @bluwy! - Fixastro-entryerror on build with multiple JSX frameworks -
#6961
a695e44aeThanks @Princesseuh! - Fix getImage type -
#6956
367e61776Thanks @lilnasy! - Changed where various parts of the build pipeline look to decide if a page should be prerendered. They now exclusively consider PageBuildData, allowing integrations to participate in the decision. -
#6969
77270cc2cThanks @bluwy! - Avoid removing leading slash forbuild.assetsPrefixvalue in the build output -
#6910
895fa07d8Thanks @natemoo-re! - Inlineprocess.envboolean values (0,1,true,false) during the build. This helps with DCE and allows for betterexport const prerenderdetection. -
#6958
72c6bf01fThanks @bluwy! - Fix content render imports flow -
#6952
e5bd084c0Thanks @Princesseuh! - Update allowed Sharp versions to support 0.32.0
Patch Changes
-
#6940
a98df9374Thanks @delucis! - Support custom 404s added viainjectRouteor assrc/pages/404.html -
#6948
50975f2eaThanks @imchell! - Placeholders for slots are cleaned in HTML String that is rendered -
#6848
ebae1eaf8Thanks @Princesseuh! - Updateexperimental.assets'simage.serviceconfiguration to allow for a config option in addition to an entrypoint -
#6953
dc062f669Thanks @Princesseuh! - Updateastro checkto use version 1.0.0 of the Astro language server -
Updated dependencies [
ac57b5549]:- @astrojs/telemetry@2.1.1
- @astrojs/webapi@2.1.1
Patch Changes
-
#6859
4c7ba4da0Thanks @andremralves! - Fix Astro.params does not contain path parameter from URL with non-English characters. -
#6872
b6154d2d5Thanks @bluwy! - Fix hoisted scripts path for linked package Astro components -
#6862
1f2699461Thanks @jcdogo! - Fixes bug with assetsPrefix not being prepended to component-url and renderer-url in astro islands when using SSR mode. -
#6902
0afff3274Thanks @bluwy! - Disable Vite optimizer for sync and config loading. Improve first page load time for warm server startup.
Minor Changes
Patch Changes
-
#6544
a9c22994eThanks @wulinsheng123! - Correctly generate directories for assets when users customise the output via rollup options. -
#6825
948a6d7beThanks @Princesseuh! - Fix unnecessary warning when using images inside thesrc/contentfolder withexperimental.assets -
Updated dependencies [
2511d58d5]:- @astrojs/markdown-remark@2.1.4
Patch Changes
-
#6765
6c09ac03bThanks @Princesseuh! - Properly include the needed WASM files for the Squoosh service for Netlify and Vercel in SSR -
#6817
f882bc163Thanks @bholmesdev! - Fix sourcemap warnings when using Content Collections and MDX with thevite.build.sourcemapoption -
#6819
76dd53e3fThanks @MoustaphaDev! - Fix fallback content showing unexpectedly in some cases -
#6582
7653cf9e9Thanks @bluwy! - Fix CSS chunking and deduping between multiple Astro files and framework components
Patch Changes
-
#6766
72fed684aThanks @Xetera! - Exporting the ImageFunction in astro:content and grouping it under a SchemaContext -
#6772
45bff6fccThanks @natemoo-re! - Allowimport.meta.envvalues of0,1,true, andfalseto be used forexport const prerenderstatements -
#6770
52d7a4a01Thanks @Princesseuh! - Updated types to match newer Vite versions -
#6774
9e88e0f23Thanks @bholmesdev! - Fix: remove oldslug()type fromdefineCollection()helper -
#6775
fa84f1a7dThanks @matthewp! - Support streaming inside of slots -
#6779
a98f6f418Thanks @matthewp! - Prevent body head content injection in MDX when using layout -
#6781
7f74326b7Thanks @bholmesdev! - Fixastro:server:setupmiddlewares not applying. This resolves an issue with the Partytown integration in dev.
Minor Changes
-
#6703
a1108e037Thanks @Princesseuh! - Moveimage()to come fromschemainstead to fix it not working with refine and inside complex typesMigration:
Remove the
imageimport fromastro:content, and instead use a function to generate your schema, like such:import { defineCollection, z } from 'astro:content'; defineCollection({ schema: ({ image }) => z.object({ image: image().refine((img) => img.width >= 200, { message: 'image too small', }), }), }); -
#6714
ff0430786Thanks @bluwy! - Addbuild.assetsPrefixoption for CDN support. If set, all Astro-generated asset links will be prefixed with it. For example, setting it tohttps://cdn.example.comwould generatehttps://cdn.example.com/_astro/penguin.123456.pnglinks.Also adds
import.meta.env.ASSETS_PREFIXenvironment variable that can be used to manually create asset links not handled by Astro.
Patch Changes
-
#6753
489dd8d69Thanks @bluwy! - FixgetViteConfigreturn type -
#6744
a1a4f45b5Thanks @Princesseuh! - Fix remote images in Markdown throwing errors when usingexperimental.assets -
#6762
8b88e4cf1Thanks @Princesseuh! - Improved error message when an error was encountered while generating types -
#6719
d54cbe413Thanks @matthewp! - Better errors for when response is already sentThis adds clearer error messaging when a Response has already been sent to the browser and the developer attempts to use:
- Astro.cookies.set
- Astro.redirect
-
#6741
4c347ab51Thanks @Princesseuh! - Fix content-type header being wrong in dev on images fromastro:assets -
#6739
2f2e572e9Thanks @Princesseuh! - Added more types and utilities exports related toastro:assetsto help building custom image components and image services -
Updated dependencies [
a1a4f45b5]:- @astrojs/markdown-remark@2.1.3
Patch Changes
-
#6693
c0b7864a4Thanks @bholmesdev! - Fix: avoid callingastro:server:setupintegration hook in production -
#6676
5e33c51a9Thanks @bholmesdev! - Fix next and previous links for index routes when using pagination -
#6717
c2d4ae1cbThanks @Princesseuh! - Dynamically import check command to improve startup speed and prevent Astro from crashing due to language-server stuff -
#6679
08e92f4f8Thanks @fcFn! - Fix incorrect path to file in error overlay on Win -
#6649
f0b732d32Thanks @Princesseuh! - Improve error handling when usingastro:assets -
#6710
a0bdf4ce2Thanks @Princesseuh! - Fix multiple Image / getImage calls with the same image causing multiple duplicate images to be generated -
#6711
c04ea0d43Thanks @Princesseuh! - Fix InferGetStaticParamsType and InferGetStaticPropsType not working when getStaticPaths wasn't async -
#6701
46ecf4662Thanks @Princesseuh! - Remove unnecessary.wasmfiles inside build output when possible
Patch Changes
-
#6675
1f783e320Thanks @matthewp! - Prevent frontmatter errors from crashing the dev server -
#6688
2e92e9aa9Thanks @JohannesKlauss! - Add a additional check fornullon thereq.bodycheck inNodeApp.render. -
#6578
adecda7d6Thanks @wulinsheng123! - add new flag with open for dev and preview -
#6680
386336441Thanks @koriwi! - Invalidates cache when changing serviceEntryPoint -
#6653
7c439868aThanks @bholmesdev! - Simplify Markdoc configuration with a newmarkdoc.config.mjsfile. This lets you import Astro components directly to render as Markdoc tags and nodes, without the need for the previouscomponentsproperty. This new configuration also unlocks passing variables to your Markdoc from theContentcomponent (see the new docs).Migration
Move any existing Markdoc config from your
astro.configto a newmarkdoc.config.mjsfile at the root of your project. This should be applied as a default export, with the optionaldefineMarkdocConfig()helper for autocomplete in your editor.This example configures an
asideMarkdoc tag. Note that components should be imported and applied to therenderattribute directly, instead of passing the name as a string:// markdoc.config.mjs import { defineMarkdocConfig } from '@astrojs/markdoc/config'; import Aside from './src/components/Aside.astro'; export default defineMarkdocConfig({ tags: { aside: { render: Aside, }, }, });You should also remove the
componentsprop from yourContentcomponents. Since components are imported into your config directly, this is no longer needed.--- - import Aside from '../components/Aside.astro'; import { getEntryBySlug } from 'astro:content'; const entry = await getEntryBySlug('docs', 'why-markdoc'); const { Content } = await entry.render(); --- <Content - components={{ Aside }} /> -
#6639
25cd3e574Thanks @tony-sull! - Fixes an attribute naming mismatch in the definition for elements in astro.JSX -
#6353
4bf87c64fThanks @wulinsheng123! - Throw better error when a dynamic endpoint without additional extensions is prerendered withundefinedparams. -
#6643
fc0ed9c53Thanks @Princesseuh! - Fix images not having the proper path when usingbase
Patch Changes
-
#6192
b7194103eThanks @erg208! - Updated to fix the Node SSR fails on POST with Express JSON middleware -
#6630
cfcf2e2ffThanks @bholmesdev! - Support automatic image optimization for Markdoc images when usingexperimental.assets. You can follow our Assets guide to enable this feature in your project. Then, start using relative or aliased image sources in your Markdoc files for automatic optimization:<!--Relative paths-->  <!--Or configured aliases-->  -
#6638
7daef9a29Thanks @matthewp! - Avoid implicit head injection when a head is in the tree
Patch Changes
-
#6633
9caf2a9ccThanks @bholmesdev! - Fix failedastro synccall when runningastro check. This change also reverts alias support in CSS styles. -
#6627
d338b6f74Thanks @Princesseuh! - Update frontmatter assets to be relative to the current file instead ofsrc/assets
Patch Changes
-
#6604
7f7a8504bThanks @Princesseuh! - Fix using optimized images in Markdown not working -
#6617
38e6ec21eThanks @MoustaphaDev! - Fix tsconfig alias regression -
#6588
f42f47dc6Thanks @bholmesdev! - Allow access to content collection entry information (including parsed frontmatter and the entry slug) from your Markdoc using the$entryvariable:--- title: Hello Markdoc! --- # {% $entry.data.title %} -
Updated dependencies [
7f7a8504b]:- @astrojs/markdown-remark@2.1.2
Patch Changes
-
#6547
04dddd783Thanks @Princesseuh! - Fix images having the wrong width and height when using the new astro:assets features if both dimensions were provided -
#6566
ea9b3dd72Thanks @bluwy! - Support tsconfig aliases in styles -
#6472
bf024cb34Thanks @wulinsheng123! - don't finish the action of the copy before removing all files. -
#6556
22955b895Thanks @Princesseuh! - Fix Invalid Input error when trying to use a custom Image Service -
#6568
f413446a8Thanks @Princesseuh! - Fix image() type to be compatible with ImageMetadata -
#6559
90e5f87d0Thanks @Princesseuh! - Vendorimage-sizeto fix CJS-related issues -
#6576
388190102Thanks @bluwy! - Simplify internal resolver in dev -
#6536
035c0c4dfThanks @Princesseuh! - Fix Image component andgetImagenot handling images from public correctly -
#6601
f112c12b1Thanks @bluwy! - Fix plugin apply args when filtering -
#6586
689884251Thanks @solelychloe! - fix: Add missing --watch flag for astro check when running astro check --help -
#6572
fa132e35cThanks @MoustaphaDev! - Properly handle empty markdown files in content collections -
#6555
f5fddafc2Thanks @Princesseuh! - Add avalidateOptionshook to the Image Service API in order to set default options and validate the passed options -
#6605
283734525Thanks @Princesseuh! - Update tsconfig.json templates to ignore TypeScript 5.0 deprecations for the moment -
#6583
66858f1f2Thanks @francoromanol! - Fix overflow title in error message -
#6558
6c465e958Thanks @bluwy! - Fix prerendered 404 page handling in SSR -
Updated dependencies [
90e5f87d0,f5fddafc2]:- @astrojs/markdown-remark@2.1.1
Patch Changes
-
#6530
acf78c5e2Thanks @Princesseuh! - Fix various inaccuracies with types related to the new Assets features:- getConfiguredImageService wasn't present on the astro:assets types.
- ImageMetadata wasn't exported
- Fixed wrong module declaration for
avif,heicandheiffiles. - Add missing module declaration for SVGs imports
-
#6527
04e624d06Thanks @bluwy! - Treeshake exported client components that are not imported -
#6533
cc90d7219Thanks @Princesseuh! - Added a warning when trying to useexperimental.assetswith a not compatible adapter -
#6483
a9a6ae298Thanks @Princesseuh! - Fix images defined in content collections schemas not working -
#6537
6a7cf0712Thanks @matthewp! - Prevent astro:content from depending on Node builtins -
#6488
bfd67ea74Thanks @matthewp! - Remove use of createRequire breaking non-Node hosts. -
#6503
f6eddffa0Thanks @bholmesdev! - Add caching togetCollection()queries for faster SSG production builds -
#6508
c63874090Thanks @bholmesdev! - Improve content collection error formatting:- Bold the collection and entry that failed
- Consistently list the frontmatter key at the start of every error
- Rich errors for union types
-
#6485
d637d1ea5Thanks @bluwy! - Fix@astrojs/prismedgecase with strict package managers -
#6532
637f9bc72Thanks @Princesseuh! - Fixenv.d.tschanging types wrongly on every restart whenexperimental.assetsis enabled -
#6460
77a046e88Thanks @bluwy! - Add default.npmrcfile when adding the Lit integration throughastro add litand usingpnpm.
Patch Changes
-
#6454
05fc7ae54Thanks @Princesseuh! - Add support for ESM importing SVGs when usingastro:assets -
#6455
cf0198316Thanks @delucis! - Documentimage.serviceconfiguration option -
#6459
964d55246Thanks @bluwy! - Prevent HTML-escape of raw strings in<script>and<style>tags of Astro JSX -
#6465
65c07ce1bThanks @matthewp! - Fixes ESM imported assets to be root relative
Minor Changes
-
#6150
b087b83feThanks @morellodev! - Add getStaticPaths type helpers to infer params and props -
#6344
694918a56Thanks @Princesseuh! - Add a new experimental flag (experimental.assets) to enable our new core Assets story.This unlocks a few features:
- A new built-in image component and JavaScript API to transform and optimize images.
- Relative images with automatic optimization in Markdown.
- Support for validating assets using content collections.
- and more!
See Assets (Experimental) on our docs site for more information on how to use this feature!
-
#6435
a20610609Thanks @matthewp! - Expose the manifest to plugins via the astro:ssr-manifest virtual module -
#6394
a4a74ab70Thanks @ematipico! - Add--helpto various commands:check,sync,dev,preview, andbuild -
#6356
75921b3cdThanks @ematipico! - Added a new--watchflag to the commandastro check -
#6213
afbbc4d5bThanks @Princesseuh! - Updated compilation settings to disable downlevelling for Node 14
Patch Changes
-
#6209
fec583909Thanks @bholmesdev! - Introduce the (experimental)@astrojs/markdocintegration. This unlocks Markdoc inside your Content Collections, bringing support for Astro and UI components in your content. This also improves Astro core internals to make Content Collections extensible to more file types in the future.You can install this integration using the
astro addcommand:astro add markdocRead the
@astrojs/markdocdocumentation for usage instructions, and browse the newwith-markdocstarter to try for yourself. -
Updated dependencies [
694918a56,afbbc4d5b]:- @astrojs/markdown-remark@2.1.0
- @astrojs/telemetry@2.1.0
- @astrojs/webapi@2.1.0
Patch Changes
-
#6412
cd8469947Thanks @liruifengv! - Remove redundant comments whenastro addupdateastro.config.mjs -
#6426
e0844852dThanks @MoustaphaDev! - Prevent?inlineand?rawcss query suffixes from injecting style tags in development -
Updated dependencies [
0abd1d3e4]:- @astrojs/webapi@2.0.3
Patch Changes
-
#6391
45501c531Thanks @bluwy! - Teardown compiler after Vite build to free up memory when rendering pages -
#6392
ee8b2a067Thanks @bluwy! - Run astro sync in build mode -
#6368
02a7266e3Thanks @userquin! - Fix regression that caused some stateful Vite plugins to assume they were running indevmode during thebuildand vice versa. -
#6358
95164bfddThanks @Princesseuh! - Add warning when using headers and encoding in endpoints in SSR
Patch Changes
-
#6323
5e26bc891Thanks @Princesseuh! - Updated Undici to 5.20.0. This fixes a security issue and handling of cookies in certain cases in dev -
#6293
a156ecbb7Thanks @MoustaphaDev! - Warn about setting theallowJscompiler option only when thecontentdirectory exists. -
#6320
ccd72e6bbThanks @wulinsheng123! - fix #6020 -
#6347
504c7bacbThanks @natemoo-re! - Fix internalgetSetCookieusage forundici@5.20.x -
#6333
63dda6dedThanks @ematipico! - Correctly emit mode when passingnodeto the commandastro add -
#6330
f91a7f376Thanks @MoustaphaDev! - Ensure prefixed underscore ignores only child paths of the content directory.
Patch Changes
-
#6268
933c651fbThanks @natemoo-re! - Do not transform--camelCasecustom properties to--camel-casewhen they're in astyleattribute.This bug fix is backwards-compatible because we will emit both
--camelCaseand--camel-casetemporarily. This behavior will be removed in a future version of Astro. -
Updated dependencies [
bb1801013]:- @astrojs/webapi@2.0.1
Patch Changes
-
#6248
ef5cea4dcThanks @wulinsheng123! - Deno SSR with prerender=true complains about invalid URL scheme -
#6257
2fec47848Thanks @bholmesdev! - Fix: prevent dev server hanging forgetCollection()calls within a layout when using thelayoutprop
Patch Changes
-
#6238
deacd5443Thanks @bholmesdev! - Fix: run integration setup hooks duringastro sync -
#6244
1c678f7ebThanks @bluwy! - Fix hydrate loading path to prevent multiple instance loaded for circular imports -
#6229
c397be324Thanks @MoustaphaDev! - Add support for.js/.mjsfile extensions for Content Collections configuration file.
Patch Changes
-
#6216
79783fc01Thanks @matthewp! - Fix head injection in body with slots.render() and head buffering -
#6218
baa2dbb3bThanks @bholmesdev! - Fix: internal content collection error on spaces in file name -
#6049
8b7cb64daThanks @natemoo-re! - Preserve--rootCLI flag when restarting dev server
Patch Changes
-
#6183
436bd0934Thanks @Jutanium! - Fixes the first-page value ofurl.prevwhen paginating a spread route at the root -
#6198
a9bdd9cc4Thanks @matthewp! - Fixes usage of Code component in Vercel -
#6182
938ad514cThanks @matthewp! - Ensure base configuration appended to content collection styles -
#6197
c75d319eeThanks @BryceRussell! - Fixborderandframeattribute types onTableHTMLAttributesinterface -
#6180
6fa6025b3Thanks @matthewp! - Allow binary data to be returned from api routes in SSG -
#6196
3390cb844Thanks @matthewp! - Fix head injection misplacement with Astro.slots.render()
Patch Changes
-
#6161
f6fc662c3Thanks @matthewp! - Prevent ?inline and ?raw CSS from being bundled as CSS -
#6149
592386b75Thanks @bloycey! - Moved pagination error to AstroErrorData -
#6153
1b591a143Thanks @torchsmith! - Respectvite.build.emptyOutDirsetting duringastro build -
#6092
bf8d7366aThanks @bholmesdev! - Ensure vite config (aliases, custom modules, etc) is respected when loading the content collection config -
#6111
ec38a8921Thanks @e111077! - Implement client:only functionality in Lit and add lit to the client:only warning -
#6124
f20a85b64Thanks @FredKSchott! - Fix outdated error message inpaginate()function. -
#6122
9f22ac3d0Thanks @bholmesdev! - Content collections: Fix accidental "use underscore to ignore" logs for.DS_Storefiles and underscored directory names. -
#6163
cee70f5c6Thanks @Princesseuh! - Fix returning hex / base64 images from endpoints not working in dev -
#6114
ac7fb04d6Thanks @bluwy! - Fix sourcemap generation when scanning files -
#6152
d1f5611feThanks @matthewp! - Fix MDX related head placement bugsThis fixes a variety of head content placement bugs (such as page
<link>) related to MDX, especially when used in content collections. Issues fixed:- Head content being placed in the body instead of the head.
- Head content missing when rendering an MDX component from within a nested Astro component.
-
#6119
2189170beThanks @matthewp! - Fix hoisted script propagation in content collection pages -
#6117
32abe49bdThanks @Princesseuh! - Fix polyfills not being available in certain cases
Patch Changes
-
#6052
9793f19ecThanks @mayank99! - Error overlay will now show the error'scauseif available. -
#6070
f91615f5cThanks @AirBorne04! - * safe guard against TextEncode.encode(HTMLString) [errors on vercel edge]- safe guard against html.replace when html is undefined
-
#6064
2fb72c887Thanks @bholmesdev! - Apply MDXcomponentsexport when rendering as a content collection entry
Patch Changes
-
#6045
41e97158bThanks @natemoo-re! - Improve error handling when an Astro component is rendered manually -
#6036
e779c6242Thanks @natemoo-re! - Improve error handling when top-levelreturnis present
Patch Changes
-
#5983
b53e0717bThanks @natemoo-re! - Fixes a dev server edge case where prerender + getStaticPaths would not 404 on an unmatched route -
#5992
60b32d585Thanks @HiDeoo! - FixAstro.url.protocolwhen using the @astrojs/node SSR adapter with HTTPS -
#5971
883e0cc29Thanks @JLarky! - improve error message: change @astrojs/solid to @astrojs/solid-js -
#5970
dabce6b8cThanks @bholmesdev! - Add type guard support to filters ongetCollection() -
#5952
aedf23f85Thanks @wulinsheng123! - Astrocomponent is not able to use a custom theme anymore -
Updated dependencies [
7abb1e905]:- @astrojs/markdown-remark@2.0.1
Patch Changes
-
#5969
f4c71e5ebThanks @matthewp! - Fix usage of logger in Vercel EdgeThis protects against usage of
processglobal in shimmed environments. -
#5962
46b6e1426Thanks @MoustaphaDev! - Fix Content Collections not loading config file when there are spaces in the folder tree -
#5972
02549b8ceThanks @bluwy! - Correctly detect Node.js version
Note This is a detailed changelog of all changes in Astro v2.
See our upgrade guide for an overview of steps needed to upgrade an existing project.
Major Changes
-
#5687
e2019be6fThanks @bholmesdev! - Give remark and rehype plugins access to user frontmatter via frontmatter injection. This meansdata.astro.frontmatteris now the complete Markdown or MDX document's frontmatter, rather than an empty object.This allows plugin authors to modify existing frontmatter, or compute new properties based on other properties. For example, say you want to compute a full image URL based on an
imageSrcslug in your document frontmatter:export function remarkInjectSocialImagePlugin() { return function (tree, file) { const { frontmatter } = file.data.astro; frontmatter.socialImageSrc = new URL(frontmatter.imageSrc, 'https://my-blog.com/').pathname; }; }When using Content Collections, you can access this modified frontmatter using the
remarkPluginFrontmatterproperty returned when rendering an entry.Migration instructions
Plugin authors should now check for user frontmatter when applying defaults.
For example, say a remark plugin wants to apply a default
titleif none is present. Add a conditional to check if the property is present, and update if none exists:export function remarkInjectTitlePlugin() { return function (tree, file) { const { frontmatter } = file.data.astro; + if (!frontmatter.title) { frontmatter.title = 'Default title'; + } } }This differs from previous behavior, where a Markdown file's frontmatter would always override frontmatter injected via remark or reype.
-
#5891
05caf445dThanks @bholmesdev! - Remove deprecated Markdown APIs from Astro v0.X. This includesgetHeaders(), the.astroproperty for layouts, and therawContent()andcompiledContent()error messages for MDX. -
#5778
49ab4f231Thanks @bluwy! - Remove proload to load the Astro config. It will now use NodeJS and Vite to load the config only. -
#5728
8fb28648fThanks @natemoo-re! - The previously experimental features--experimental-error-overlayand--experimental-prerender, both added in v1.7.0, are now the default.You'll notice that the error overlay during
astro devhas a refreshed visual design and provides more context for your errors.The
prerenderfeature is now enabled by default when usingoutput: 'server'. To prerender a particular page, addexport const prerender = trueto your frontmatter.Warning Integration authors that previously relied on the exact structure of Astro's v1.0 build output may notice some changes to our output file structure. Please test your integrations to ensure compatability. Users that have configured a custom
vite.build.rollupOptions.output.chunkFileNamesshould ensure that their Astro project is configured as an ESM Node project. Either include"type": "module"in your rootpackage.jsonfile or use the.mjsextension forchunkFileNames. -
#5782
1f92d64eaThanks @Princesseuh! - Remove support for Node 14. Minimum supported Node version is now >=16.12.0 -
#5771
259a539d7Thanks @matthewp! - Removes support for astroFlavoredMarkdownIn 1.0 Astro moved the old Astro Flavored Markdown (also sometimes called Components in Markdown) to a legacy feature. This change removes the
legacy.astroFlavoredMarkdownoption completely.In 2.0 this feature will not be available in Astro at all. We recommend migration to MDX for those were still using this feature in 1.x.
-
#5941
304823811Thanks @bholmesdev! - Content collections: Introduce a newslugfrontmatter field for overriding the generated slug. This replaces the previousslug()collection config option from Astro 1.X and the 2.0 beta.When present in a Markdown or MDX file, this will override the generated slug for that entry.
# src/content/blog/post-1.md --- title: Post 1 + slug: post-1-custom-slug ---Astro will respect this slug in the generated
slugtype and when using thegetEntryBySlug()utility:--- import { getEntryBySlug } from 'astro:content'; // Retrieve `src/content/blog/post-1.md` by slug with type safety const post = await getEntryBySlug('blog', 'post-1-custom-slug'); ---Migration
If you relied on the
slug()config option, you will need to move all custom slugs toslugfrontmatter properties in each collection entry.Additionally, Astro no longer allows
slugas a collection schema property. This ensures Astro can manage theslugproperty for type generation and performance. Remove this property from your schema and any relevantslug()configuration:const blog = defineCollection({ schema: z.object({ - slug: z.string().optional(), }), - slug({ defaultSlug, data }) { - return data.slug ?? defaultSlug; - }, }) -
#5753
302e0ef8fThanks @bluwy! - Default preview host tolocalhostinstead of127.0.0.1. This allows the static server and integration preview servers to serve under ipv6. -
#5716
dd56c1941Thanks @bluwy! - Remove MDX Fragment hack. This was used by@astrojs/mdxto access theFragmentcomponent, but isn't required anymore since@astrojs/mdxv0.12.1. -
#5584
9963c6e4d& #5842c4b0cb8bfThanks @wulinsheng123 and @natemoo-re! - Breaking Change: client assets are built to an_astrodirectory in the build output directory. Previously these were built to various locations, includingassets/,chunks/and the root of build output.You can control this location with the new
buildconfiguration option namedassets. -
#5893
be901dc98Thanks @matthewp! - RenamegetEntrytogetEntryBySlugThis change moves
getEntrytogetEntryBySlugand accepts a slug rather than an id.In order to improve support in
[id].astroroutes, particularly in SSR where you do not know what the id of a collection is. UsinggetEntryBySluginstead allows you to map the[id]param in your route to the entry. You can use it like this:--- import { getEntryBySlug } from 'astro:content'; const entry = await getEntryBySlug('docs', Astro.params.id); if (!entry) { return new Response(null, { status: 404, }); } --- <!-- You have an entry! Use it! --> -
#5685
f6cf92b48Thanks @bluwy! - Upgrade to Vite 4. Please see its migration guide for more information. -
#5724
16c7d0bfdThanks @bluwy! - Remove outdated Vue info log. RemovetoStringsupport forRenderTemplateResult. -
#5684
a9c292026& #576993e633922Thanks @bholmesdev! - Refine Markdown and MDX configuration options for ease-of-use.-
Markdown
-
Replace the
extendDefaultPluginsoption with agfmboolean and asmartypantsboolean. These are enabled by default, and can be disabled to remove GitHub-Flavored Markdown and SmartyPants. -
Ensure GitHub-Flavored Markdown and SmartyPants are applied whether or not custom
remarkPluginsorrehypePluginsare configured. If you want to apply custom plugins and remove Astro's default plugins, manually setgfm: falseandsmartypants: falsein your config.
-
-
Migrate
extendDefaultPluginstogfmandsmartypantsYou may have disabled Astro's built-in plugins (GitHub-Flavored Markdown and Smartypants) with the
extendDefaultPluginsoption. This has now been split into 2 flags to disable each plugin individually:-
markdown.gfmto disable GitHub-Flavored Markdown -
markdown.smartypantsto disable SmartyPants// astro.config.mjs import { defineConfig } from 'astro/config'; export default defineConfig({ markdown: { -
extendDefaultPlugins: false,
-
smartypants: false,
-
gfm: false, } });
Additionally, applying remark and rehype plugins **no longer disables** `gfm` and `smartypants`. You will need to opt-out manually by setting `gfm` and `smartypants` to `false`.
-
-
MDX
-
Support all Markdown configuration options (except
drafts) from your MDX integration config. This includessyntaxHighlightingandshikiConfigoptions to further customize the MDX renderer. -
Simplify
extendPluginsto anextendMarkdownConfigoption. MDX options will default to their equivalent in your Markdown config. By settingextendMarkdownConfigto false, you can "eject" to set your own syntax highlighting, plugins, and more.
-
-
Migrate MDX's
extendPluginstoextendMarkdownConfigYou may have used the
extendPluginsoption to manage plugin defaults in MDX. This has been replaced by 3 flags:extendMarkdownConfig(trueby default) to toggle Markdown config inheritance. This replaces theextendPlugins: 'markdown'option.gfm(trueby default) andsmartypants(trueby default) to toggle GitHub-Flavored Markdown and SmartyPants in MDX. This replaces theextendPlugins: 'defaults'option.
-
-
#5717
a3a7fc929Thanks @bluwy! - Removestyle.postcssAstro config. Refactor tailwind integration to configure throughviteinstead. Also disablesautoprefixerin dev. -
#5825
52209ca2aThanks @bholmesdev! - Baseline the experimentalcontentCollectionsflag. You're free to remove this from your astro config!import { defineConfig } from 'astro/config'; export default defineConfig({ - experimental: { contentCollections: true } }) -
#5707
5eba34fccThanks @bluwy! - Remove deprecatedAstroglobal APIs, includingAstro.resolve,Astro.fetchContent, andAstro.canonicalURL.-
Astro.resolveYou can resolve asset paths using
importinstead. For example:--- import 'style.css'; import imageUrl from './image.png'; --- <img src={imageUrl} />See the v0.25 migration guide for more information.
-
Astro.fetchContentUse
Astro.globinstead to fetch markdown files, or migrate to the Content Collections feature.let allPosts = await Astro.glob('./posts/*.md'); -
Astro.canonicalURLUse
Astro.urlinstead to construct the canonical URL.const canonicalURL = new URL(Astro.url.pathname, Astro.site);
-
-
#5608
899214298Thanks @konojunya! - A trailing slash will not be automatically appended toimport.meta.env.SITE. Instead, it will be the value of thesiteconfig as is. This may affect usages of${import.meta.env.SITE}image.png, which will need to be updated accordingly. -
#5707
5eba34fccThanks @bluwy! - RemovebuildConfigoption parameter from integrationastro:build:starthook in favour of thebuild.configoption in theastro:config:setuphook.export default function myIntegration() { return { name: 'my-integration', hooks: { 'astro:config:setup': ({ updateConfig }) => { updateConfig({ build: { client: '...', server: '...', serverEntry: '...', }, }); }, }, }; }
Minor Changes
-
#5901
a342a486cThanks @bluwy! - The fallback Svelte preprocessor will only be applied if a custompreprocessoption is not passed to thesvelte()integration option, or in thesvelte.config.jsfile.To support IDE autocompletion, or if you're migrating from
@astrojs/sveltev1, you can create asvelte.config.jsfile with:import { vitePreprocess } from '@astrojs/svelte'; export default { preprocess: vitePreprocess(), };This file will also be generated by
astro add svelteby default. -
#5786
c2180746bThanks @bholmesdev! - Move generated content collection types to a.astrodirectory. This replaces the previously generatedsrc/content/types.generated.d.tsfile.If you're using Git for version control, we recommend ignoring this generated directory by adding
.astroto your .gitignore.Astro will also generate the TypeScript reference path to include
.astrotypes in your project. This will update your project'ssrc/env.d.tsfile, or write one if none exists. -
#5826
840412128Thanks @bholmesdev! - Allow Zod objects, unions, discriminated unions, intersections, and transform results as content collection schemas.Migration
Astro requires a
z.object(...)wrapper on all content collection schemas. Update your content collections config like so:// src/content/config.ts import { z, defineCollection } from 'astro:content'; const blog = defineCollection({ - schema: { + schema: z.object({ ... }) -
#5823
1f49cddf9Thanks @delucis! - Generate content types when runningastro check -
#5832
2303f9514Thanks @HiDeoo! - Add support for serving well-known URIs with the @astrojs/node SSR adapter
Patch Changes
-
#5855
16dc36a87Thanks @natemoo-re! - Remove legacy compiler error handling -
#5822
01f3f463bThanks @natemoo-re! - Fix edge case with bundle generation by emitting a single chunk for pages -
#5803
ae8a012a7Thanks @bluwy! - Upgrade compiler and handle breaking changes -
#5840
cf2de5422Thanks @chenxsan! - Persist CLI flags when restarting the dev server -
#5884
ce5c5dbd4Thanks @MoustaphaDev! - Add a theme toggle button to the error overlay -
#5824
665a2c222Thanks @bholmesdev! - Better handle content type generation failures:- Generate types when content directory is empty
- Log helpful error when running
astro syncwithout a content directory - Avoid swallowing
config.tssyntax errors from Vite
-
#5499
4987d6f44Thanks @bluwy! - Handle custom injected entry files during build -
#5734
55cea0a9dThanks @natemoo-re! - Fixprerenderwhen used withgetStaticPaths -
#5845
e818cc046Thanks @bluwy! - Fix importing client-side components with alias -
#5849
8c100a6feThanks @bluwy! - Handle server restart from Vite plugins -
#5756
116d8835cThanks @matthewp! - Fix for hoisted scripts in project with spaces in the file path -
#5917
7325df412Thanks @natemoo-re! - Fix duplicate CSS in dev mode whenvite.css.devSourcemapis provided -
#5743
2a5786419Thanks @Princesseuh! - Add error location during build for user-generated errors -
#5761
fa8c131f8Thanks @bholmesdev! - Add helpful error message when the MDX integration is missing. -
#5896
64b8082e7Thanks @natemoo-re! - Update@astrojs/compilertov1.0.0 -
#5829
23dc9ea96Thanks @giuseppelt! - FixCode.astroshiki css class replace logic -
#5836
63a6ceb38Thanks @natemoo-re! - Fix route matching when path includes special characters -
#5909
5fd9208d4Thanks @jasikpark! - Update compiler to 1.0.1 -
#5852
3a00ecb3eThanks @rishi-raj-jain! - Respectvite.envPrefixif provided -
#5872
b66d7195cThanks @bluwy! - EnableskipLibCheckby default -
Updated dependencies [
93e633922,e2019be6f,1f92d64ea,12f65a4d5,46ecd5de3,16107b6a1,c55fbcb8e,a9c292026,1f92d64ea,52209ca2a,7572f7402]:- @astrojs/markdown-remark@2.0.0
- @astrojs/telemetry@2.0.0
- @astrojs/webapi@2.0.0
Major Changes
-
#5941
304823811Thanks @bholmesdev! - Content collections: Introduce a newslugfrontmatter field for overriding the generated slug. This replaces the previousslug()collection config option from Astro 1.X and the 2.0 beta.When present in a Markdown or MDX file, this will override the generated slug for that entry.
# src/content/blog/post-1.md --- title: Post 1 + slug: post-1-custom-slug ---Astro will respect this slug in the generated
slugtype and when using thegetEntryBySlug()utility:--- import { getEntryBySlug } from 'astro:content'; // Retrieve `src/content/blog/post-1.md` by slug with type safety const post = await getEntryBySlug('blog', 'post-1-custom-slug'); ---Migration
If you relied on the
slug()config option, you will need to move all custom slugs toslugfrontmatter properties in each collection entry.Additionally, Astro no longer allows
slugas a collection schema property. This ensures Astro can manage theslugproperty for type generation and performance. Remove this property from your schema and any relevantslug()configuration:const blog = defineCollection({ schema: z.object({ - slug: z.string().optional(), }), - slug({ defaultSlug, data }) { - return data.slug ?? defaultSlug; - }, })
Patch Changes
-
#5499
4987d6f44Thanks @bluwy! - Handle custom injected entry files during build -
#5917
7325df412Thanks @natemoo-re! - Fix duplicate CSS in dev mode whenvite.css.devSourcemapis provided -
#5909
5fd9208d4Thanks @jasikpark! - Update compiler to 1.0.1 -
Updated dependencies [
46ecd5de3]:- @astrojs/webapi@2.0.0-beta.1
Major Changes
-
#5891
05caf445dThanks @bholmesdev! - Remove deprecated Markdown APIs from Astro v0.X. This includesgetHeaders(), the.astroproperty for layouts, and therawContent()andcompiledContent()error messages for MDX. -
#5893
be901dc98Thanks @matthewp! - Move getEntry to getEntryBySlugThis change moves
getEntrytogetEntryBySlugand accepts a slug rather than an id.In order to improve support in
[id].astroroutes, particularly in SSR where you do not know what the id of a collection is. UsinggetEntryBySluginstead allows you to map the[id]param in your route to the entry. You can use it like this:--- import { getEntryBySlug } from 'astro:content'; const entry = await getEntryBySlug('docs', Astro.params.id); if (!entry) { return new Response(null, { status: 404, }); } --- <!-- You have an entry! Use it! --> -
#5608
899214298Thanks @konojunya! - A trailing slash will not be automatically appended toimport.meta.env.SITE. Instead, it will be the value of thesiteconfig as is. This may affect usages of${import.meta.env.SITE}image.png, which will need to be updated accordingly.
Minor Changes
-
#5901
a342a486cThanks @bluwy! - The fallback Svelte preprocessor will only be applied if a custompreprocessoption is not passed to thesvelte()integration option, or in thesvelte.config.jsfile.To support IDE autocompletion, or if you're migrating from
@astrojs/sveltev1, you can create asvelte.config.jsfile with:import { vitePreprocess } from '@astrojs/svelte'; export default { preprocess: vitePreprocess(), };This file will also be generated by
astro add svelteby default.
Patch Changes
-
#5855
16dc36a87Thanks @natemoo-re! - Remove legacy compiler error handling -
#5884
ce5c5dbd4Thanks @MoustaphaDev! - Add a theme toggle button to the error overlay -
#5845
e818cc046Thanks @bluwy! - Fix importing client-side components with alias -
#5849
8c100a6feThanks @bluwy! - Handle server restart from Vite plugins -
#5896
64b8082e7Thanks @natemoo-re! - Update@astrojs/compilertov1.0.0 -
#5852
3a00ecb3eThanks @rishi-raj-jain! - Respectvite.envPrefixif provided -
#5872
b66d7195cThanks @bluwy! - EnableskipLibCheckby default
Major Changes
-
#5782
1f92d64eaThanks @Princesseuh! - Remove support for Node 14. Minimum supported Node version is now >=16.12.0 -
#5753
302e0ef8fThanks @bluwy! - Default preview host tolocalhostinstead of127.0.0.1. This allows the static server and integration preview servers to serve under ipv6. -
#5842
c4b0cb8bfThanks @natemoo-re! - Breaking Change: client assets are built to an_astrodirectory in the build output directory. Previously these were built to various locations, includingassets/,chunks/and the root of build output.You can control this location with the new
buildconfiguration option namedassets. -
#5825
52209ca2aThanks @bholmesdev! - Baseline the experimentalcontentCollectionsflag. You're free to remove this from your astro config!import { defineConfig } from 'astro/config'; export default defineConfig({ - experimental: { contentCollections: true } })
Minor Changes
-
#5786
c2180746bThanks @bholmesdev! - Move generated content collection types to a.astrodirectory. This replaces the previously generatedsrc/content/types.generated.d.tsfile.If you're using Git for version control, we recommend ignoring this generated directory by adding
.astroto your .gitignore.Astro will also generate the TypeScript reference path to include
.astrotypes in your project. This will update your project'ssrc/env.d.tsfile, or write one if none exists. -
#5826
840412128Thanks @bholmesdev! - Allow Zod objects, unions, discriminated unions, intersections, and transform results as content collection schemas.Migration
Astro requires a
z.object(...)wrapper on all content collection schemas. Update your content collections config like so:// src/content/config.ts import { z, defineCollection } from 'astro:content'; const blog = defineCollection({ - schema: { + schema: z.object({ ... }) -
#5823
1f49cddf9Thanks @delucis! - Generate content types when runningastro check -
#5832
2303f9514Thanks @HiDeoo! - Add support for serving well-known URIs with the @astrojs/node SSR adapter
Patch Changes
-
#5822
01f3f463bThanks @natemoo-re! - Fix edge case with bundle generation by emitting a single chunk for pages -
#5803
ae8a012a7Thanks @bluwy! - Upgrade compiler and handle breaking changes -
#5840
cf2de5422Thanks @chenxsan! - Persist CLI flags when restarting the dev server -
#5824
665a2c222Thanks @bholmesdev! - Better handle content type generation failures:- Generate types when content directory is empty
- Log helpful error when running
astro syncwithout a content directory - Avoid swallowing
config.tssyntax errors from Vite
-
#5829
23dc9ea96Thanks @giuseppelt! - FixCode.astroshiki css class replace logic -
#5836
63a6ceb38Thanks @natemoo-re! - Fix route matching when path includes special characters -
Updated dependencies [
1f92d64ea,12f65a4d5,16107b6a1,c55fbcb8e,1f92d64ea,52209ca2a,7572f7402]:- @astrojs/telemetry@2.0.0-beta.0
- @astrojs/markdown-remark@2.0.0-beta.2
- @astrojs/webapi@2.0.0-beta.0
Major Changes
-
#5778
49ab4f231Thanks @bluwy! - Remove proload to load the Astro config. It will now use NodeJS and Vite to load the config only. -
#5771
259a539d7Thanks @matthewp! - Removes support for astroFlavoredMarkdownIn 1.0 Astro moved the old Astro Flavored Markdown (also sometimes called Components in Markdown) to a legacy feature. This change removes the
legacy.astroFlavoredMarkdownoption completely.In 2.0 this feature will not be available in Astro at all. We recommend migration to MDX for those were still using this feature in 1.x.
-
#5584
9963c6e4dThanks @wulinsheng123! - Builds chunks into theassetsfolder. This simplifies configuring immutable caching with your adapter provider as all files are now in the sameassetsfolder. -
#5717
a3a7fc929Thanks @bluwy! - Removestyle.postcssAstro config. Refactor tailwind integration to configure throughviteinstead. Also disablesautoprefixerin dev.
Minor Changes
-
#5769
93e633922Thanks @bholmesdev! - Introduce asmartypantsflag to opt-out of Astro's default SmartyPants plugin.{ markdown: { smartypants: false, } }Migration
You may have disabled Astro's built-in plugins (GitHub-Flavored Markdown and Smartypants) with the
extendDefaultPluginsoption. This has now been split into 2 flags to disable each plugin individually:markdown.gfmto disable GitHub-Flavored Markdownmarkdown.smartypantsto disable SmartyPants
// astro.config.mjs import { defineConfig } from 'astro/config'; export default defineConfig({ markdown: { - extendDefaultPlugins: false, + smartypants: false, + gfm: false, } });
Patch Changes
-
#5734
55cea0a9dThanks @natemoo-re! - Fixprerenderwhen used withgetStaticPaths -
#5756
116d8835cThanks @matthewp! - Fix for hoisted scripts in project with spaces in the file path -
#5743
2a5786419Thanks @Princesseuh! - Add error location during build for user-generated errors -
#5761
fa8c131f8Thanks @bholmesdev! - Add helpful error message when the MDX integration is missing. -
Updated dependencies [
93e633922]:- @astrojs/markdown-remark@2.0.0-beta.1
Major Changes
-
#5687
e2019be6fThanks @bholmesdev! - Give remark and rehype plugins access to user frontmatter via frontmatter injection. This meansdata.astro.frontmatteris now the complete Markdown or MDX document's frontmatter, rather than an empty object.This allows plugin authors to modify existing frontmatter, or compute new properties based on other properties. For example, say you want to compute a full image URL based on an
imageSrcslug in your document frontmatter:export function remarkInjectSocialImagePlugin() { return function (tree, file) { const { frontmatter } = file.data.astro; frontmatter.socialImageSrc = new URL(frontmatter.imageSrc, 'https://my-blog.com/').pathname; }; }Content Collections - new
remarkPluginFrontmatterpropertyWe have changed inject frontmatter to modify frontmatter in our docs to improve discoverability. This is based on support forum feedback, where "injection" is rarely the term used.
To reflect this, the
injectedFrontmatterproperty has been renamed toremarkPluginFrontmatter. This should clarify this plugin is still separate from thedataexport Content Collections expose today.Migration instructions
Plugin authors should now check for user frontmatter when applying defaults.
For example, say a remark plugin wants to apply a default
titleif none is present. Add a conditional to check if the property is present, and update if none exists:export function remarkInjectTitlePlugin() { return function (tree, file) { const { frontmatter } = file.data.astro; + if (!frontmatter.title) { frontmatter.title = 'Default title'; + } } }This differs from previous behavior, where a Markdown file's frontmatter would always override frontmatter injected via remark or reype.
-
#5728
8fb28648fThanks @natemoo-re! - The previously experimental features--experimental-error-overlayand--experimental-prerender, both added in v1.7.0, are now the default.You'll notice that the error overlay during
astro devhas a refreshed visual design and provides more context for your errors.The
prerenderfeature is now enabled by default when usingoutput: 'server'. To prerender a particular page, addexport const prerender = trueto your frontmatter.Warning Integration authors that previously relied on the exact structure of Astro's v1.0 build output may notice some changes to our output file structure. Please test your integrations to ensure compatability. Users that have configured a custom
vite.build.rollupOptions.output.chunkFileNamesshould ensure that their Astro project is configured as an ESM Node project. Either include"type": "module"in your rootpackage.jsonfile or use the.mjsextension forchunkFileNames. -
#5716
dd56c1941Thanks @bluwy! - Remove MDX Fragment hack. This was used by@astrojs/mdxto access theFragmentcomponent, but isn't require anymore since@astrojs/mdxv0.12.1. -
#5685
f6cf92b48Thanks @bluwy! - Upgrade to Vite 4. Please see its migration guide for more information. -
#5724
16c7d0bfdThanks @bluwy! - Remove outdated Vue info log. RemovetoStringsupport forRenderTemplateResult. -
#5684
a9c292026Thanks @bholmesdev! - Refine Markdown and MDX configuration options for ease-of-use.Markdown
- Remove
remark-smartypantsfrom Astro's default Markdown plugins. - Replace the
extendDefaultPluginsoption with a simplifiedgfmboolean. This is enabled by default, and can be disabled to remove GitHub-Flavored Markdown. - Ensure GitHub-Flavored Markdown is applied whether or not custom
remarkPluginsorrehypePluginsare configured. If you want to apply custom plugins and remove GFM, manually setgfm: falsein your config.
MDX
- Support all Markdown configuration options (except
drafts) from your MDX integration config. This includessyntaxHighlightingandshikiConfigoptions to further customize the MDX renderer. - Simplify
extendDefaultsto anextendMarkdownConfigoption. MDX options will default to their equivalent in your Markdown config. By settingextendMarkdownConfigto false, you can "eject" to set your own syntax highlighting, plugins, and more.
Migration
To preserve your existing Markdown and MDX setup, you may need some configuration changes:
Smartypants manual installation
Smartypants has been removed from Astro's default setup. If you rely on this plugin, install
remark-smartypantsand apply to yourastro.config.*:// astro.config.mjs import { defineConfig } from 'astro/config'; + import smartypants from 'remark-smartypants'; export default defineConfig({ markdown: { + remarkPlugins: [smartypants], } });Migrate
extendDefaultPluginstogfmYou may have disabled Astro's built-in plugins (GitHub-Flavored Markdown and Smartypants) with the
extendDefaultPluginsoption. Since Smartypants has been removed, this has been renamed togfm.// astro.config.mjs import { defineConfig } from 'astro/config'; export default defineConfig({ markdown: { - extendDefaultPlugins: false, + gfm: false, } });Additionally, applying remark and rehype plugins no longer disables
gfm. You will need to opt-out manually by settinggfmtofalse.Migrate MDX's
extendPluginstoextendMarkdownConfigYou may have used the
extendPluginsoption to manage plugin defaults in MDX. This has been replaced by 2 flags:extendMarkdownConfig(trueby default) to toggle Markdown config inheritance. This replaces theextendPlugins: 'markdown'option.gfm(trueby default) to toggle GitHub-Flavored Markdown in MDX. This replaces theextendPlugins: 'defaults'option.
- Remove
-
#5707
5eba34fccThanks @bluwy! - Remove deprecatedAstroglobal APIs, includingAstro.resolve,Astro.fetchContent, andAstro.canonicalURL.Astro.resolveYou can resolve asset paths using
importinstead. For example:--- import 'style.css'; import imageUrl from './image.png'; --- <img src={imageUrl} />See the v0.25 migration guide for more information.
Astro.fetchContentUse
Astro.globinstead to fetch markdown files, or migrate to the Content Collections feature.let allPosts = await Astro.glob('./posts/*.md');Astro.canonicalURLUse
Astro.urlinstead to construct the canonical URL.const canonicalURL = new URL(Astro.url.pathname, Astro.site); -
#5707
5eba34fccThanks @bluwy! - RemovebuildConfigoption parameter from integrationastro:build:starthook in favour of thebuild.configoption in theastro:config:setuphook.export default function myIntegration() { return { name: 'my-integration', hooks: { 'astro:config:setup': ({ updateConfig }) => { updateConfig({ build: { client: '...', server: '...', serverEntry: '...', }, }); }, }, }; }
Patch Changes
Minor Changes
- #5666
bf210f784Thanks @bholmesdev! - Correctly handle spaces and capitalization insrc/content/file names. This introduces github-slugger for slug generation to ensure slugs are usable bygetStaticPaths. Changes:- Resolve spaces and capitalization:
collection/Entry With Spaces.mdbecomescollection/entry-with-spaces. - Truncate
/indexpaths to base URL:collection/index.mdbecomescollection
- Resolve spaces and capitalization:
Patch Changes
Minor Changes
- #5647
d72da5290Thanks @bholmesdev! - Addastro syncCLI command for type generation
Patch Changes
-
#5668
9674cf56cThanks @bholmesdev! - Remove strayconsole.logfrom content collections error message -
#5652
0b5098758Thanks @bluwy! - Use acorn to postprocess Astro globs -
#5648
853081d1cThanks @bholmesdev! - Prevent relative image paths insrc/content/ -
#5678
f8f576829Thanks @bluwy! - Fix code generation quotes handling -
#5635
376f67011Thanks @SegaraRai! - Addserver.headerstyping -
Updated dependencies [
853081d1c,2c65b433b]:- @astrojs/markdown-remark@1.2.0
Patch Changes
-
#5641
62580ed07Thanks @chenxsan! - Fix "Maximum call stack size exceeded" error in vite-plugin-head-propagation -
#5644
d5aff85dbThanks @natemoo-re! - Fix static build regression where chunks would not be generated -
#5639
1ac1ed86eThanks @bluwy! - Fixclient:onlyimports with"importsNotUsedAsValues": "error"tsconfig
Patch Changes
- #5617
33dcaa05bThanks @bholmesdev! - Fix error message when using Content Collections and an out-of-date@astrojs/mdxintegration
Minor Changes
-
#5297
d2960984cThanks @natemoo-re! - Introduces the experimental Prerender API.Note This API is not yet stable and is subject to possible breaking changes!
- Deploy an Astro server without sacrificing the speed or cacheability of static HTML.
- The Prerender API allows you to statically prerender specific
pages/at build time.
Usage
- First, run
astro build --experimental-prerenderor enableexperimental: { prerender: true }in yourastro.config.mjsfile. - Then, include
export const prerender = truein any file in thepages/directory that you wish to prerender.
-
#5495
31ec84797Thanks @Princesseuh! - Add a new error overlay designed by @doodlemarks! This new overlay should be much more informative, clearer, astro-y, and prettier than the previous one. -
#5291
5ec0f6ed5Thanks @bholmesdev! - Introduce Content Collections experimental API- Organize your Markdown and MDX content into easy-to-manage collections.
- Add type safety to your frontmatter with schemas.
- Generate landing pages, static routes, and SSR endpoints from your content using the collection query APIs.
-
#5341
6b156dd3bThanks @alexpdraper! - Allow setting domain when deleting cookies
Patch Changes
- #5615
d85ec7484Thanks @natemoo-re! - Sanitize dynamically rendered tags to strip out any attributes
Patch Changes
-
#5545
9082a850eThanks @bluwy! - Exclude astro from Vite optimization -
#5446
4f7f20616Thanks @jyasskin! - Fix redirect() typing to allow all redirection status codes. -
#5511
05915fec0Thanks @matthewp! - Low-level head propagationThis adds low-level head propagation ability within the Astro runtime. This is not really useable within an Astro app at the moment, but provides the APIs necessary for
renderEntryto do head propagation. -
#5553
1aeabe417Thanks @matthewp! - Fix Astro.params not having values when using base in SSR -
#5549
795f00f73Thanks @matthewp! - Use accumulated sort order when order production CSS -
#5539
2c836b9d1Thanks @wulinsheng123! - Error reporting fails on undefined error index -
#5548
8f3f67c96Thanks @ido-pluto! - Removed premature optimization
Patch Changes
-
#5506
f536a34e5Thanks @bluwy! - Dedupe Astro package when resolving -
#5506
f536a34e5Thanks @bluwy! - Refactor Astro compile flow -
#5533
58188e053Thanks @bluwy! - Refactor and remove esbuild dependency -
#5501
3c44033e4Thanks @Princesseuh! - Added a warning in build when trying to hydrate an Astro component
Patch Changes
-
#5484
731e99df8Thanks @Pimm! - Narrow type ofParams, as its values cannot be numbers -
#5480
c13775279Thanks @sapphi-red! - Fix astro preview not working on Windows -
#5497
ca01a71ebThanks @bluwy! - Refactor internal plugins code -
#5460
57888e069Thanks @bluwy! - Fix linked Astro library style HMR -
#5477
5e693c214Thanks @bluwy! - Prevent inlining SCSS partials in dev -
#5498
1a3923da7Thanks @bluwy! - Optimize JSX import source detection
Patch Changes
-
#5431
1ab505855Thanks @matthewp! - Fix regression with loading .ts in .mjs config -
#5426
ff35b4759Thanks @bluwy! - Fix JSX tagging for anonymous higher-order components default export -
#5430
b22ba1c03Thanks @bluwy! - Fix preview --host in Node.js 18 -
#5417
a9f7ff966Thanks @matthewp! - Prevent dev from crashing when there are errors in template
Patch Changes
-
#5409
9f80a4046Thanks @matthewp! - Fix Code component usage in Vercel -
#5410
3c5cb6948Thanks @impcyber! - Fix: https://github.com/withastro/astro/issues/5400 -
#5412
a278c7ae6Thanks @matthewp! - Restart dev server on package.json changes -
#5377
40226dd14Thanks @matthewp! - Uses vite to load astro.config.ts files
Patch Changes
-
#5375
f9104354bThanks @Princesseuh! - Fix regression causing nested arrays ingetStaticPaths's return value to throw an error -
#5346
f3181b5adThanks @bluwy! - Fix .html.astro file routing in dev -
#5358
9eee0f016Thanks @matthewp! - Properly support trailingSlash: never with a base -
#5345
3ae2a961bThanks @bluwy! - Respect Vite user config for third-party packages config handling -
#5371
bee8c14afThanks @matthewp! - Prefer thebaseconfig rather than site config for creating URLs for links and scripts. -
#5369
e385076efThanks @natemoo-re! - Upgrade@astrojs/compiler, fixes regression withbodyhandling whenheadcontains a Component node
Patch Changes
-
#5316
a780f2595Thanks @Princesseuh! - Improved error messages descriptions and hints to be more informative -
#5331
688f8e4bcThanks @matthewp! - Allow dynamic segments in injected routes -
#5330
7e19e8b30Thanks @matthewp! - Prevent jsx throws from hanging server -
#5328
bcd0f8f8cThanks @matthewp! - 404 when not using subpath for items in public in devPreviously if using a base like
base: '/subpath/you could load things from the root, which would break in prod. Now you must include the subpath. -
#5339
03a8f89d5Thanks @natemoo-re! - Upgrade@astrojs/compilerto latest -
#5327
0dcdc6fb1Thanks @Princesseuh! - Update Astro language-server to 0.28.3
Patch Changes
-
#5290
b2b291d29Thanks @matthewp! - Handle base configuration in adaptersThis allows adapters to correctly handle
baseconfiguration. Internally Astro now matches routes when the URL includes thebase.Adapters now also have access to the
removeBasemethod which will remove thebasefrom a pathname. This is useful to look up files for static assets. -
#5292
97e2b6ad7Thanks @MontelAle! - Changes slow astro cli imports to dynamic -
#5293
4af4d8fa0Thanks @matthewp! - Prevent overcaching .astro HMR changes -
#5314
f6add3924Thanks @matthewp! - Fixes regression with config file restarts -
#5298
247eb7411Thanks @wulinsheng123! - have not founded style when srcDir was root
Patch Changes
-
#5273
c7b9b14a1Thanks @matthewp! - Surface astro.config errors to the user -
#5264
0d27c4a2bThanks @VladCuciureanu! - Fixed memleak caused by project dir names containing '.md' or '.mdx' -
#5258
74759cf78Thanks @bluwy! - Allow 200 response for endpoints in build -
#5284
126cd8e83Thanks @herteleo! - Include missingclass:listwithinHTMLAttributestype -
#5236
1cc067052Thanks @bluwy! - Refactor CSS preprocessing handling -
#5198
c77a6cbe3Thanks @matthewp! - HMR - Improved error recoveryThis improves error recovery for HMR. Now when the dev server finds itself in an error state (because a route contained an error), it will recover from that state and refresh the page when the user has corrected the mistake.
Patch Changes
-
#5233
7f8987085Thanks @bluwy! - Support rendering@motionone/solidcomponents -
#5238
26ff42905Thanks @MoustaphaDev! - Fix not included file extension inurlmetadata for newly added markdown files -
#5217
8c83359e3Thanks @Princesseuh! - Fix missing types.d.ts in npm package -
#5206
d64d5b9b5Thanks @Princesseuh! - Improve error messages related to CSS and compiler errors -
#5212
a609a8937Thanks @bluwy! - Allow importing public files in SSR
Minor Changes
-
#5147
0bf0758fbThanks @natemoo-re! - Addastro/typesentrypoint. These utilities can be used for common prop type patterns.HTMLAttributesIf you would like to extend valid HTML attributes for a given HTML element, you may use the provided
HTMLAttributestype—it accepts an element name and returns the valid HTML attributes for that element name.import { HTMLAttributes } from 'astro/types'; interface Props extends HTMLAttributes<'a'> { myProp?: string; } -
#5164
4a8a346caThanks @MoustaphaDev! - Add support for markdown files with the following extensions:.markdown.mdown.mkdn.mkd.mdwn
-
#4917
ddf2f8390Thanks @natemoo-re! - Add support for--baseCLI argument, which will override thebaseset in yourastro.config.mjsfile.astro --site https://astro.build --base /docs
Patch Changes
Patch Changes
-
#5133
1c477dd8dThanks @bluwy! - Update@astrojs/compilerand use the newresolvePathoption. This allows removing much of the runtime code, which should improve rendering performance for Astro and MDX pages. -
#5192
8728ee0b9Thanks @tony-sull! -astro addno longer automatically installs optional peer dependencies
Patch Changes
-
#5110
0edfdd325Thanks @bluwy! - Ensure CLI flags override function-style server config -
#5106
ef0c54316Thanks @bluwy! - Support spread parameters for server endpoints -
#5095
ddfbef5acThanks @Princesseuh! - Fixastro addtrying to add lines from extended configurations when adding frameworks -
#5076
6f9a88b31Thanks @Princesseuh! - Fix jsconfig.json aliases not working anymore after 1.5.0 -
#5080
90b715d5cThanks @matthewp! - Fix Astro-in-MDX dashes in slot attr -
#5098
f684e9d36Thanks @jkjustjoshing! - Separate type definitions for built-in HTML elements and custom elements. Helpful when implementing an "as" prop similar to styled-components. -
#5108
ce01225a7Thanks @Princesseuh! - Fix types not working properly when usingmoduleResolution: 'node16' -
#5060
5923dd77cThanks @AirBorne04! - api routes: adding cookies to the response, also when returning a simple result -
#5087
49a8d18b4Thanks @JuanM04! - Fixastro addpnpm command
Minor Changes
-
#5056
e55af8a23Thanks @matthewp! - # Adapter support forastro previewAdapters are now about to support the
astro previewcommand via a new integration option. The Node.js adapter@astrojs/nodeis the first of the built-in adapters to gain support for this. What this means is that if you are using@astrojs/nodeyou can new preview your SSR app by running:npm run previewAdapter API
We will be updating the other first party Astro adapters to support preview over time. Adapters can opt-in to this feature by providing the
previewEntrypointvia thesetAdapterfunction inastro:config:donehook. The Node.js adapter's code looks like this:export default function() { return { name: '@astrojs/node', hooks: { 'astro:config:done': ({ setAdapter, config }) => { setAdapter({ name: '@astrojs/node', serverEntrypoint: '@astrojs/node/server.js', + previewEntrypoint: '@astrojs/node/preview.js', exports: ['handler'], }); // more here } } }; }The
previewEntrypointis a module in the adapter's package that is a Node.js script. This script is run whenastro previewis run and is charged with starting up the built server. See the Node.js implementation in@astrojs/nodeto see how that is implemented. -
#4986
ebd364e39Thanks @bluwy! - ## New properties for API routesIn API routes, you can now get the
site,generator,url,clientAddress,props, andredirectfields on the APIContext, which is the first parameter passed to an API route. This was done to make the APIContext more closely align with theAstroglobal in .astro pages.For example, here's how you might use the
clientAddress, which is the user's IP address, to selectively allow users.export function post({ clientAddress, request, redirect }) { if (!allowList.has(clientAddress)) { return redirect('/not-allowed'); } }Check out the docs for more information on the newly available fields: https://docs.astro.build/en/core-concepts/endpoints/#server-endpoints-api-routes
-
#4959
0ea6187f9Thanks @Princesseuh! - Added support for updating TypeScript settings automatically when usingastro addThe
astro addcommand will now automatically update yourtsconfig.jsonwith the proper TypeScript settings needed for the chosen frameworks.For instance, typing
astro add solidwill update yourtsconfig.jsonwith the following settings, per Solid's TypeScript guide:{ "compilerOptions": { "jsx": "preserve", "jsxImportSource": "solid-js" } } -
#4947
a5e3ecc80Thanks @JuanM04! - - AddedisRestartandaddWatchFileto integration stepisRestart.- Restart dev server automatically when tsconfig changes.
-
#4986
ebd364e39Thanks @bluwy! - ## Support passing a custom status code for Astro.redirectNew in this minor is the ability to pass a status code to
Astro.redirect. By default it uses302but now you can pass another code as the second argument:--- // This page was moved return Astro.redirect('/posts/new-post-name', 301); --- -
#5056
e55af8a23Thanks @matthewp! - # New build configurationThe ability to customize SSR build configuration more granularly is now available in Astro. You can now customize the output folder for
server(the server code for SSR),client(your client-side JavaScript and assets), andserverEntry(the name of the entrypoint server module). Here are the defaults:import { defineConfig } from 'astro/config'; export default defineConfig({ output: 'server', build: { server: './dist/server/', client: './dist/client/', serverEntry: 'entry.mjs', }, });These new configuration options are only supported in SSR mode and are ignored when building to SSG (a static site).
Integration hook change
The integration hook
astro:build:startincludes a parambuildConfigwhich includes all of these same options. You can continue to use this param in Astro 1.x, but it is deprecated in favor of the newbuild.configoptions. All of the built-in adapters have been updated to the new format. If you have an integration that depends on this param we suggest upgrading to do this instead:export default function myIntegration() { return { name: 'my-integration', hooks: { 'astro:config:setup': ({ updateConfig }) => { updateConfig({ build: { server: '...', }, }); }, }, }; }
Patch Changes
-
#5057
baf88ee9eThanks @bluwy! - Skip JSX tagging for export statements with source -
#5044
44ea0c6d9Thanks @JuanM04! - Upgrade Astro compiler to 0.27.1 -
#5059
f7fcdfe62Thanks @bluwy! - Support strict dependency install for libraries with JSX -
#5047
1e2799243Thanks @matthewp! - Update Astro.cookies.set types to allow booleans and numbersNote that booleans and numbers were already allowed, they just were not allowed by the type definitions.
Patch Changes
-
#5035
d7bfb144bThanks @AirBorne04! - preventing multiple doctype injection into html documents -
#5015
b1964e9e1Thanks @matthewp! - Shared state in Preact components with signalsThis makes it possible to share client state between Preact islands via signals.
For example, you can create a signals in an Astro component and then pass it to multiple islands:
--- // Component Imports import Counter from '../components/Counter'; import { signal } from '@preact/signals'; const count = signal(0); --- <Count count={count} /> <Count count={count} /> -
#5036
38fdb4ca6Thanks @matthewp! - New algorithm for shorter CSS bundle names
Patch Changes
-
#4981
1f890b336Thanks @matthewp! - Ensure dynamic tags have their slot instructions yielded -
#4886
61d26f335Thanks @yuhang-dong! - Fix: import.meta.env.BASE_URL will be '/' in client loaded component on dev mode -
#4973
c733d4fb8Thanks @bluwy! - Support Astro.slots.render for mdx -
#4918
a6bb2694bThanks @bluwy! - Refactor hydration path handling -
#4977
4f73b98aeThanks @tony-sull! - Fixes a bug that logged route cache warnings inastro dev -
#4887
37cb2fc02Thanks @Calvin-LL! - fix object styles not escaped -
#4990
8f9791d84Thanks @matthewp! - Upgrade Astro compiler to 0.26.0
Patch Changes
- #4928
7690849a8Thanks @Princesseuh! - Fix module definition of Markdown and MDX files not being available outside Astro files
Minor Changes
-
#4907
01c1aaa00Thanks @matthewp! - Order Astro styles last, to override imported stylesThis fixes CSS ordering so that imported styles are placed higher than page/component level styles. This means that if you do:
--- import '../styles/global.css'; --- <style> body { background: limegreen; } </style>The
<style>defined in this component will be placed below the imported CSS. When compiled for production this will result in something like this:/* /src/styles/global.css */ body { background: blue; } /* /src/pages/index.astro */ body:where(.astro-12345) { background: limegreen; }Given Astro's 0-specificity hashing, this change effectively makes it so that Astro styles "win" when they have the same specificity as global styles.
-
#4876
d3091f89eThanks @matthewp! - Adds the Astro.cookies APIAstro.cookiesis a new API for manipulating cookies in Astro components and API routes.In Astro components, the new
Astro.cookiesobject is a map-like object that allows you to get, set, delete, and check for a cookie's existence (has):--- type Prefs = { darkMode: boolean; }; Astro.cookies.set<Prefs>( 'prefs', { darkMode: true }, { expires: '1 month', } ); const prefs = Astro.cookies.get<Prefs>('prefs').json(); --- <body data-theme={prefs.darkMode ? 'dark' : 'light'}></body>Once you've set a cookie with Astro.cookies it will automatically be included in the outgoing response.
This API is also available with the same functionality in API routes:
export function post({ cookies }) { cookies.set('loggedIn', false); return new Response(null, { status: 302, headers: { Location: '/login', }, }); }See the RFC to learn more.
Patch Changes
-
#4892
ff7ba0ee0Thanks @matthewp! - Prevent multiple rendering of head content -
#4842
812658ad2Thanks @bluwy! - Add missing dependencies, support strict dependency installation (e.g. pnpm) -
#4891
87a7cf48eThanks @matthewp! - Hoist hydration scripts out of slot templates -
Updated dependencies [
812658ad2,812658ad2]:- @astrojs/markdown-remark@1.1.3
- @astrojs/telemetry@1.0.1
Patch Changes
-
#4861
42fe8e0c7Thanks @rishi-raj-jain! - use const instead of let for define:vars -
#4878
90c207299Thanks @rishi-raj-jain! - add warning for post routes called when output is not server -
#4855
49ca9e129Thanks @matthewp! - Fix TS errors when not using skipLibCheck -
#4845
3389f0ce9Thanks @matthewp! - Prevent the root folder from being deleted during the build -
#4841
4b092269cThanks @rishi-raj-jain! - copy assets even if outDir is out of process.cwd() -
#4849
ee5fdeffdThanks @rishi-raj-jain! - append .html to the file URL in case build.format says file -
#4867
03e8b750aThanks @rishi-raj-jain! - check if class:list's value is defined before converting -
#4873
83ed1cc1fThanks @bluwy! - Prevent /undefined catch-all routes in dev -
#4454
6a1a17dd2Thanks @bluwy! - Allow HMR for internal e2e tests -
#4712
17dbc6701Thanks @Lifeni! - Fix slashes for paths containing non-ASCII characters on Windows -
#4850
edb7bead6Thanks @rishi-raj-jain! - add support for changing mode via CLI -
#4868
b99f9902bThanks @rishi-raj-jain! - remove all the ssr generated folders in static build if only empty -
Updated dependencies [
5e4c5252b]:- @astrojs/webapi@1.1.0
Minor Changes
-
#4775
b0cc93996Thanks @tony-sull! - Adds a new "astro:build:generated" hook that runs after SSG builds finish but before build artifacts are cleaned up. This is a very specific use case, "astro:build:done" is probably what you're looking for. -
#4669
a961aa3c2Thanks @aggre! - astro-island now correctly passes Uint8Array/Uint16Array/Uint32Array -
#4832
73f215df7Thanks @matthewp! - Allows Responses to be passed to set:htmlThis expands the abilities of
set:htmlto ultimate service this use-case:<div set:html={fetch('/legacy-post.html')}></div>This means you can take a legacy app that has been statically generated to HTML and directly consume that HTML within your templates. As is always the case with
set:html, this should only be used on trusted content.To make this possible, you can also pass several other types into
set:htmlnow:Responseobjects, since that is what fetch() returns:<div set:html={new Response('<span>Hello world</span>', { headers: { 'content-type': 'text/html' }, })} > </div>ReadableStreams:<div set:html={new ReadableStream({ start(controller) { controller.enqueue(`<span>read me</span>`); controller.close(); }, })} > </div>AsyncIterables:<div set:html={(async function* () { for await (const num of [1, 2, 3, 4, 5]) { yield `<li>${num}</li>`; } })()} > </div>Iterables (non-async):<div set:html={(function* () { for (const num of [1, 2, 3, 4, 5]) { yield `<li>${num}</li>`; } })()} > </div>
Patch Changes
-
#4831
29b29e6a8Thanks @yuhang-dong! - Update vite-jsx-plugin for jsx export -
#4754
baae1b3fdThanks @Princesseuh! - Updateastro checkto latest version of the language server
Patch Changes
-
#4813
be9eaa069Thanks @bluwy! - Allow overridevite.build.target -
#4817
a49bc2f02Thanks @mohammed-elhaouari! - fix parsing integration names with astro add command -
#4819
518e8f7e2Thanks @matthewp! - Allow passing promises to set:html -
#4807
44fa37818Thanks @lucacasonato! - Remove explicitTransfer-Encoding: chunkedheader from streaming responses -
#4803
f53d97d56Thanks @Enteleform! - replaces hard-codedminifyvalues withvite.build.minify -
Updated dependencies [
df54595a8]:- @astrojs/markdown-remark@1.1.2
Patch Changes
-
#4736
13ca686eaThanks @bluwy! - Handle builds with outDir outside of current working directory -
#4748
c5e134d03Thanks @bluwy! - Fix console.error filtering -
#4742
cf8a7e933Thanks @matthewp! - Allow file uploads in dev server -
#4594
005d5bacdThanks @matthewp! - Allow custom 404 route to handle API route missing methods
Patch Changes
- #4703
d28f7013cThanks @bholmesdev! - Fix: [astro add] Apply fetch polyfill before running
Minor Changes
-
#4682
d1e695914Thanks @bholmesdev! - astro add - move configuration updates to final step -
#4549
255636cc7Thanks @altano! - Allow specifying custom encoding when using a non-html route. Only option before was 'utf-8' and now that is just the default. -
#4578
c706d845eThanks @bholmesdev! - Restart dev server when config file is added, updated, or removed
Patch Changes
Patch Changes
-
#4675
63e49c3b6Thanks @matthewp! - Prevent locking up when encountering invalid CSS -
#4684
919df13b9Thanks @natemoo-re! - Fixes regression introduced in #4646 with better cyclic reference detection -
#4683
cc242d3afThanks @Princesseuh! - Fixtsccompilation errors whenskipLibCheckwasn't enabled -
#4667
9290b2414Thanks @Holben888! - Fix framework components on Vercel Edge -
#4645
f27ca6ab3Thanks @bholmesdev! - Fix client-side scripts reloads on dev server in windows
Patch Changes
-
#4646
98f242cdcThanks @natemoo-re! - Add cyclic ref detection when serializing props -
#4656
6d845c353Thanks @matthewp! - Fix bug with usingassertas import identifier -
#4403
d31e72c3bThanks @JohnDaly! - Fix for components, declared with JSXMemberExpression nodes, that failed to hydrate due to incomplete 'component-export' metadata
Patch Changes
-
#4623
eb1862b4eThanks @delucis! - Improve third-party Astro package support -
#4643
307b7b97cThanks @matthewp! - Remove regression when there is duplicate client/server CSS -
#4584
29a5fdc15Thanks @bluwy! - Correctly escape paths in file names -
#4621
0068afb87Thanks @AllanChain! - Ensure SSR module is loaded before testing if it's CSS in dev
Patch Changes
-
#4519
a2e8e76c3Thanks @JuanM04! - Upgraded Shiki to v0.11.1 -
#4531
2d2e38e47Thanks @bluwy! - Remove hardcoded Vite middleware handling -
#4553
2f05f5d30Thanks @matthewp! - Include trailingSlash in astro:build:done hookThis change ensures that the
pagesprovided in theastro:build:donehook conform to thetrailingSlashandbuild.formatconfigs. -
#4526
046bfd908Thanks @bluwy! - Skip clean SSR output if page generation fails -
#4546
bb71be78dThanks @bholmesdev! - Update "Add an Adapter" help heading to "Add an SSR Adapter" -
#4548
69b640b87Thanks @bholmesdev! - Fix "failed to load for SSR" on styles when using tailwind -
#4535
ca28d7578Thanks @Princesseuh! - Add missingslotattributes to SVG definitions -
#4524
d431fbe4e- fix import in the config type declarations -
Updated dependencies [
a2e8e76c3]:- @astrojs/markdown-remark@1.1.1
Patch Changes
- #4507
4e1af3f0eThanks @Princesseuh! - Fiximport-meta.d.tsnot being included in the npm package
Minor Changes
-
#4352
cd154e447Thanks @matthewp! - Make Astro.url match the build.format configuration during the build -
#4423
d4cd7a59fThanks @bholmesdev! - Update Markdown type signature to match new markdown plugin,and update top-level layout props for better alignment -
#4474
ac0321824Thanks @bholmesdev! - Add "extends" to markdown plugin config to preserve Astro defaults -
#4138
839097c84Thanks @gtnbssn! - Makes remark-rehype options available in astro.config.mjs -
#4182
fcc36ac90Thanks @Alxandr! - Make type definitions available through package.json exports
Patch Changes
-
#4500
9874c7bf4Thanks @Princesseuh! - Updateastro checkto use latest version of the Astro language server -
#4439
77ce6be30Thanks @Princesseuh! - Add tsconfig templates for users to extend from -
#4499
1f42c0791Thanks @Princesseuh! - Fixtscnot being able to find Vite's import.meta types on Linux -
#4497
78e06c8ecThanks @bholmesdev! - Production build logging - Only log[code].htmlinstead of[code]/index.htmlfor 404 and 500 routes -
Updated dependencies [
ac0321824,839097c84]:- @astrojs/markdown-remark@1.1.0
Minor Changes
-
#4352
cd154e447Thanks @matthewp! - Make Astro.url match the build.format configuration during the build -
#4423
d4cd7a59fThanks @bholmesdev! - Update Markdown type signature to match new markdown plugin,and update top-level layout props for better alignment -
#4474
ac0321824Thanks @bholmesdev! - Add "extends" to markdown plugin config to preserve Astro defaults -
#4138
839097c84Thanks @gtnbssn! - Makes remark-rehype options available in astro.config.mjs -
#4182
fcc36ac90Thanks @Alxandr! - Make type definitions available through package.json exports
Patch Changes
-
#4439
77ce6be30Thanks @Princesseuh! - Add tsconfig templates for users to extend from -
Updated dependencies [
ac0321824,839097c84]:- @astrojs/markdown-remark@1.1.0-next.0
Patch Changes
-
#4457
9490f0e22Thanks @matthewp! - Include styles imported by hoisted scripts -
#4469
8a2d6958fThanks @kagankan! - Fix loadbaseoption in build -
#4451
a38a56829Thanks @bluwy! - Bump @astrojs/compiler dependency -
#4473
467108730Thanks @bluwy! - Remove optional chaining in astro-island -
#4475
78334b976Thanks @matthewp! - Fixes regression with JSX in Solid library -
#4458
aa555932bThanks @bluwy! - Supportvite.build.cssCodeSplit: falseoption -
#4422
85646918aThanks @bluwy! - Refactor CSS preprocess and deps HMR -
#4456
47e71ae8fThanks @Princesseuh! - Added an error message when the second argument of Astro.slots.render is not an array
Patch Changes
-
#4330
baa2ddd01Thanks @bluwy! - Warn hydration directive for Astro components in JSX -
#4427
b2e976f39Thanks @cameronmcefee! - Fix config types to allow falsy values in integrations list, to match docs -
#4385
8164fa6f1Thanks @krolebord! - Fix warning when using hooks inside the react components not exported as a function declaration -
#4445
df4e99928Thanks @bholmesdev! - Add "waiting for X integration" log for long-running integration hooks -
#4430
dc42f2c00Thanks @bholmesdev! - astro add - Fix third-party npm orgs, i.e.@example/integration -
#4441
ca0c7e8b8Thanks @Princesseuh! - Allow arbitrary strings on the target attribute -
#4446
27ac6a03aThanks @matthewp! - Deterministic CSS orderingThis makes our CSS link order deterministic. It uses CSS depth; that is how deeply a module import the CSS comes from, in order to determine which CSS is page-level vs. component-level CSS.
This is intended to match dev ordering where, because we do not bundle, the page-level CSS always comes after component-level.
-
#4426
f40065f51Thanks @matthewp! - Ensure index pages are generated on paginated results
Patch Changes
-
#4362
aa5118e85Thanks @joseph-lozano! - Allow user config to setmarkdown.draftsoption -
#4344
500332a42Thanks @bluwy! - Refactor static build config merge -
#4364
77b068086Thanks @bluwy! - Preserve all error stack lines -
#4405
a70f69a06Thanks @FredKSchott! - Refactor JSX build plugin, improve performance -
#4356
beed20be4Thanks @delucis! - Provide correct MIME type for dynamic endpoint routes in dev -
#4375
5e82f6c24Thanks @matthewp! - Fixes race condition between directives being defined
Patch Changes
-
#4324
45fdbc465Thanks @BurntCaramel! - Use TextEncoder instead of Buffer.byteLength() for Deno compatibility -
#4334
b55f76c1cThanks @matthewp! - Fix double injecting of head content in md pages -
#4329
0274b8d47Thanks @tony-sull! - Updates routing logic to allow multiple routes to match the same URL in SSR -
#4347
166b3b8a5Thanks @bholmesdev! - Fix MDXLayoutProps type signature for linting
Patch Changes
-
#4302
1d3a0a16fThanks @FredKSchott! - Revert "Ensure hydration scripts inside of slots render ASAP (#4288)" to fix Svelte integration bug -
#4284
73f367c77Thanks @FredKSchott! - Prevent preview if 'output: server' is configured
Patch Changes
-
#4268
f7afdb889Thanks @bholmesdev! - Align MD with MDX on layout props and "glob" import results:- Add
Contentto MDX - Add
fileandurlto MDX frontmatter (layout import only) - Update glob types to reflect differences (lack of
rawContentandcompiledContent)
- Add
-
#4265
8f845ca95Thanks @matthewp! - Prevents automatic trailingSlash appending on getStaticPaths produced pages -
#4288
c21810068Thanks @matthewp! - Ensure hydration scripts inside of slots render ASAP -
#4282
c0992e1feThanks @natemoo-re! - Fix bug where Astro's server runtime would end up in the browser -
#4272
24d2f7a6eThanks @natemoo-re! - Properly handle hydration for namespaced components -
#4289
3ca905174Thanks @bholmesdev! - [astro add] Setoutput: 'server'when adding adapter
Patch Changes
-
#4239
a9baa45afThanks @bluwy! - Fix Astro client scripts sourcemap 404 -
#4279
42fd6936cThanks @FredKSchott! - Handle "not found" imports without throwing an "Invalid URL" error -
#4273
0022f46b5Thanks @Princesseuh! - Fix build output adding/index.htmlat the end of endpoints route -
#4270
7127b1bb3Thanks @natemoo-re! - Make third-party integration names nicer when usingastro add
Patch Changes
-
#4247
714a8399eThanks @matthewp! - Return 404 status code for 404.astro in SSR -
#4240
561a34d91Thanks @matthewp! - Properly invalidate Astro modules when a child script updates in HMR -
#4234
c38e7f189Thanks @bluwy! - Remove dev server during build -
#4225
e918b3883Thanks @mayank99! -astro addnow supports-y
Patch Changes
3a7f2385eThanks @FredKSchott! - Add rawContent and compiledContent to MD layout props
Astro v1.0 is out! Read the official announcement post.
Note If you need help migrating an existing Astro project to the new Astro v1.0, check out our updated Migration Guide and full documentation website.
Features
Astro v1.0 includes a few new features and improvements since our original beta announcement back in April, including:
- SSR Builds: Server output is now stable and available for production use.
- Image Optimization: New
<Image />and<Picture />components available with@astrojs/image. - MDX Support: A standard syntax for mixing UI components in Markdown is available with
@astrojs/mdx. - Vite 3.0: An upgrade to our internal build engine, Vite.
Breaking Changes
Astro.canonicalURLhas been deprecated. Please useAstro.urlto construct your own canonical URL.- CSS Specificity is now preserved for scoped styles. See the migration guide for more details.
Warning Please visually inspect your site output to make sure everything is styled as expected. If not, find your scoped style and increase the selector specificity manually to match the old behavior.
- Components and JSX in Markdown has been deprecated. For long-term support you should migrate to the
@astrojs/mdxintegration. See the migration guide for more details. - The previously deprecated
<Markdown>component has been removed. It is now available as a separate package,@astrojs/markdown-component.
If you are coming from v0.25 or earlier, make sure you have read and followed the v0.26 Migration Guide, which contained several major breaking changes.
Patch Changes
- Updated dependencies [
04ad44563]:- @astrojs/markdown-remark@1.0.0
- @astrojs/telemetry@1.0.0
- @astrojs/webapi@1.0.0
Patch Changes
-
#4012
f207c417eThanks @natemoo-re! - AddsAstro.generatorwhich can be used to add a<meta name="generator">tag. -
#4201
25d36d955Thanks @matthewp! - Adds warning in dev when using client: directive on Astro component -
#4203
ec376369aThanks @natemoo-re! - Ensure JSX does not reference server entrypoint -
#4195
28ab273a3Thanks @bluwy! - Fix client build sourcemap generation -
#4189
5e71a8720Thanks @jablonski! - Fix custom 404 pages when usingastro preview(#4113)
Minor Changes
-
#4176
2675b8633Thanks @bholmesdev! - Support frontmatter injection for MD and MDX using remark and rehype plugins -
#4155
81c9ad9a6Thanks @kagankan! - Addvite.build.cssTaregtsupport for CSS build -
#4137
471c6f784Thanks @bholmesdev! - Speed up internal markdown builds with new vite-plugin markdown
Patch Changes
-
#4154
36223f663Thanks @natemoo-re! - ExposegetViteConfigfromastro/configto unblock usage with Vitest -
#4158
e569f0a5cThanks @natemoo-re! - Fix edge case where MDX components would be escaped -
#4157
025743849Thanks @natemoo-re! - Fix duplicated CSS when using HMR -
#4156
82a1063ccThanks @matthewp! - Add CSS to page when child component uses Astro.glob -
#4153
3321aace0Thanks @FredKSchott! - Improve an error message for getStaticPaths -
#4180
c56a9227cThanks @natemoo-re! - Fix edge case where Astro component would render [Object object] when using MDX -
#4136
9afa4611cThanks @natemoo-re! - Fix issue when using Fragment inside MDX -
Updated dependencies [
2675b8633,471c6f784,16034f0dd]:- @astrojs/markdown-remark@0.14.1
Patch Changes
-
#4108
08432d5b0Thanks @altano! - Allow globbed mdx files to have typed frontmatter -
#4125
5f3b3b44dThanks @natemoo-re! - Fix HMR of style blocks in Astro files. Updating a style block should no longer perform a full reload of the page. -
#4131
09eca9be5Thanks @matthewp! - Fixes use of multiple renderers when one throws -
#4141
65f2d3b4bThanks @FredKSchott! - fix windows "bad package export" error -
#4063
ec5518fe3Thanks @vikpe! - Addmdxextension to default generated Tailwind config.
Patch Changes
-
#4112
e33fc9bc4Thanks @matthewp! - Fix MDX working with a ts config file -
#4049
b60cc0538Thanks @natemoo-re! - ImproveinjectScripthandling for non-Astro pages -
#4105
9cc3a11c4Thanks @dimitrov-adrian! - Do not sendbodywithHEADorGETrequests when usingserveroutput. -
#4114
64432bcb8Thanks @Princesseuh! - Refactor@astrojs/mdxand@astrojs/markdown-remarkto use@astrojs/prisminstead of duplicating the code -
#4115
26cc0bbf7Thanks @natemoo-re! - Fix edge case with hoisted scripts and Tailwind during dev -
Updated dependencies [
64432bcb8]:- @astrojs/markdown-remark@0.14.0
Patch Changes
-
#4073
13b4f8ad8Thanks @matthewp! - Fixes use of @fontsource packages -
#4045
a397b981fThanks @tony-sull! - Adding support for custom "astro/client" type definitions in@astrojs/image -
#4028
c565465a9Thanks @alfredogonzalezmartinez! - Addurlandfileproperties toMarkdownContenttype -
#4072
a198028b0Thanks @matthewp! - Fixes Cloudflare throwing an error for process -
#4055
44694d8a9Thanks @matthewp! - Handle binary data request bodies in the Node adapter

The Astro v1.0.0 Release Candidate comes includes new features, tons of bug fixes, and a few breaking changes to be aware of.
Migration Guide: https://docs.astro.build/en/migrate/
Breaking Changes
- Astro now uses Vite 3, which comes with its own Migration Guide.
- Components and JSX expressions in
.mdfiles is no longer supported by default. It can be enabled by setting thelegacy.astroFlavoredMarkdownflag totrue. In the future, we will be pushing users to our new@astrojs/mdxIntegration for using components in Markdown. - ‘@astrojs/image’ integration released!
- Astro scoped styles now respect their authored specificity (see RFC0012). Please visually inspect your site after upgrading to confirm that styles are working as expected.
Astro.canonicalURLhas been replaced by the newAstro.urlhelper.- The Markdown
headersandgetHeaders()utils have been renamed toheadingsandgetHeadings(). - The deprecated
Markdowncomponent has been removed from core and is now available as@astrojs/markdown-component.
Read the full migration guide for more details on upgrading your existing project.
New Features
astro devHMR has been overhauled to provide more stable live reload behaviorastro deverror handling has been overhauled to provide a more seamless error handling experience- The new
outputconfiguration option builds to'static' | 'server'targets .htmlcomponents and pages are now supported.mdxcomponents and pages are now supported via@astrojs/mdxserveroutput now supports custom404and500pagesserveroutput now exposesAstro.clientAddressto get the current IP address per request
Patch Changes
-
#3988
9841c21e8Thanks @Princesseuh! - Fix certain characters showing incorrectly inastro check -
#4000
1c1b9da62Thanks @tony-sull! - public assets should always take priority over page routes in SSR deployments -
#4042
7e5ac1f45Thanks @matthewp! - Ensure the before-hydration scripts are built -
#3944
e82ff13f1Thanks @mihkeleidast! - Add export keyword to astro config file stub created by add cli command -
#3942
21462feb4Thanks @AllanChain! - Use a base middleware for better base path handling in dev. -
#3991
4dd341c8aThanks @natemoo-re! - #3859 Overhaul Astro error handling, using Vite's built-in error overlay when possible -
#4024
1215e731bThanks @natemoo-re! - BREAKING Implement RFC0012 to preserve authored specificity for Astro scoped styles.If you use a mix of global styles and Astro scoped styles, please visually inspect your site after upgrading to confirm that styles are working as expected.
If you previously relied on Astro's scoped styles to increase the specificity of your selectors, please update your selectors to use an additional class. For example, updating
divtodiv.my-classwill match the previous behavior. -
#4046
c811be49aThanks @matthewp! - Adds warnings for legacy markdown behavior -
#4009
01ba07d8fThanks @matthewp! - Fixes Lit compat with Vite 3.0.1 -
#4008
399d7e269Thanks @bholmesdev! - Avoid parsing JSX, components, and Astro islands when using "plain" md mode. This bringsmarkdown.mode: 'md'in-line with our docs description. -
#4047
453c026aaThanks @matthewp! - Perf: move getStaticPaths call during the build to during page generation -
#3974
54865612eThanks @Princesseuh! - Added missingmediaattributes from the JSX definitions for themetaelement -
#3932
27ee8b97aThanks @natemoo-re! - Overhaul HMR handling for more stable live reload behavior -
#4044
6f88597c3Thanks @lostra01! - Added missing "loading" attribute to IFrameHTMLAttributes -
#3995
b2b367c96Thanks @bholmesdev! - Support YAML frontmatter in MDX files -
#3976
fbef6a7f7Thanks @natemoo-re! - Fixdefine:varsbugs with bothstyleandscript -
#4023
4ca6a0933Thanks @matthewp! - Fixes Node adapter to accept a request body -
#4010
d503c5bf3Thanks @matthewp! - Allow defining aliases with tsconfig -
#4032
beddf073bThanks @arimgibson! - Fix: find a hosting network differently based on Node version -- adjusted for Node v18.4+ -
#3867
7250e4e86Thanks @natemoo-re! - Add support for.htmlcomponents and pages -
#3959
ddefb172fThanks @FredKSchott! - Deprecate Astro.canonicalURL, in favor of Astro.url instead. -
#3968
95eaa207dThanks @bholmesdev! - Improve warning logs on astro.config change -
#3959
ddefb172fThanks @FredKSchott! - Add Astro.url helper for getting the request URL -
#4031
6e27a5fdcThanks @natemoo-re! - BREAKING Renamed Markdown utility functiongetHeaders()togetHeadings(). -
Updated dependencies [
ba11b3399,399d7e269,00fab4ce1,6e27a5fdc]:- @astrojs/markdown-remark@0.13.0
Patch Changes
-
#3937
31f9c0bf0Thanks @delucis! - Roll back supported Node engines -
#3588
5d0edfc3bThanks @charlesvdv! - Fix missing props (url, file) in markdown layout -
#3960
ceda294e1Thanks @matthewp! - Fixes hydration of maps/sets -
#3958
8eba6d9d9Thanks @Princesseuh! - Fix JSX definitions being too strict as to what an element is, which lead to type issues in certain cases (Markdown imports, JSX components etc) -
#3915
f5d4ebf0eThanks @natemoo-re! - Fix metadata handling for building MDX files -
#3930
3acb9ec26Thanks @matthewp! - Include hoisted scripts inside Astro.glob in dev -
#3906
b37695c34Thanks @Princesseuh! - Fixed many long-standing issues withastro check- Fixed it not working on Windows at all
- Fixed red squiggles not showing in the proper place in certain contexts, notably with strings using non-latin characters
- Fixed IDE links pointing to the wrong line number and character
- Fixed line numbers being off by one
- Fixed IDE links not working when the project wasn't at the root of the folder
Additionally added some features:
- Added more pretty colors
- Fixed it not working at all on Windows
- Warnings and hints are now printed alongside errors
- Surrounding lines are now shown when relevant (aka not empty)
-
#3955
92b48b152Thanks @matthewp! - Set import.meta.env.BASE_URL in dev mode -
#3963
5fde2fd8bThanks @matthewp! - Makes the Debug component's styles be inlined -
Updated dependencies [
31f9c0bf0,07fb544da]:- @astrojs/prism@0.6.1
- @astrojs/telemetry@0.4.1
- @astrojs/markdown-remark@0.12.0
Patch Changes
-
#3922
7094d6a45Thanks @natemoo-re! - Properly handlefalseinclass:list -
#3927
7c5c4106dThanks @Princesseuh! - Updatedastro/componentsexports to a.tsfile so it's automatically typed
Patch Changes
-
#3918
6a7a17f73Thanks @natemoo-re! - Update@astrojs/compiler, fixing various edge cases around nested expressions, tables, and conditional slots. See the@astrojs/compiler@0.19.0 changelogfor more information. -
Updated dependencies [
01a55467d]:- @astrojs/markdown-remark@0.11.7
Patch Changes
-
#3902
d8af02a94Thanks @bholmesdev! - Fix: markdown "require is not defined" issue -
#3914
b48767985Thanks @ran-dall! - Rollback supportednode@16version. Minimum versions are nownode@14.20.0ornode@16.14.0. -
Updated dependencies [
ca45c0c27,b48767985]:- @astrojs/markdown-remark@0.11.6
- @astrojs/prism@0.6.0
- @astrojs/telemetry@0.4.0
Patch Changes
-
#3891
9cf7e4064Thanks @matthewp! - Fix Safari client:visible refresh bug -
#3851
21869a614Thanks @matthewp! - Replaces vite/client types with astro/client -
#3871
1cc5b7890Thanks @natemoo-re! - Update supportednodeversions. Minimum versions are nownode@14.20.0ornode@16.16.0. -
#3892
7c49096e8Thanks @natemoo-re! - Update@astrojs/compilerto latest -
Updated dependencies [
1cc5b7890]:- @astrojs/prism@0.5.0
- @astrojs/telemetry@0.3.0
- @astrojs/markdown-remark@0.11.4
Patch Changes
-
#3842
08fa0772Thanks @bholmesdev! - Docs: add complete "adapter" configuration reference -
#3860
c2c4e5c2Thanks @matthewp! - Fixes response.arrayBuffer() handling in large pages -
#3854
b012ee55Thanks @bholmesdev! - [astro add] Support adapters and third party packages -
#3848
502f0631Thanks @matthewp! - Allow importing the Image component from @astrojs/image -
#3873
957fb505Thanks @bholmesdev! - Fix hydration for SSR components that return null -
#3801
b84bd7dbThanks @Princesseuh! - Update JSX definitions with element specific types and added some missing attributes -
#3837
5afb8076Thanks @natemoo-re! - Fix usage of slots inside expressions -
Updated dependencies [
eedb32c7]:- @astrojs/telemetry@0.2.5
Patch Changes
-
#3821
c2165c34Thanks @matthewp! - Fix for putting the into its own component -
#3841
820a26ddThanks @bholmesdev! - Fix: add default content type to endpoints with { body } shorthand -
#3839
cd3f6348Thanks @bholmesdev! - Fixclient:visibledirective in safari -
Updated dependencies [
e4b2dca1]:- @astrojs/telemetry@0.2.4
Patch Changes
- #3799
5fe52737Thanks @natemoo-re! - Fix internal error for MDX integration
Patch Changes
- #3788
f4943e0fThanks @tony-sull! - Adds support for the newastrojs/imageintegration
Patch Changes
-
#3779
192c4bcfThanks @FredKSchott! - Fix an issue with throwAndExit not awaiting -
#3706
032ad1c0Thanks @natemoo-re! - Internal changes needed to support@astrojs/mdx -
#3768
913591d1Thanks @FredKSchott! - Fix an issue with unfriendly config validation error output -
Updated dependencies [
8045c8ad]:- @astrojs/telemetry@0.2.3
Patch Changes
-
#3767
1eab496eThanks @tony-sull! - Updates an error handler to expect updated@astrojs/litbehavior -
#3763
54cd6b8dThanks @tony-sull! - Fixes howinjectRouteparses route patterns on Windows -
#3750
dd176ca5Thanks @FredKSchott! - Add basic error reporting to astro telemetry -
Updated dependencies [
dd176ca5]:- @astrojs/telemetry@0.2.2
Patch Changes
-
#3715
4d6d8644Thanks @FredKSchott! - Update "astro add" output to remove confusing multi-select prompt. -
#3715
4d6d8644Thanks @FredKSchott! - Update the help output to improve formatting -
#3713
ebd7e7adThanks @FredKSchott! - Update telemetry to support a more anonymized project id.anonymousProjectIdis now hashed based on anonymous git data instead of your git remote URL. -
Updated dependencies [
ebd7e7ad]:- @astrojs/telemetry@0.2.0
Patch Changes
-
#3696
3daaf510Thanks @matthewp! - Support for streaming responsesAstro supports streaming in its templates. Any time Astro encounters an async boundary it will stream out HTML that occurs before it. For example:
--- import LoadTodos from '../components/LoadTodos.astro'; --- <html> <head> <title>App</title> </head> <body> <LoadTodos /> </body> </html>In this arbtrary example Astro will streaming out the
<head>section and everything else until it encounters<LoadTodos />and then stop. LoadTodos, which is also an Astro component will stream its contents as well; stopping and waiting at any other asynchronous components.As part of this Astro also now supports async iterables within its templates. This means you can do this:
<ul> {(async function * () { for(const number of numbers) { await wait(1000); yield <li>Number: {number}</li> yield '\n' } })()} </ul>Which will stream out
<li>s one at a time, waiting a second between each. -
#3700
47c81effThanks @matthewp! - Make Astro.redirect use a 302 status code
Patch Changes
-
#3652
7373d61cThanks @natemoo-re! - Add renderer support for passing named slots to framework components.BREAKING: integrations using the
addRenderer()API are now passed all named slots viaRecord<string, string>rather thanstring. Previously only the default slot was passed. -
#3649
446f8c4fThanks @dc7290! - Added test for dir parameter in astro:build:done -
#3679
fa7ed3f3Thanks @matthewp! - Moves head injection to happen during renderingThis change makes it so that head injection; to insert component stylesheets, hoisted scripts, for example, to happen during rendering than as a post-rendering step.
This is to enable streaming. This change will only be noticeable if you are rendering your
<head>element inside of a framework component. If that is the case then the head items will be injected before the first non-head element in an Astro file instead.In the future we may offer a
<Astro.Head>component as a way to control where these scripts/styles are inserted.
Patch Changes
-
#3685
3d554fdbThanks @bholmesdev! - Fix PostCSS config not applied to Svelte component by default -
#3665
9a813268Thanks @matthewp! - Allow TypeScript inside script tagsThis makes it so that you can use TypeScript inside of script tags like so:
<script> interface Person { name: string; } const person: Person = { name: 'Astro', }; console.log(person); </script>Note that the the VSCode extension does not currently support this, however.
-
#3633
921d9a27Thanks @FredKSchott! - Fix a bug withastro add reactadding a too-complex semver to your package.json -
#3676
85c33751Thanks @matthewp! - Allow specifying entryFileNames for client JS
Patch Changes
-
#3667
df02fad1Thanks @bholmesdev! - Fix: add @nanostores/preact to ALWAYS_NOEXTERNAL list for easier onboarding -
#3678
89884540Thanks @matthewp! - Fix regression with SSRManifest and client assets -
#3658
aeab8909Thanks @matthewp! - Inlines small hoisted scriptsThis enables a perf improvement, whereby small hoisted scripts without dependencies are inlined into the HTML, rather than loaded externally. This uses
vite.build.assetInlineLimitto determine if the script should be inlined.
Patch Changes
-
#3675
ef6282d5Thanks @hippotastic! - Fiximport.meta.envalso without trailing dot -
#3673
ba5ad785Thanks @hippotastic! - Fix react dependencies to improve test reliability
Patch Changes
-
#3625
f5afaf24Thanks @matthewp! - Significantly improved build performanceThis change reflects in a significantly improved build performance, especially on larger sites.
With this change Astro is not building everything by statically analyzing
.astrofiles. This means it no longer needs to dynamically run your code in order to know what JavaScript needs to be built.With one particular large site we found it to build 32% faster.
-
#3612
fca58cfdThanks @bholmesdev! - Fix: "vpath" import error when building for netlify edge -
#3650
d9f6dcf6Thanks @natemoo-re! - Properly catch falsy components -
#3610
6ab749beThanks @hippotastic! - Add component hydration in Markdown E2E tests -
#3620
05aa7244Thanks @hippotastic! - Remove extra newlines around Markdown components -
Updated dependencies [
80c71c7c,fca58cfd,9c8a7c0b,9c8a7c0b,48e67fe0,05aa7244]:- @astrojs/markdown-remark@0.11.3
- @astrojs/telemetry@0.1.3
Patch Changes
-
d1f3406d- Add support for theinjectRoutehook proposed in RFC0023. Feature documentation is available in #704 -
#3397
48161b77Thanks @happycollision! - MarkdownInstance: Persist frontmatter type into the return of.default() -
#3595
330fef44Thanks @matthewp! - Handle importing multiple CSS packages in same bundle
Patch Changes
-
#3593
0e2314d8Thanks @matthewp! - Fixes uses of inline hoisted scripts in SSR -
#3590
d46f8fb1Thanks @okikio! - Add support for optional integrationsBy making integration optional, Astro can now ignore null, undefined or other falsy "Integration" values instead of giving an internal error most devs can't and/or won't understand.
This also enables conditional integrations, e.g.
integration: [ // Only run `compress` integration when in production environments, etc... import.meta.env.production ? compress() : null, ];
Patch Changes
-
#3552
3eb96a7aThanks @tony-sull! - Fix: Astro.site should default to localhost when not provided in a project's config -
#3540
78164033Thanks @tony-sull! - Fix: showing a more helpful error message when an import in an Astro component could not be resolved -
#3547
a83d5817Thanks @bholmesdev! - Fix: show "unable to find network to expose" with local network log when using --host without suitable networks -
Updated dependencies [
76fb01cf,c549f161]:- @astrojs/markdown-remark@0.11.1
Patch Changes
-
#3537
51c60de7Thanks @matthewp! - Fixes imported CSS packages in frontmatter -
#3492
a87ce441Thanks @natemoo-re! - - Improvements to how Astro handles style updates in HMR- Fixes a Svelte-specific HMR bug that caused Svelte component styles to be lost once a .astro file was hot reloaded
-
#3533
d7688f05Thanks @matthewp! - Prevent minifying server JS
Patch Changes
-
#3507
cf2fb300Thanks @natemoo-re! - Silence noisy build warnings aboutoptimizeDeps.include -
#3506
d41540ccThanks @natemoo-re! - Fix issue where generatedlinktags would have an invalid closing tag -
#3498
4a23b5aaThanks @matthewp! - Fixes use of import.meta.env.SITE -
#3503
207f58d1Thanks @williamtetlow! - Aliasfrom 'astro'imports to'@astro/types'Update Deno and Netlify integrations to handle vite.resolves.alias as an array
Patch Changes
-
#3496
d588bc4aThanks @matthewp! - Update rollup to fix default param regression -
#3464
9c2ba137Thanks @bholmesdev! - Add warning on startup whenvite.server.fs.strictis disabled -
#3427
10b25890Thanks @tony-sull! - Fixes HMR support for inline scripts in Astro components on Linux and OSX -
#3505
2b35650bThanks @bholmesdev! - Fix newline characters in SolidJS JSX attributes (ex: multiline CSS classes)
Patch Changes
-
#3459
efccebb9Thanks @matthewp! - Forces the correct mime type for CSS in HMR -
#3486
119ecf8dThanks @hippotastic! - Fix components in markdown regressions -
#3462
d145b868Thanks @bholmesdev! - Remove the rss() helper from getStaticPaths. Using rss() now prints an error pointing to the new @astrojs/rss documentation. -
#3455
e9a77d86Thanks @natemoo-re! - Implements improved hydration event system, meaning hydration for client:only and nested frameworks should be see significant stability improvements -
Updated dependencies [
119ecf8d]:- @astrojs/markdown-remark@0.10.2
Patch Changes
-
#3471
75fa58f1Thanks @hippotastic! - Fix using Vite env var names in Markdown -
#3477
429b65d6Thanks @hippotastic! - Prevent*/from breaking HTML comments in Markdown
Minor Changes
- #3452
47d1a8d5Thanks @bholmesdev! - Add content parsing helpers to imported markdown files. This exposes both the raw markdown content when using rawContent() and the parsed Astro syntax when using compiledContent()
Patch Changes
-
#3439
ac3c60d4Thanks @matthewp! - Fixes importing npm packages within CSSThis change fixes a longstanding bug where the string
VITE_ASSETwas left in CSS when trying to import CSS packages. The fix comes thanks to an upstream Vite feature that allows us to hand off most of the CSS bundling work to Vite. -
#3438
79b9ebc8Thanks @userquin! - Expose route dist URL on SSG
Patch Changes
-
#3444
51db2b9bThanks @bholmesdev! - Fix: markdown imports failing due to internal dependency issue -
Updated dependencies [
51db2b9b]:- @astrojs/markdown-remark@0.10.1
Patch Changes
-
#3426
946630a1Thanks @bholmesdev! - Logs: Add "ssr.noExternal" hint for CSS loaded from npm packages -
#3434
4e3b405eThanks @natemoo-re! - Respect user's configured vite logLevel during build -
#3423
463a1c21Thanks @matthewp! - Fix relative inline scripts on Windows -
#3384
296fff2cThanks @natemoo-re! - Fix long-standing bug where aclassattribute inside of a spread prop will cause duplicateclassattributes -
#3433
4ca60e93Thanks @natemoo-re! - Fix build issue where hoisted scripts would be duplicated per page -
#3422
0209d627Thanks @tony-sull! - Updates component hydration scripts to use absolute paths for script imports -
#3410
cfae9760Thanks @natemoo-re! - Significantally more stable behavior for "Markdown + Components" usage, which now handles component serialization much more similarly to MDX. Also supports switching between Components and Markdown without extra newlines, removes wrapping<p>tags from standalone components, and improves JSX expression handling. -
Updated dependencies [
cfae9760]:- @astrojs/markdown-remark@0.10.0
Patch Changes
Patch Changes
-
#3392
2939be5fThanks @matthewp! - Allows vite config to override options used in the build -
#3401
0d3c673dThanks @tony-sull! - Adding support for config.build.format to the dev server -
#3399
1bf12260Thanks @bholmesdev! - Update "building for SSR..." log for SSG users to say "building entrypoints for prerendering..." -
#3391
cf8015eaThanks @natemoo-re! - Fix #3309 default logger locale behavior.
Patch Changes
-
#3350
e48aa2fdThanks @FredKSchott! - Improve error hints for packages that should be added tovite.ssr.noExternal -
#3348
43e411eeThanks @natemoo-re! - Update defaultvite.optimizeDeps.excludeto keepnode-fetchfrom being optimized -
#3336
ccea6a0aThanks @matthewp! - Fixes HMR of hoisted script tags -
#3331
e22f7364Thanks @tony-sull! - Fixes an issue preventing custom 404 pages in dev -
#3339
3dc68e14Thanks @thepassle! - fixes injectscript in ssr mode -
#3332
d04928e8Thanks @FredKSchott! - Fix animport from '../core/build/types';error -
f40705d9Thanks @matthewp! - Fix for swallowed SolidJS errors -
#3300
b463ddb3Thanks @tony-sull! - Resolve .astro components by module ID to support the use of Astro + framework components in an NPM package -
#3352
86855061Thanks @JuanM04! - ExportViteUserConfigtype -
#3337
678c2b75Thanks @bholmesdev! - Fix: remove hydration failures on React v18 by exposing the "client" directive from Astro core.
Patch Changes
- #3286
e5f6de4eThanks @thepassle! - Adds pages param to the astro:build:setup integration hook
Patch Changes
-
1032e450Thanks @FredKSchott! - Introduce new @astrojs/rss package for RSS feed generation! This also adds a new global env variable for your project's configured "site": import.meta.env.SITE. This is consumed by the RSS feed helper to generate the correct canonical URL. -
1032e450Thanks @FredKSchott! - Internal: removedshorthash -
1032e450Thanks @FredKSchott! - Internal: replacesserialize-javascriptwithdevalue -
82345fddThanks @FredKSchott! - Deprecate the markdown component in SSR.This was not working before, so now we make it official by throwing with a clean error message. See https://docs.astro.build/en/guides/markdown-content/#markdown-component to learn more.
Patch Changes
-
#3244
48a35e60Thanks @matthewp! - Consolidates hydration scripts into one -
#3256
f76038acThanks @matthewp! - Adds anonymous telemetry data to the cli -
#3234
de123b28Thanks @JuanM04! - Moved some type fromastroto@astrojs/markdown-remark -
Updated dependencies [
de123b28,f76038ac,de123b28]:- @astrojs/markdown-remark@0.9.3
- @astrojs/telemetry@0.1.0
Patch Changes
- #3241
d25dc4c4Thanks @tony-sull! - Fix a bug in define:vars preventing variables from being included in rendered styles
Patch Changes
-
#3207
22cb4b7bThanks @matthewp! - Disables file watching during the build -
#3191
205d1f07Thanks @JuanM04! - Added better types to importing Markdown -
#3183
7a61977dThanks @bholmesdev! - Support "astro add" before installing project dependencies -
#3209
fdd607c5Thanks @Princesseuh! - Addis:rawto AstroBuiltinAttributes -
#3198
1a86e77cThanks @JuanM04! - Markdown file.url now respectstrailingSlashandbase -
#3187
75dab3caThanks @bholmesdev! - Fix: remove online editor configs (stackblitz and code sandbox) from create-astro output -
#3205
e4bb2767Thanks @Princesseuh! - Added Astro attributes to SVG elements in JSX definition -
#3170
19667c45Thanks @matthewp! - Netlify Edge: Forward requests for static assets -
#3186
2b702d6aThanks @bholmesdev! - Fix: astro add generating "astro.config.mjs" outside project root
Patch Changes
- #3171
908fffb5Thanks @natemoo-re! - Fix various edge cases in the compiler, upgrading to@astrojs/compiler@0.14.2. Read the full changelog.
Patch Changes
- #3156
637919c8Thanks @tony-sull! - Adds subpath to assets/scripts when statically generating
Patch Changes
-
#3152
9ba1f4f8Thanks @bholmesdev! - Fix JSX expression inconsistencies within markdown files -
#3141
0247b542Thanks @bholmesdev! - Astro internals: remove all legacy build logic from the codebase, now that the legacy build flag has been removed -
Updated dependencies [
9ba1f4f8]:- @astrojs/markdown-remark@0.9.2
Minor Changes
-
#3078
d33e1778Thanks @FredKSchott! - Support the "del" API method, because "delete" is a reserved word. -
#3078
d33e1778Thanks @FredKSchott! - Add support for an "all" API method, to handle all requests
Patch Changes
-
#3094
564caf24Thanks @bholmesdev! - Expose "metadata" to component integrations renderToStaticMarkup function -
#3068
81e210e0Thanks @FredKSchott! - Fix an issue around build not respecting your base config -
Updated dependencies [
53162534]:- @astrojs/markdown-remark@0.9.0
Patch Changes
815d62f1Thanks @FredKSchott! - no changes.
Patch Changes
-
#3026
4b0f27d9Thanks @matthewp! - Fix for adding set-cookie multiple times -
#3020
c773dcdeThanks @tony-sull! - Add support for advanced CSS imports with?rawand?url⚠️WARNING⚠️: Be careful when bypassing Astro's built-in CSS bundling! Styles won't be included in the built output - this is best used in combination with
set:htmlto inline styles directly into the built HTML page. -
#3022
8c04ff1fThanks @matthewp! - Allows adapters to export default -
#3021
7e9d82d7Thanks @matthewp! - Warn when attempting to access headers in SSG mode
Patch Changes
-
#3001
25cc9218Thanks @natemoo-re! - Fix relative config handling with the--configflag -
#3008
8bd49c95Thanks @JuanM04! - Updated integrations'astro:build:donehook: now it matches the client dist when using SSR -
#3011
c6f8bce7Thanks @matthewp! - Fixes dynamic routes in the Netlify adapter -
#2958
d0777ad3Thanks @aFuzzyBear! - Addastro docscommand which opens the Astro docs in your preferred browser.
Patch Changes
572ca3dcThanks @FredKSchott! - fix markdown issue with parsing components in setup
Patch Changes
bc12edf0Thanks @FredKSchott! - Add missing entry to "files" field in package.json
Major Changes
- #2979
9d7a4b59Thanks @FredKSchott! - Welcome to the Astro v1.0.0 Beta! Read the official announcement for more details.
Migration Guide & What's New: https://docs.astro.build/en/migrate/#migrate-to-v026 Full Changelog: https://github.com/withastro/astro/blob/main/packages/astro/CHANGELOG.md#0260
Patch Changes
-
#2894
9d6e0b5dThanks @FredKSchott! - Add the "--experimental-integrations" flag to enable 3rd-party integrations. -
#2893
f2684512Thanks @FredKSchott! - tailwind: add a default "contents" configuration that works for most Astro projects
Patch Changes
- #2891
a0d67b1dThanks @natemoo-re! - Add missingexecadependency
Upgrading from v0.24 or earlier? Check out the Migration Guide.
Breaking & Minor Changes
-
#2820 Thanks @FredKSchott! - New Astro Integrations System! Full Documentation
-
#2849
72ef7ae6Thanks @natemoo-re! - Introduce newastro addcommand to automatically configure integrations.npx astro add -
#2833
79545412Thanks @natemoo-re! - This PR introduces a new internal CSS parser for@astrojs/compiler. Seewithastro/compiler#329for more details.This fixes Astro's support for modern CSS syntax like
@container,@layer, and nesting. Note While Astro now correctly parses this modern syntax, it does not automatically compile features for browser compatability purposes. -
#2824
0a3d3e51Thanks @bholmesdev! - Change shiki to our default markdown syntax highlighter. This includes updates to all relevant starter projects that used Prism-specific styles.
Patch Changes
-
#2879
80034c6cThanks @matthewp! - Netlify AdapterThis change adds a Netlify adapter that uses Netlify Functions. You can use it like so:
import { defineConfig } from 'astro/config'; import netlify from '@astrojs/netlify/functions'; export default defineConfig({ adapter: netlify(), }); -
#2871
5029382aThanks @FredKSchott! - Fix a bug where tailwind integration wouldn't apply to markdown pages -
#2852
96372e6bThanks @bholmesdev! - Fix "isSelfAccepting" exception when using the new @astrojs/react integration in development -
#2798
4c25a1c2Thanks @matthewp! - Implement APIs for headers for SSR flag -
#2855
5e52814dThanks @matthewp! - Adds support for the Node adapter (SSR)This provides the first SSR adapter available using the
integrationsAPI. It is a Node.js adapter that can be used with thehttpmodule or any framework that wraps it, like Express.In your astro.config.mjs use:
import nodejs from '@astrojs/node'; export default { adapter: nodejs(), };After performing a build there will be a
dist/server/entry.mjsmodule that works like a middleware function. You can use with any framework that supports the Noderequestandresponseobjects. For example, with Express you can do:import express from 'express'; import { handler as ssrHandler } from '@astrojs/node'; const app = express(); app.use(handler); app.listen(8080); -
#2859
c781b12fThanks @natemoo-re! - Ensure private, internal APIs are not enumerable -
#2835
77ebab8bThanks @natemoo-re! - Fix missingpostcss-load-configdependency -
#2878
2db97f10Thanks @bholmesdev! - Move the built-inPrismcomponent fromastro/componentsto@astrojs/prism/component. -
#2857
1061d647Thanks @bholmesdev! - Improve granularity of production build logs. This now lists:- the "data collection" build step, with timeout warnings for larger imports. This is useful for understanding large
import.meta.globcalls. - the Vite client bundling step. This logs all Vite production build info to clarify what assets are built alongside your HTML.
- the route generation step, complete with all output HTML files for a given input file. This is especially useful when debugging
getStaticPaths. - fixes "0 pages in Infinityms" log when building to SSR
- the "data collection" build step, with timeout warnings for larger imports. This is useful for understanding large
-
#2825
1cd7184cThanks @hlynursmari1! - Fix island deduplication ignoring props.Re-resolves an issue initially patched in https://github.com/withastro/astro/pull/846 but seemingly lost in the 0.21.0 mega-merge (https://github.com/withastro/astro/commit/d84bfe719a546ad855640338d5ed49ad3aa4ccb4).This change makes the component render step account for all props, even if they don't affect the generated HTML, when deduplicating island mounts. -
#2873
e4025d1fThanks @matthewp! - Improves the build by building to a single file for rendering -
#2815
7b9d042dThanks @matthewp! - Allows dynamic routes in SSR to avoid implementing getStaticPaths -
#2875
55712277Thanks @FredKSchott! - Generalize output assets to avoid adblocker false positives -
#2848
981e2a83Thanks @FredKSchott! - add missing injected "page" scripts into markdown pages -
#2872
098f6f6bThanks @bholmesdev! - FixisSelfAcceptingerrors when using the Preact integration with the Astro dev server -
Updated dependencies [
0a3d3e51,2db97f10,d763ec18]:- @astrojs/markdown-remark@0.7.0
- @astrojs/prism@0.4.1
Patch Changes
-
#2871
5029382aThanks @FredKSchott! - Fix a bug where tailwind integration wouldn't apply to markdown pages -
#2855
5e52814dThanks @matthewp! - Adds support for the Node adapter (SSR)This provides the first SSR adapter available using the
integrationsAPI. It is a Node.js adapter that can be used with thehttpmodule or any framework that wraps it, like Express.In your astro.config.mjs use:
import nodejs from '@astrojs/node'; export default { adapter: nodejs(), };After performing a build there will be a
dist/server/entry.mjsmodule that works like a middleware function. You can use with any framework that supports the Noderequestandresponseobjects. For example, with Express you can do:import express from 'express'; import { handler as ssrHandler } from '@astrojs/node'; const app = express(); app.use(handler); app.listen(8080); -
#2859
c781b12fThanks @natemoo-re! - Ensure private, internal APIs are not enumerable -
#2878
2db97f10Thanks @bholmesdev! - Move the built-inPrismcomponent fromastro/componentsto@astrojs/prism/component. -
#2857
1061d647Thanks @bholmesdev! - Improve granularity of production build logs. This now lists:- the "data collection" build step, with timeout warnings for larger imports. This is useful for understanding large
import.meta.globcalls. - the Vite client bundling step. This logs all Vite production build info to clarify what assets are built alongside your HTML.
- the route generation step, complete with all output HTML files for a given input file. This is especially useful when debugging
getStaticPaths. - fixes "0 pages in Infinityms" log when building to SSR
- the "data collection" build step, with timeout warnings for larger imports. This is useful for understanding large
-
#2873
e4025d1fThanks @matthewp! - Improves the build by building to a single file for rendering -
#2875
55712277Thanks @FredKSchott! - Generalize output assets to avoid adblocker false positives -
#2872
098f6f6bThanks @bholmesdev! - FixisSelfAcceptingerrors when using the Preact integration with the Astro dev server -
Updated dependencies [
2db97f10,d763ec18]:- @astrojs/prism@0.4.1-next.0
- @astrojs/markdown-remark@0.7.0-next.1
Patch Changes
-
#2852
96372e6bThanks @bholmesdev! - Fix "isSelfAccepting" exception when using the new @astrojs/react integration in development -
#2848
981e2a83Thanks @FredKSchott! - add missing injected "page" scripts into markdown pages
Patch Changes
- #2835
77ebab8bThanks @natemoo-re! - Fix missingpostcss-load-configdependency
Minor Changes
-
#2833
79545412Thanks @natemoo-re! - This PR introduces a new internal CSS parser for@astrojs/compiler. Seewithastro/compiler#329for more details.This fixes Astro's support for modern CSS syntax like
@container,@layer, and nesting. Note While Astro now correctly parses this modern syntax, it does not automatically compile features for browser compatability purposes. -
#2824
0a3d3e51Thanks @bholmesdev! - Change shiki to our default markdown syntax highlighter. This includes updates to all relevant starter projects that used Prism-specific styles.
Patch Changes
-
#2798
4c25a1c2Thanks @matthewp! - Implement APIs for headers for SSR flag -
#2825
1cd7184cThanks @hlynursmari1! - Fix island deduplication ignoring props.Re-resolves an issue initially patched in https://github.com/withastro/astro/pull/846 but seemingly lost in the 0.21.0 mega-merge (https://github.com/withastro/astro/commit/d84bfe719a546ad855640338d5ed49ad3aa4ccb4).This change makes the component render step account for all props, even if they don't affect the generated HTML, when deduplicating island mounts. -
#2815
7b9d042dThanks @matthewp! - Allows dynamic routes in SSR to avoid implementing getStaticPaths -
Updated dependencies [
0a3d3e51]:- @astrojs/markdown-remark@0.7.0-next.0
Patch Changes
-
#2797
58d8686eThanks @matthewp! - Fix for projects with a folder name containing a space -
#2785
2c4fd919Thanks @bholmesdev! - Update Astro.props to show object properties on console.log(Astro.props), interating over properties, and anything else outside direct key access -
#2790
6b34840dThanks @natemoo-re! - Improveset:htmlbehavior fornullandundefinedvalues -
#2772
b4d34e2dThanks @FredKSchott! - Improve build performance, especially on large sites -
#2772
b4d34e2dThanks @FredKSchott! - Surface vite warnings to the user
Minor Changes
-
#2760
77b9c953Thanks @bholmesdev! - Introduce a new --host flag + host devOption to expose your server on a network IP -
af075d81Thanks @natemoo-re! - Visual redesign of theastro devCLI, including newastro --helpandastro --versionoutputs.These changes introduce a new startup screen, make it more obvious when a file triggers in-place HMR (
update) or a full reload (reload), and improve the way Astro surfaces errors during dev. -
#2705
72c2c86eThanks @natemoo-re! - New default build strategyThis change marks the "static build" as the new default build strategy. If you are unfamiliar with this build strategy check out the migration guide on how to change your code to be compatible with this new bulid strategy.
If you'd like to keep using the old build strategy, use the flag
--legacy-buildboth in yourastro devandastro buildscripts, for ex:{ "scripts": { "build": "astro build --legacy-build" } }Note that the legacy build is deprecated and will be removed in a future version. You should only use this flag until you have the time to migration your code.
-
#2705
72c2c86eThanks @natemoo-re! - ## Updated<head>and<body>behaviorSince
astro@0.21, Astro placed certain restrictions on what files could use<head>or<body>tags. Inastro@0.24, the restrictions have been lifted. Astro will be able to correctly handle<head>and<body>tags in any component, not just those insrc/pages/orsrc/layouts/. -
#2747
05b66bd6Thanks @natemoo-re! - Escape HTML inside of expressions by default. Please see our migration guide for more details.
Patch Changes
-
#2695
ae8d9256Thanks @natemoo-re! - UpdateAstro.slotsAPI with new publichasandrendermethods.This is a backwards-compatible change—
Astro.slots.defaultwill still betrueif the component has been passed adefaultslot.if (Astro.slots.has('default')) { const content = await Astro.slots.render('default'); } -
#2755
10843abaThanks @natemoo-re! - Add user-configurablesitemapFilteroption.This option can be used to ensure certain pages are excluded from your final sitemap.
// astro.config.ts import type { AstroUserConfig } from 'astro' const config: AstroUserConfig = { sitemap: true, sitemapFilter: (page: string) => !page.includes('secret-page') } export default config -
#2767
2bb2c2f7Thanks @natemoo-re! - Update@astrojs/compilerto0.12.0 -
#2705
72c2c86eThanks @natemoo-re! - Fixes the static build to write to 404.html -
#2705
72c2c86eThanks @natemoo-re! - Fixes use of private .env variables with the static build -
#2750
79fc3204Thanks @FredKSchott! - update esbuild@0.14.25 -
#2737
e8d4e568Thanks @natemoo-re! - Astro's logger has been redesigned for an improved experience! In addition to deduping identical messages, we've surfaced more error details and exposed new events likeupdate(for in-place HMR) andreload(for full-reload HMR). -
#2733
6bf124fbThanks @FredKSchott! - Remove a bad dev warning -
#2768
49c0d997Thanks @matthewp! - Fixes loading astro/client/* on Windows in dev -
#2758
499fb6a3Thanks @natemoo-re! - Add CLI warnings when running a prerelease or outdated version of Astro -
#2705
72c2c86eThanks @natemoo-re! - Replacesenddependency withsirv -
#2732
0ae96bb7Thanks @bholmesdev! - Update server start message to use localhost for local hostnames -
#2743
a14075e2Thanks @bholmesdev! - Fix - show 404 for bad static paths with console message, rather than a 500
Patch Changes
-
#2755
10843abaThanks @natemoo-re! - Add user-configurablesitemapFilteroption.This option can be used to ensure certain pages are excluded from your final sitemap.
// astro.config.ts import type { AstroUserConfig } from 'astro' const config: AstroUserConfig = { sitemap: true, sitemapFilter: (page: string) => !page.includes('secret-page') } export default config -
#2750
79fc3204Thanks @FredKSchott! - update esbuild@0.14.25 -
#2758
499fb6a3Thanks @natemoo-re! - Add CLI warnings when running a prerelease or outdated version of Astro -
#2743
a14075e2Thanks @bholmesdev! - Fix - show 404 for bad static paths with console message, rather than a 500
Minor Changes
-
af075d81Thanks @natemoo-re! - Visual redesign of theastro devCLI, including newastro --helpandastro --versionoutputs.These changes introduce a new startup screen, make it more obvious when a file triggers in-place HMR (
update) or a full reload (reload), and improve the way Astro surfaces errors during dev. -
#2747
05b66bd6Thanks @natemoo-re! - Escape HTML inside of expressions by default. Please see our migration guide for more details.
Patch Changes
-
#2695
ae8d9256Thanks @natemoo-re! - UpdateAstro.slotsAPI with new publichasandrendermethods.This is a backwards-compatible change—
Astro.slots.defaultwill still betrueif the component has been passed adefaultslot.if (Astro.slots.has('default')) { const content = await Astro.slots.render('default'); } -
#2705
72c2c86eThanks @natemoo-re! - Fixes the static build to write to 404.html -
#2737
e8d4e568Thanks @natemoo-re! - Astro's logger has been redesigned for an improved experience! In addition to deduping identical messages, we've surfaced more error details and exposed new events likeupdate(for in-place HMR) andreload(for full-reload HMR). -
#2733
6bf124fbThanks @FredKSchott! - Remove a bad dev warning -
#2732
0ae96bb7Thanks @bholmesdev! - Update server start message to use localhost for local hostnames
Minor Changes
-
#2705
8ce63ee6Thanks @natemoo-re! - New default build strategyThis change marks the "static build" as the new default build strategy. If you are unfamiliar with this build strategy check out the migration guide on how to change your code to be compatible with this new bulid strategy.
If you'd like to keep using the old build strategy, use the flag
--legacy-buildboth in yourastro devandastro buildscripts, for ex:{ "scripts": { "build": "astro build --legacy-build" } }Note that the legacy build is deprecated and will be removed in a future version. You should only use this flag until you have the time to migration your code.
- Updated
<head>and<body>behavior
Since
astro@0.21, Astro placed certain restrictions on what files could use<head>or<body>tags. Inastro@0.24, the restrictions have been lifted. Astro will be able to correctly handle<head>and<body>tags in any component, not just those insrc/pages/orsrc/layouts/. - Updated
Patch Changes
-
#2705
176d4082Thanks @natemoo-re! - Fixes use of private .env variables with the static build -
#2705
a483c044Thanks @natemoo-re! - Replacesenddependency withsirv
Patch Changes
-
#2697
91765d79Thanks @FredKSchott! - Improve build performance by processingssrPreloadin serial rather than in parallel -
#2684
c7bbb112Thanks @natemoo-re! - Fix issue where HMR could be triggered duringastro build -
Updated dependencies [
91765d79]:- @astrojs/markdown-remark@0.6.3
Patch Changes
- #2681
046af364Thanks @natemoo-re! - Fix HMR regression related to fine-grained.astroHMR. This fixes HMR for Tailwind and CSS styles when.astrofiles are edited.
Patch Changes
-
#2665
0494f74eThanks @natemoo-re! - Improve compatability with third-party Astro packages -
#2656
fca64073Thanks @FredKSchott! - fix astro scoping of "@import" inside of style tags
Patch Changes
-
ac6d2e8cThanks @FredKSchott! - Fix issue with Non-HTML pages in static build for dev -
#2628
9b7e2ab2Thanks @JuanM04! - Fixed shiki to work with{ "type": "module" } -
#2630
a2128f8eThanks @JuanM04! - Fixed incorrect types and imports -
#2653
17032cd0Thanks @natemoo-re! - Update@astrojs/compiler, fixing a bug with self-closing tags that need special consideration like<title />and<script /> -
#2654
a0fc5cb5Thanks @FredKSchott! - Fix an issue where utf8 encoding was skipped in the dev server. -
#2649
5091d788Thanks @natemoo-re! - Add fine-grained HMR support for Astro files -
#2645
2e5c3b51Thanks @xavikortes! - Fix issue when process.env.LANG was longer than 5 characters -
Updated dependencies [
9b7e2ab2]:- @astrojs/markdown-remark@0.6.2
Minor Changes
-
#2489
618a16f5Thanks @natemoo-re! - Add support for theset:htmlandset:textdirectives.With the introduction of these directives, unescaped HTML content in expressions is now deprecated. Please migrate to
set:htmlin order to continue injecting unescaped HTML in future versions of Astro—you can use<Fragment set:html={content}>to avoid a wrapper element.set:textallows you to opt-in to escaping now, but it will soon become the default. -
#2494
d7149f9bThanks @FredKSchott! - Refactor dev server to use vite server internally.This should be an invisible change, and no breaking changes are expected from this change. However, it is a big enough refactor that some unexpected changes may occur. If you've experienced a regression in the dev server, it is most likely a bug!
-
#2586
d6d35bcaThanks @tony-sull! - Support for non-HTML pages⚠️ This feature is currently only supported with the
--experimental-static-buildCLI flag. This feature may be refined over the next few weeks/months as SSR support is finalized.This adds support for generating non-HTML pages form
.jsand.tspages during the build. Built file and extensions are based on the source file's name, ex:src/pages/data.json.tswill be built todist/data.json.Is this different from SSR? Yes! This feature allows JSON, XML, etc. files to be output at build time. Keep an eye out for full SSR support if you need to build similar files when requested, for example as a serverless function in your deployment host.
Examples
// src/pages/company.json.ts export async function get() { return { body: JSON.stringify({ name: 'Astro Technology Company', url: 'https://astro.build/', }), }; }What about
getStaticPaths()? It just works™.export async function getStaticPaths() { return [ { params: { slug: 'thing1' }}, { params: { slug: 'thing2' }} ] } export async function get(params) { const { slug } = params return { body: // ...JSON.stringify() } } -
#2424
1abb9ed0Thanks @natemoo-re! - Upgradeviteto2.8.x, unvendoringviteand bringing Astro's dependencies up-to-date.This is a low-level change that you shouldn't have to worry about too much, but it should fix many, many issues with CJS/ESM interoperability. It also allows Astro to stay up-to-date with the
viteecosystem. If you run into any unexpected problems, please let us know by opening an issue. -
#2471
c9bb1147Thanks @FredKSchott! - Standardize trailing subpath behavior in config.Most users are not aware of the subtle differences between
/fooand/foo/. Internally, we have to handle both which means that we are constantly worrying about the format of the URL, needing to add/remove trailing slashes when we go to work with this property, etc. This change transforms allsitevalues to use a trailing slash internally, which should help reduce bugs for both users and maintainers. -
#2548
ba5e2b5eThanks @matthewp! - Experimental SSR Support⚠️ If you are a user of Astro and see this PR and think that you can start deploying your app to a server and get SSR, slow down a second! This is only the initial flag and very basic support. Styles are not loading correctly at this point, for example. Like we did with the
--experimental-static-buildflag, this feature will be refined over the next few weeks/months and we'll let you know when its ready for community testing.Changes
-
This adds a new
--experimental-ssrflag toastro buildwhich will result indist/server/anddist/client/directories. -
SSR can be used through this API:
import { createServer } from 'http'; import { loadApp } from 'astro/app/node'; const app = await loadApp(new URL('./dist/server/', import.meta.url)); createServer((req, res) => { const route = app.match(req); if(route) { let html = await app.render(req, route); } }).listen(8080); -
This API will be refined over time.
-
This only works in Node.js at the moment.
-
Many features will likely not work correctly, but rendering HTML at least should.
-
Patch Changes
-
#2486
6bd165f8Thanks @matthewp! - Fix for the static build when project contains a space -
#2424
1abb9ed0Thanks @natemoo-re! - Fixes HMR of CSS that is imported from astro, when using the static build flag -
#2522
3e8844faThanks @matthewp! - Fix for CSS superset support and HMR in the static build -
#2506
187d5128Thanks @jonathantneal! - Fix an issue rendering content within HTMLElement -
#2606
96609d4cThanks @matthewp! - Fixes 404 to HMR script in the static build -
#2599
929fae68Thanks @natemoo-re! - Update@astrojs/compilertov0.11.0, which moves from TinyGo to Go's built-in WASM output. This will be a significant improvement for stability and memory safety. -
#2532
b210fd00Thanks @matthewp! - Fixes HMR of .astro modules in astro@next -
#2552
e81bc3cfThanks @matthewp! - Fixes build slowness on large appsThis fixes slowness on large apps, particularly during the static build. Fix is to prevent the Vite dev server plugin from being run during build, as it is not needed.
-
#2605
87762410Thanks @matthewp! - Fixes Astro style resolution in the static build -
#2569
82544e41Thanks @matthewp! - Fixes pageUrlFormat: 'file' in the static build -
#2588
10216176Thanks @matthewp! - Fix for passing children to client component when the component does not render them -
#2531
ef1d81efThanks @FredKSchott! - Fix issue where hostname was not passed to dev server -
#2537
b0666286Thanks @FredKSchott! - Improve debug logs -
#2511
3d2c1849Thanks @matthewp! - Bug fix fordefine:varswith the --experimental-static-build flag -
#2518
2bc91543Thanks @JuanM04! - Added the ability to use custom themes and langs with Shiki (<Code />and@astrojs/markdown-remark) -
#2612
39cbe500Thanks @natemoo-re! - Improve suppport forimport.meta.env.Prior to this change, all variables defined in
.envfiles had to include thePUBLIC_prefix, meaning that they could potentially be visible to the client if referenced.Now, Astro includes any referenced variables defined in
.envfiles onimport.meta.envduring server-side rendering, but only referencedPUBLIC_variables on the client. -
#2471
c9bb1147Thanks @FredKSchott! - Respect subpath URL paths in the fetchContent url property.This fixes an issue where fetchContent() URL property did not include the buildOptions.site path in it.
-
#2538
16d532feThanks @natemoo-re! - Fix rendering of HTML boolean attributes likeopenandasync.Fix rendering of HTML and SVG enumerated attributes like
contenteditableandspellcheck. -
#2570
34317bc0Thanks @matthewp! - Fixes bug with astro/components not loading in the next release -
#2581
ec6f148fThanks @matthewp! - Fix for resolving relative imports from hoisted scripts in the static build. -
#2593
40c0e2b3Thanks @tony-sull! - Dynamic route params should ignore param order when matching paths -
#2594
085468e9Thanks @natemoo-re! - Upgrade@astrojs/compilertov0.10.2 -
Updated dependencies [
a907a73b,cfeaa941,2bc91543,6fe1b027,2bc91543,d71c4620]:- @astrojs/renderer-preact@0.5.0
- @astrojs/renderer-react@0.5.0
- @astrojs/renderer-svelte@0.4.0
- @astrojs/renderer-vue@0.4.0
- @astrojs/markdown-remark@0.6.1
Patch Changes
- #2599
929fae68Thanks @natemoo-re! - Update@astrojs/compilertov0.11.0, which moves from TinyGo to Go's built-in WASM output. This will be a significant improvement for stability and memory safety.
Patch Changes
-
#2586
d6d35bcaThanks @tony-sull! - Support for non-HTML pages⚠️ This feature is currently only supported with the
--experimental-static-buildCLI flag. This feature may be refined over the next few weeks/months as SSR support is finalized.This adds support for generating non-HTML pages form
.jsand.tspages during the build. Built file and extensions are based on the source file's name, ex:src/pages/data.json.tswill be built todist/data.json.Is this different from SSR? Yes! This feature allows JSON, XML, etc. files to be output at build time. Keep an eye out for full SSR support if you need to build similar files when requested, for example as a serverless function in your deployment host.
Examples
// src/pages/company.json.ts export async function get() { return { body: JSON.stringify({ name: 'Astro Technology Company', url: 'https://astro.build/', }), }; }What about
getStaticPaths()? It just works™.export async function getStaticPaths() { return [ { params: { slug: 'thing1' }}, { params: { slug: 'thing2' }} ] } export async function get(params) { const { slug } = params return { body: // ...JSON.stringify() } } -
#2548
ba5e2b5eThanks @matthewp! - Experimental SSR Support⚠️ If you are a user of Astro and see this PR and think that you can start deploying your app to a server and get SSR, slow down a second! This is only the initial flag and very basic support. Styles are not loading correctly at this point, for example. Like we did with the
--experimental-static-buildflag, this feature will be refined over the next few weeks/months and we'll let you know when its ready for community testing.Changes
-
This adds a new
--experimental-ssrflag toastro buildwhich will result indist/server/anddist/client/directories. -
SSR can be used through this API:
import { createServer } from 'http'; import { loadApp } from 'astro/app/node'; const app = await loadApp(new URL('./dist/server/', import.meta.url)); createServer((req, res) => { const route = app.match(req); if(route) { let html = await app.render(req, route); } }).listen(8080); -
This API will be refined over time.
-
This only works in Node.js at the moment.
-
Many features will likely not work correctly, but rendering HTML at least should.
-
-
#2581
ec6f148fThanks @matthewp! - Fix for resolving relative imports from hoisted scripts in the static build. -
#2594
085468e9Thanks @natemoo-re! - Upgrade@astrojs/compilertov0.10.2
Minor Changes
-
#2424
1abb9ed0Thanks @natemoo-re! - Upgradeviteto2.8.x, unvendoringviteand bringing Astro's dependencies up-to-date.This is a low-level change that you shouldn't have to worry about too much, but it should fix many, many issues with CJS/ESM interoperability. It also allows Astro to stay up-to-date with the
viteecosystem. If you run into any unexpected problems, please let us know by opening an issue.
Patch Changes
-
#2424
1abb9ed0Thanks @natemoo-re! - Fixes HMR of CSS that is imported from astro, when using the static build flag -
Updated dependencies [
a907a73b]:- @astrojs/renderer-preact@0.5.0-next.0
- @astrojs/renderer-react@0.5.0-next.0
- @astrojs/renderer-svelte@0.4.0-next.0
- @astrojs/renderer-vue@0.4.0-next.0
Patch Changes
-
#2532
b210fd00Thanks @matthewp! - Fixes HMR of .astro modules in astro@next -
#2531
ef1d81efThanks @FredKSchott! - Fix issue where hostname was not passed to dev server -
#2537
b0666286Thanks @FredKSchott! - Improve debug logs -
#2518
2bc91543Thanks @JuanM04! - Added the ability to use custom themes and langs with Shiki (<Code />and@astrojs/markdown-remark) -
#2538
16d532feThanks @natemoo-re! - Fix rendering of HTML boolean attributes likeopenandasync.Fix rendering of HTML and SVG enumerated attributes like
contenteditableandspellcheck. -
Updated dependencies [
cfeaa941,2bc91543,2bc91543]:- @astrojs/markdown-remark@0.6.1-next.1
Minor Changes
-
#2489
618a16f5Thanks @natemoo-re! - Add support for theset:htmlandset:textdirectives.With the introduction of these directives, unescaped HTML content in expressions is now deprecated. Please migrate to
set:htmlin order to continue injecting unescaped HTML in future versions of Astro—you can use<Fragment set:html={content}>to avoid a wrapper element.set:textallows you to opt-in to escaping now, but it will soon become the default. -
#2494
d7149f9bThanks @FredKSchott! - Refactor dev server to use vite server internally.This should be an invisible change, and no breaking changes are expected from this change. However, it is a big enough refactor that some unexpected changes may occur. If you've experienced a regression in the dev server, it is most likely a bug!
-
#2471
c9bb1147Thanks @FredKSchott! - Standardize trailing subpath behavior in config.Most users are not aware of the subtle differences between
/fooand/foo/. Internally, we have to handle both which means that we are constantly worrying about the format of the URL, needing to add/remove trailing slashes when we go to work with this property, etc. This change transforms allsitevalues to use a trailing slash internally, which should help reduce bugs for both users and maintainers.
Patch Changes
-
#2486
6bd165f8Thanks @matthewp! - Fix for the static build when project contains a space -
#2506
187d5128Thanks @jonathantneal! - Fix an issue rendering content within HTMLElement -
#2511
3d2c1849Thanks @matthewp! - Bug fix fordefine:varswith the --experimental-static-build flag -
#2471
c9bb1147Thanks @FredKSchott! - Respect subpath URL paths in the fetchContent url property.This fixes an issue where fetchContent() URL property did not include the buildOptions.site path in it.
-
Updated dependencies [
6fe1b027]:- @astrojs/markdown-remark@0.6.1-next.0
Patch Changes
-
#2491
c7a6ed9aThanks @jonathantneal! - Fixed top-level await and other es features with the static build -
#2479
005751a9Thanks @natemoo-re! - Add theescapeHTMLutility toastro/internal -
#2490
69d5b709Thanks @matthewp! - Fix for CSS preprocessing using the static build -
#2491
c7a6ed9aThanks @jonathantneal! - Renders server-side HTMLElement as HTML tag
Patch Changes
-
#2423
ebe414f0Thanks @delucis! - Resolve sitemap URLs in relation to full site path -
#2443
ed0b46f9Thanks @natemoo-re! - Fix bug with RSS feed generation.rss()can now be called multiple times and URLs can now be fully qualified. -
#2442
dfe1f8b4Thanks @matthewp! - Allow setting ssr Vite config in the static build
Patch Changes
-
#2371
85ad1aabThanks @natemoo-re! - Add support for styled RSS feeds using the newstylesheetoption -
#2416
5208c88aThanks @matthewp! - Adds Astro.resolve deprecation for the static build -
#2392
24aa3245Thanks @obnoxiousnerd! - Support markdown draft pages. Markdown draft pages are markdown pages which havedraftset in their frontmatter. By default, these will not be built by Astro while runningastro build. To disable this behavior, you need to setbuildOptions.draftstotrueor pass the--draftsflag while runningastro build. An exaple of a markdown draft page is:--- # src/pages/blog-post.md title: My Blog Post draft: true --- This is my blog post which is currently incomplete.
Patch Changes
-
#2335
f008a19cThanks @jonathantneal! - Preserve pathnames for sitemap.xml -
#2358
10074972Thanks @matthewp! - Fixes the output when using the experimental-static-build flag -
#2323
69af658bThanks @jonathantneal! - Fix issue with plugins running twice in dev and build -
#2338
c0cb7eeaThanks @jonathantneal! - Fix preview issues triggered by pageUrlFormat & trailingSlash options -
#2363
7e0b32c5Thanks @matthewp! - Fixes use of --experimental-static-build with markdown pages
Patch Changes
-
#2324
77ef43e6Thanks @natemoo-re! - Update compiler to remove console.log (sorry everyone!) -
e0de21efThanks @FredKSchott! - Add<guid>to RSS feed. -
#2318
c0204c0aThanks @natemoo-re! - Update@astrojs/compilerto0.7.3 -
#2319
e6379d51Thanks @jonathantneal! - Updated @astropub/webapi
Patch Changes
-
#2299
5fbdd56fThanks @tadeuzagallo! - Fix dynamic routes for sites with subpath -
#2308
e98659b7Thanks @natemoo-re! - Update the Astro compiler, fixing a number of bugs
Patch Changes
-
#2137
cc1dae55Thanks @natemoo-re! - Exclude 404 pages from sitemap generation -
#2112
da7b41f5Thanks @drwpow! - Bugfix: fix missing styles in build -
#2116
d9d3906aThanks @e111077! - add lit renderer reflection tests -
#2135
77c3fda3Thanks @natemoo-re! - Patchfetchsupport to prioritize authored code. Existingfetchimports and declarations are respected.
Patch Changes
- #2096
11798a32Thanks @jonathantneal! - Updates @astro/compiler and @astro/language-server.
Patch Changes
-
#2065
c6e4e283Thanks @drwpow! - Bugfix: improve CSS import order -
#2081
62a5e98cThanks @drwpow! - Bugfix: CSS import ordering, empty CSS output on build -
#2086
2a2eaadcThanks @matthewp! - Fixes invalidation of proxy module (inline script modules) -
#2048
1301f3daThanks @matthewp! - Updates Astro.resolve to return project-relative paths -
#2078
ac3e8702Thanks @natemoo-re! - Fix behavior of renderers when no children are passed in -
#2091
0a826c99Thanks @drwpow! - Bugfix: allow special characters in filenames -
#2064
5bda895fThanks @jonathantneal! - Fixes an issue where void elements are rendered with opening and closing tags. -
#2076
920d3da1Thanks @tony-sull! - Improving build validation and error messages for client hydration directives -
#2075
b348ca6cThanks @drwpow! - Bugfix: allow dynamic importing of rehype plugins -
Updated dependencies [
ac3e8702]:- @astrojs/renderer-preact@0.3.1
- @astrojs/renderer-react@0.3.1
- @astrojs/renderer-svelte@0.2.2
- @astrojs/renderer-vue@0.2.1
Patch Changes
-
341ec3cd: Fixes dev errors in hydrated components
The errors would occur when there was state changes in hydrated components. This only occurs in dev but does result in the hydrated component not working. This fixes the underlying issue.
-
4436592d: Fix crash with unexpected file types in pages directory
-
50f3b8d7: Bugfix: improve style and script injection for partial pages
-
fad6bd09: Fixes use of
PUBLIC_to reference env varsPreviously
PUBLIC_worked in server-only components such as .astro components. However if you had a client-side component you had to useVITE_. This was a bug with our build that is now fixed.
Patch Changes
- 76559faa: Chore: update compiler
Patch Changes
- 8a5de030: Fix client:visible with multiple copies of same component
- 9ed6b3c0: Update compiler with the following patches:
- Fix components supporting only one style or script
- Fix regression where leading
<style>elements could break generated tags - Fix case-sensitivity of void elements
- Fix expressions not working within SVG elements
- Fix panic when preprocessed style is empty
- 7a7427e4: Fix CSS URLs on Windows
- Updated dependencies [4cec1256]
- @astrojs/renderer-svelte@0.2.1
Patch Changes
- 22dd6bf6: Support
lang="postcss"in addition tolang="pcss" - d3476f24: Bump Sass dependency version
- 679d4395: Added
MarkdownParserandMarkdownParserResponseto@types - e4945232: Fix a host of compiler bugs, including:
- CSS scoping of
*character inside ofcalc()expressions - Encoding of double quotes inside of quoted attributes
- Expressions inside of
<table>elements
- CSS scoping of
- 8cb77959: Fixes building of non-hoisted scripts
- fc5f4163: Fix regression with
astro build404.astro output - Updated dependencies [679d4395]
- @astrojs/markdown-remark@0.5.0
Patch Changes
- 8775730e: Fix CSS scanning bug that could lead to infinite loops
- aec4e8da: Fix client:only behavior when only a single renderer is configured
Minor Changes
-
e6aaeff5: Astro 0.21 is here! Read the complete migration guide.
This new version of Astro includes:
- A new, faster, Go-based compiler
- A completely new runtime backed by Vite, with significantly dev experience improvements
- Improved support for loading Astro config files, including
.cjs,.js, and.tsfiles - And many more features!
Patch Changes
- Updated dependencies [e6aaeff5]
- Updated dependencies [e6aaeff5]
- Updated dependencies [e6aaeff5]
- @astrojs/renderer-preact@0.3.0
- @astrojs/renderer-react@0.3.0
- @astrojs/renderer-svelte@0.2.0
- @astrojs/renderer-vue@0.2.0
- @astrojs/markdown-remark@0.4.0
- @astrojs/prism@0.3.0
Patch Changes
- 8733599e: Adds missing vite dependency, vixing svelte and vue
- 2e0c790b: Fix Lit renderer built
Patch Changes
- 00d2b625: Add Vite dependencies to astro
- Updated dependencies [00d2b625]
- @astrojs/markdown-remark@0.4.0-next.2
Patch Changes
- c7682168: Fix build by making vendored vite resolve to copy
Patch Changes
- 41c6a772: Fix for dev server not starting
- 3b511059: Fix for OSX .astro file corruption
Patch Changes
- c82ceff7: Bug fix for Debug when passed JSON contain HTML strings
- 53d9cf5e: Fixes dev server not stopping cleanly
- 8986d33b: Improve error display
- Updated dependencies [8986d33b]
- @astrojs/renderer-vue@0.2.0-next.2
Patch Changes
- dbc49ed6: Fix HMR regression
- 6b598b24: Fix middleware order
- 0ce86dfd: Fixes Vue scoped styles when built
Patch Changes
- 0f9c1910: Fixes routing regression in next.4. Subpath support was inadvertedly prevent any non-index routes from working when not using a subpath.
Patch Changes
-
b958088c: Make astro-root be a display: contents element
-
65d17857: Fixes hoisted scripts to be bundled during the build
-
3b8f201c: Add build output
-
824c1f20: Re-implement client:only support
-
3cd1458a: Bugfix: Bundled CSS missing files on Windows
-
4e55be90: Fixes layout file detection on non-unix environments
-
fca1a99d: Provides first-class support for a site deployed to a subpath
Now you can deploy your site to a subpath more easily. Astro will use your
buildOptions.siteURL and host the dev server from there.If your site config is
http://example.com/blogyou will need to go tohttp://localhost:3000/blog/in dev and when usingastro preview.Includes a helpful 404 page when encountering this in dev and preview.
-
65216ef9: Bugfix: PostCSS not working in all contexts
-
Updated dependencies [3cd1458a]
- @astrojs/renderer-preact@0.3.0-next.1
- @astrojs/renderer-react@0.3.0-next.1
- @astrojs/renderer-svelte@0.2.0-next.1
- @astrojs/renderer-vue@0.2.0-next.1
Patch Changes
- 7eaabbb0: Fix error with Markdown content attribute parsing
- fd52bcee: Update the build to build/bundle assets
- 7eaabbb0: Fix bug with attribute serialization
- Updated dependencies [7eaabbb0]
- @astrojs/markdown-remark@0.4.0-next.1
Patch Changes
- fbae2bc5: Improve support for Astro config files.
In addition to properly loading .cjs and .js files in all cases, Astro now supports astro.config.ts files.
For convenience, you may now also move your astro.config.js file to a top-level config/ directory.
- 2e1bded7: Improve Tailwind HMR in
devmode - Fix bug when using
<Markdown></Markdown>with no content - Support
PUBLIC_prefixed.envvariables - Respect
tsconfig.jsonandjsconfig.jsonpaths as aliases
Patch Changes
-
11ee158a: Fix issue with
styleandscriptprocessing where siblings would be skippedFix
Fragmentand<>handling for backwards compatabilityFix CSS
--custom-proprtyparsing when using scoped CSS
Minor Changes
-
d84bfe71: Astro 0.21 Beta release! This introduces the new version of Astro that includes:
- A new, faster, Go-based compiler
- A runtime backed by Vite, with faster dev experience
- New features
See more at https://astro.build/blog/astro-021-preview/
Patch Changes
- Updated dependencies [d84bfe71]
- Updated dependencies [d84bfe71]
- Updated dependencies [d84bfe71]
- @astrojs/prism@0.3.0-next.0
- @astrojs/markdown-remark@0.4.0-next.0
- @astrojs/renderer-preact@0.3.0-next.0
- @astrojs/renderer-react@0.3.0-next.0
- @astrojs/renderer-svelte@0.2.0-next.0
- @astrojs/renderer-vue@0.2.0-next.0
Patch Changes
- Updated dependencies [31d06880]
- @astrojs/renderer-vue@0.1.9
Patch Changes
- 6813106a: Improve getStaticPaths memoization to successfully store values in the cache
Patch Changes
-
dbd2f507: Adds the
astro checkcommandThis adds a new command,
astro checkwhich runs diagnostics on a project. The same diagnostics run within the Astro VSCode plugin! Just run:astro checkWhich works a lot like
tscand will give you error messages, if any were found. We recommend adding this to your CI setup to prevent errors from being merged.
Patch Changes
- Updated dependencies [756e3769]
- @astrojs/renderer-react@0.2.2
Patch Changes
- 30835635: Fixed props shadowing
Patch Changes
- 3a0dcbe9: Fix pretty byte output in build stats
- 98d785af: Expose slots to components
Patch Changes
- dd92871f: During CSS bundling separate processing of
rel="preload"from normal loading stylesheets, to preserve preloads, and source element attributes likemedia. - d771dad6: Remove check for referenced files
- 9cf2df81: Improve stats logging to use
pretty-bytesso that 20B doesn't get output as 0kB, which is accurate, but confusing - 09b2f0e4: Fix passing Markdown content through props (#1259)
- Updated dependencies [97d37f8f]
- @astrojs/renderer-preact@0.2.2
- @astrojs/renderer-react@0.2.1
- @astrojs/renderer-svelte@0.1.2
- @astrojs/renderer-vue@0.1.8
Patch Changes
- 3b4bbdc9: Add human readable config verification errors
- b668117c: Sitemaps will not create entries for 404.html pages
- 00fd7ca4: Fix parsing of an empty
<pre></pre>tag in markdown files, which expected the pre tag to have a child - e282e8e4: Add new
<Code>component, powered by the more modern shiki syntax highlighter. - ac2c00e9: Fix astro bin bug in some pre-ESM versions of Node v14.x
- Updated dependencies [00fd7ca4]
- Updated dependencies [7cb31c6e]
- @astrojs/markdown-support@0.3.1
Patch Changes
- 231964f0: Adds interfaces for built-in components
Patch Changes
- 290f2032: Fix knownEntrypoint warning for __astro_hoisted_scripts.js
Patch Changes
-
788c769d: # Hoisted scripts
This change adds support for hoisted scripts, allowing you to bundle scripts together for a page and hoist them to the top (in the head):
<script hoist> // Anything goes here! </script> -
Updated dependencies [5d2ea578]
- @astrojs/parser@0.20.2
Patch Changes
- ff92be63: Add a new "astro preview" command
Minor Changes
-
affcd04f: [BREAKING CHANGE] stop bundling, building, and processing public files. This fixes an issue where we weren't actually honoring the "do not process" property of the public directory.
If you were using the
public/directory as expected and not using it to build files for you, then this should not be a breaking change. However, will notice that these files are no longer bundled.If you were using the
public/directory to build files (for example, likepublic/index.scss) then you can expect this to no longer work. As per the correct Astro documentation.
Patch Changes
- Updated dependencies [397d8f3d]
- @astrojs/markdown-support@0.3.0
Patch Changes
- 44fb8ebc: Remove non-null assertions, fix lint issues and enable lint in CI.
- 9482fade: Makes sure Astro.resolve works in nested component folders
Patch Changes
-
f9cd0310: Fix TypeScript "types" reference in package.json
-
f9cd0310: Improve schema validation using zod
-
efb41f22: Add
<Debug>component for JavaScript-free client-side debugging.--- import Debug from 'astro/debug'; const obj = { /* ... */ } --- <Debug {obj} />
Patch Changes
- 3e605d7e: Add real-world check for ESM-CJS compatability to preflight check
- 1e0e2f41: Including Prism's
language-class on code block<pre>tags - 166c9ed6: Fix an issue where getStaticPaths is called multiple times per build
- c06da5dd: Add configuration options for url format behavior:
buildOptions.pageUrlFormat&trailingSlash - c06da5dd: Move 404.html output from /404/index.html to /404.html
Patch Changes
- ece0953a: Fix CSS :global() selector bug
- Updated dependencies [a421329f]
- @astrojs/markdown-support@0.2.4
Minor Changes
-
239065e2: [BREAKING] Replace the Collections API with new file-based routing.
This is a breaking change which impacts collections, pagination, and RSS support. Runtime warnings have been added to help you migrate old code to the new API. If you have trouble upgrading, reach out on https://astro.build/chat
This change was made due to confusion around our Collection API, which many users found difficult to use. The new file-based routing approach should feel more familiar to anyone who has used Next.js or SvelteKit.
Documentation added:
-
239065e2: Adds support for Astro.resolve
Astro.resolve()helps with creating URLs relative to the current Astro file, allowing you to reference files within yoursrc/folder.Astro does not resolve relative links within HTML, such as images:
<img src="../images/penguin.png" />The above will be sent to the browser as-is and the browser will resolve it relative to the current page. If you want it to be resolved relative to the .astro file you are working in, use
Astro.resolve:<img src={Astro.resolve('../images/penguin.png')} /> -
239065e2: Adds support for client:only hydrator
The new
client:onlyhydrator allows you to define a component that should be skipped during the build and only hydrated in the browser.In most cases it is best to render placeholder content during the build, but that may not always be feasible if an NPM dependency attempts to use browser APIs as soon as is imported.
Note If more than one renderer is included in your Astro config, you need to include a hint to determine which renderer to use. Renderers will be matched to the name provided in your Astro config, similar to
<MyComponent client:only="@astrojs/renderer-react" />. Shorthand can be used for@astrojsrenderers, i.e.<MyComponent client:only="react" />will use@astrojs/renderer-react.An example usage:
--- import BarChart from '../components/BarChart.jsx'; --- <BarChart client:only /> /** * If multiple renderers are included in the Astro config, * this will ensure that the component is hydrated with * the Preact renderer. */ <BarChart client:only="preact" /> /** * If a custom renderer is required, use the same name * provided in the Astro config. */ <BarChart client:only="my-custom-renderer" />This allows you to import a chart component dependent on d3.js while making sure that the component isn't rendered at all at build time.
Patch Changes
- @astrojs/parser@0.18.6
Minor Changes
-
1971ab3c: Adds support for client:only hydrator
The new
client:onlyhydrator allows you to define a component that should be skipped during the build and only hydrated in the browser.In most cases it is best to render placeholder content during the build, but that may not always be feasible if an NPM dependency attempts to use browser APIs as soon as is imported.
Note If more than one renderer is included in your Astro config, you need to include a hint to determine which renderer to use. Renderers will be matched to the name provided in your Astro config, similar to
<MyComponent client:only="@astrojs/renderer-react" />. Shorthand can be used for@astrojsrenderers, i.e.<MyComponent client:only="react" />will use@astrojs/renderer-react.An example usage:
--- import BarChart from '../components/BarChart.jsx'; --- <BarChart client:only /> /** * If multiple renderers are included in the Astro config, * this will ensure that the component is hydrated with * the Preact renderer. */ <BarChart client:only="preact" /> /** * If a custom renderer is required, use the same name * provided in the Astro config. */ <BarChart client:only="my-custom-renderer" />This allows you to import a chart component dependent on d3.js while making sure that the component isn't rendered at all at build time.
Patch Changes
-
1f13e403: Fix CSS scoping issue
-
78b5bde1: Adds support for Astro.resolve
Astro.resolve()helps with creating URLs relative to the current Astro file, allowing you to reference files within yoursrc/folder.Astro does not resolve relative links within HTML, such as images:
<img src="../images/penguin.png" />The above will be sent to the browser as-is and the browser will resolve it relative to the current page. If you want it to be resolved relative to the .astro file you are working in, use
Astro.resolve:<img src={Astro.resolve('../images/penguin.png')} />
Patch Changes
- 089d1e7a: update dependencies, and fix a bad .flat() call
Patch Changes
- c881e71e: Revert 939b9d0 "Allow dev server port to be set by PORT environment variable"
Minor Changes
-
0f0cc2b9: [BREAKING] Replace the Collections API with new file-based routing.
This is a breaking change which impacts collections, pagination, and RSS support. Runtime warnings have been added to help you migrate old code to the new API. If you have trouble upgrading, reach out on https://astro.build/chat
This change was made due to confusion around our Collection API, which many users found difficult to use. The new file-based routing approach should feel more familiar to anyone who has used Next.js or SvelteKit.
Documentation added:
Patch Changes
- Fix curly bracket encoding issue in markdown
No changes
- Fixes a bad build were
nextwas accidentally published to astro@0.18.11.
Patch Changes
- Revert 939b9d0 "Allow dev server port to be set by PORT environment variable" due to bug
Patch Changes
- 2321b577: - Allow Markdown with scoped styles to coexist happily with code syntax highlighting via Prism
- 618ea3a8: Properly escapes script tags with nested client:load directives when passing Astro components into framework components via props. Browsers interpret script end tags in strings as script end tags, resulting in syntax errors.
- 939b9d01: Allow dev server port to be set by
PORTenvironment variable - Updated dependencies [1339d5e3]
- @astrojs/renderer-vue@0.1.7
Patch Changes
- 8cf0e65a: Fixes a previous revert, makes sure head content is injected into the right place
- 8cf0e65a: Refactor the CLI entrypoint to support stackblitz and improve the runtime check