
πΏ 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' modeconst cart = await Astro.session.get('cart');---<a href="/checkout">π {cart?.length ?? 0} items</a>Sessions are available in on-demand rendered/SSR pages, API endpoints, actions and middleware. To enable session support, you must configure a storage driver.
If you are using the Node.js adapter, you can use the
fsdriver to store session data on the filesystem:astro.config.mjs {adapter: node({ mode: 'standalone' }),experimental: {session: {// Required: the name of the unstorage driverdriver: "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:src/components/my-component.astro <script>import { actions, getActionPath } from 'astro:actions';await fetch(getActionPath(actions.like), {method: 'POST',headers: {'Content-Type': 'application/json',Authorization: 'Bearer YOUR_TOKEN',},body: JSON.stringify({ id: 'YOUR_ID' }),keepalive: true,});</script>This example shows how to call the same
likeaction using thesendBeaconAPI:src/components/my-component.astro <script>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